tag:blogger.com,1999:blog-35670281126418310532024-03-12T20:57:55.395-07:00Coding4Fun!Playing with what I likeUnknownnoreply@blogger.comBlogger12125tag:blogger.com,1999:blog-3567028112641831053.post-79335392324803242042011-03-06T13:20:00.000-08:002011-04-01T06:48:44.722-07:00Some Near duplicate detectionI've been reading a lot about Data Mining recently and today I came across Shingling, a method for near duplicate detection. <br />
<br />
The algorithm is simple, it creates a set of consecutive substrings of fixed length on 2 two documents and calculates the <a href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard distance</a> between these two sets. The Jaccard distance is a number between 1 and 0, inclusive, calculated as the size of the intersection of two sets divided by the size of their union. i.e |A ∩ B| / |A U B|. If this distance is 1 then the sets are equal.<br />
<br />
Here's a simple implementation of the technique in python:<br />
<br />
<blockquote>shingles = lambda s: set(s[i:i+3] for i in range(len(s)-2))<br />
jaccard_distance = lambda seta, setb: len(seta & setb)/float(len(seta | setb))<br />
<br />
a = raw_input("Original text: ")<br />
b = raw_input("Other text: ")<br />
sa = shingles(a)<br />
sb = shingles(b)<br />
print "These texts are %.2f%% similar" % (jaccard_distance(sa, sb)*100)<br />
</blockquote><br />
Another article I came across is <a href="http://en.wikipedia.org/wiki/MinHash">MinHash</a> which is used for the same purpose.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-25709348527783604592010-11-20T13:26:00.000-08:002010-11-20T13:34:40.107-08:00A Python script using Tornado web server with the Twitter Streaming APISo today I decided to play with <a href="http://www.tornadoweb.org/">Tornado</a> the open source version of a scalable, non-blocking web server which powers <a href="http://friendfeed.com/">FriendFeed</a>. While doing so I discovered it will probably be cool to play with the <a href="http://dev.twitter.com/pages/streaming_api">Twitter streaming API </a>as well and write a Python script that uses both.<br />
<br />
Here's the result of my experiment:<br />
<br />
<blockquote><pre style="font-size: 12px;">from tornado.httpclient import HTTPClient, HTTPRequest
import simplejson
def handle_tweet_stream(response):
try:
# Print the parsed twitter stream.
print simplejson.loads(response)
except ValueError:
return
print
if __name__ == '__main__':
req = HTTPRequest(
"http://stream.twitter.com/1/statuses/filter.json",
body='track=google',
method = "POST",
auth_username = "username",
auth_password = "xxxxxxx",
streaming_callback=handle_tweet_stream)
client = HTTPClient()
client.fetch(req)
</pre></blockquote>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-7917671153269200262010-10-21T13:10:00.000-07:002010-11-02T15:33:57.750-07:00Lessons learned from working in large scaleBefore my internship with Google, I wasn't a big fan of unit tests, logging and cloud computing. Now I can say there's a degree of doubt in me when I see some new code without tests and that this code claims to do the right thing.<br />
<br />
When you're running code in parallel on 1000's of machines in the cloud, machines whose physical location you don't know and machines you don't have shell access to, your idea of project development changes dramatically. Things like logging and unit testing become your friends.<br />
<br />
A good blog on this topic is found on <a href="http://matt-welsh.blogspot.com/2010/10/computing-at-scale-or-how-google-has.html">Matt Welsh's blog</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-29842297490804516942010-03-25T11:48:00.000-07:002010-03-25T11:50:48.672-07:00A one line Python QuineOK, Here's a one line Python program that prints its own source code:<br />
<br />
<blockquote><pre><span style="font-size: large;">s='s=%r;print s%%s';print s%s</span></pre></blockquote><br />
<a href="http://en.wikipedia.org/wiki/Quine_%28computing%29">This wikipedia article on Quines</a> is a very good place to learn how these things workUnknownnoreply@blogger.com1tag:blogger.com,1999:blog-3567028112641831053.post-88952638032014583952010-02-27T11:29:00.001-08:002010-12-30T01:47:47.302-08:00One line quicksort in PythonHere's a one line quicksort in python. I came up with this idea after looking at a 2 lines implementation in Haskel<br />
<blockquote><br />
<div style="font-family: "Courier New",Courier,monospace;">qsort = lambda seq: [] if not seq else qsort(filter(lambda n: n<=seq[0], seq[1:]))+[seq[0]]+qsort(filter(lambda n: n>seq[0], seq[1:]))</div></blockquote>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3567028112641831053.post-22143984520549083812009-12-25T12:57:00.000-08:002009-12-25T12:59:48.708-08:00What goes around comes around<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5_Op-FDEM6HokKRxcOXa6tWmLQ1LgAdUs_ghvH8QBbxDx4utj9mzqBeeNuxbYWvnpyFK5HZ1R74eEwxxPEhfXKuWeK5avtCbCXv9aqNGBKWBFprlnoz4T4fJte6c_lUxcsCVf8B8mQVhm/s1600-h/n653824194_941490_7218.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5_Op-FDEM6HokKRxcOXa6tWmLQ1LgAdUs_ghvH8QBbxDx4utj9mzqBeeNuxbYWvnpyFK5HZ1R74eEwxxPEhfXKuWeK5avtCbCXv9aqNGBKWBFprlnoz4T4fJte6c_lUxcsCVf8B8mQVhm/s320/n653824194_941490_7218.jpg" /> </a><br />
</div><div class="separator" style="clear: both; text-align: center;">Image source: <a href="http://www.facebook.com/group.php?gid=202376966626&ref=mf">http://www.facebook.com/group.php?gid=202376966626&ref=mf</a><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-14940986764802278212009-12-21T03:49:00.000-08:002011-01-25T00:45:18.575-08:005 Handy python functions (lambdas)Here's a list of 5 handy python lambda's you may need when solving a quick maths problem<br />
<br />
<b>1) The sum of all integers from 1 to n</b> <br />
<blockquote><div style="font-family: "Courier New",Courier,monospace;">triangle = lambda n: n*(n+1)/2</div></blockquote><br />
<b>2) Factorial</b><br />
<blockquote><span style="font-family: 'Courier New', Courier, monospace;">factorial = lambda n: 1 if n<2 else n*factorial(n-1)</span></blockquote><b>3) Get odd numbers</b><br />
<blockquote><span style="font-family: 'Courier New', Courier, monospace;">odds = lambda n: [k for k in range(1,n,2)]</span> </blockquote><b>4) Test whether a number is prime</b><br />
<br />
<blockquote><span style="font-family: 'Courier New', Courier, monospace;">is_prime = lambda n: False if n<2 else (0 not in [n%k for k in range(2,int(n**.5)+1)])</span></blockquote>A number is prime when it has no factor other than 1 and itself. To determine whether the number is a prime, we need to check that it doesn't leave a reminder of 0 when divided by each number in the range of [2..square root of the number].<br />
<br />
<b>5) Primes sieve</b><br />
This function returns the list of primes in the range [2..N]. It's the most cryptic of all but it makes use of the previous function to add a number to the generated list.<br />
<blockquote><span style="font-family: 'Courier New', Courier, monospace;">sieve = lambda n: [k for k in range(2,n+1) if (0 not in [k%i for i in range(2,int(k**.5)+1)])]</span></blockquote>It could also be written as:<br />
<br />
<blockquote><span style="font-family: 'Courier New', Courier, monospace;">is_prime = lambda n: False if n<2 else (0 not in [n%k for k in range(2,int(n**.5)+1)])</span></blockquote><blockquote><span style="font-family: 'Courier New', Courier, monospace;">sieve = lambda n: [k for k in range(2,n+1) if is_prime(k)] <br />
</span></blockquote>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3567028112641831053.post-79958769877795144302009-12-15T16:14:00.000-08:002009-12-17T06:37:03.538-08:00Let’s cook a simple yet powerful HTML Editor with Delphi<b>N.B.</b> You might need to read <a href="http://i-coded.blogspot.com/2009/12/using-scintilla-in-delphi-7.html">Using Scintilla in Delphi 7</a> before reading this tutorial.<br />
<br />
I'm cooking a simple WYSIWYG HTML Editor which allows editing a webpage from design mode and source mode just like FrontPage and DreamWeaver do. Things like auto-completion, Style editor and flash are beyond the scope of this tutorial.<br />
<br />
When cooking a simple IDE, syntax highlighting is the ingredient that makes it different from a text editor like notepad. If syntax highlighting never existed and all we had was notepad, I don't think I would have learnt HTML.<br />
<br />
<b>Step 1: Warm the interface</b><br />
Drop a TScintilla (from the Scintilla tab), a TWebBrowser (from the Internet tab) , 3 buttons and a TOpenDialog on the form.<br />
Set the language of the Scintilla control to HTML. So you should have something like this:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwqNrQhuPEV3jwr97RmsZ4NG7hrhU07hzgE-HsRYe3T5tlLpoIbZZ8-ujbNhlAqWFCWhCBxtDRCg2LqngI2jqN_kOEmg7ADXFQLza4klgiKbDoNPSBAevqA_ll9bPrdr1n5XelLSzy4ar1/s1600-h/cook_html.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwqNrQhuPEV3jwr97RmsZ4NG7hrhU07hzgE-HsRYe3T5tlLpoIbZZ8-ujbNhlAqWFCWhCBxtDRCg2LqngI2jqN_kOEmg7ADXFQLza4klgiKbDoNPSBAevqA_ll9bPrdr1n5XelLSzy4ar1/s400/cook_html.png" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">The first button will be for loading the file you want to edit, the second for refreshing the Preview and the third for switching to design mode.<br />
</div><br />
<b>Step 2 (Add some code)</b><br />
In order to get juice out of the TWebBrowser component, you must add the mshtml unit to the code. This unit is interesting because it exposes some of the stuff that make up the engine used by Internet Explorer and other Microsoft programs. An expert HTML user will be very familiar with some of the methods and properties in this module. Here’s the code:<br />
<blockquote><div style="font-family: "Courier New",Courier,monospace;">implementation<br />
{$R *.dfm}<br />
uses<br />
mshtml;<br />
</div></blockquote><b>Step 2 (Loading the HTML file)</b><br />
the first button will simply load an html file onto the webbrowser. Add this code for the Click Event on button1:<br />
<blockquote><span style="font-family: "Courier New",Courier,monospace;">procedure TForm1.Button1Click(Sender: TObject);</span><br />
<span style="font-family: "Courier New",Courier,monospace;">var</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc: IHTMLDocument2;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">begin</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> if not OpenDialog1.Execute then</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> Exit;</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> WebBrowser1.Navigate(OpenDialog1.FileName);</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc:= WebBrowser1.Document as IHTMLDocument2;</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> while doc.readyState <> 'complete' do Application.ProcessMessages;</span><br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> Scintilla1.Lines.Text:= doc.body.innerHTML;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">end;</span><br />
</blockquote>To load the file I used <span style="font-family: "Courier New",Courier,monospace;">WebBrowser1.Navigate(OpenDialog1.FileName);</span><br />
Because I’ll need to retrieve the text from the WebBrowser at some stage, I used a IHTMLDocument2 interface to allow me to read the innerHTML of the document’s body. The head isn’t much needed here. Unfortunately the outerHTML property of the body is read-only. This pauses a problem because I can’t edit attributes set in the tag. You can use file handling routines or another method to be able to access the full source code but we'll stick to this simple method from its simplicity.<br />
<br />
The line <span style="font-family: "Courier New",Courier,monospace;">while doc.readyState <> 'complete' do Application.ProcessMessages;</span> is useful because we’ll get an exception if we try to use the body element because it becomes ready.<br />
<br />
Running the program should give you something like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2eMcVmIMabWG053mee1xFArUwSNhPMUP-pa-3BovyqbZQzhOe5kXBtWHYdsZ9D45sxq3uszLJUPa5qqFnPm7ddnleO2Cuuh1nhN2zzF13uxwsWqCGrrWdNUqNntLKD4P-3kVdbUMDuIMi/s1600-h/cook_html_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2eMcVmIMabWG053mee1xFArUwSNhPMUP-pa-3BovyqbZQzhOe5kXBtWHYdsZ9D45sxq3uszLJUPa5qqFnPm7ddnleO2Cuuh1nhN2zzF13uxwsWqCGrrWdNUqNntLKD4P-3kVdbUMDuIMi/s400/cook_html_2.png" /></a><br />
</div><br />
<b>Step 3 (I can smell it)</b><br />
Now I can edit the html but nothing will happen if I try to preview.<br />
So to connect the two controls, I’ll write the code for button2. It copies the text from the scintilla control into the innerHTML of the document’s body.<br />
<blockquote><span style="font-family: "Courier New",Courier,monospace;">procedure TForm1.Button2Click(Sender: TObject);</span><br />
<span style="font-family: "Courier New",Courier,monospace;">var</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc: IHTMLDocument2;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">begin</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc:= WebBrowser1.Document as IHTMLDocument2;</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc.body.innerHTML:= Scintilla1.Lines.Text;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">end;</span><br />
</blockquote>Now you can test the source code editor. But get the WYSISWYG part we got to the Next step…<br />
<br />
<div style="margin-bottom: 0cm;"><b>Step 4 (The food is ready)</b><br />
</div><div style="margin-bottom: 0cm;">The last button will switch the designMode ‘on’ for the WebBrowser:<br />
</div><blockquote><div style="margin-bottom: 0cm;"><span style="font-family: "Courier New",Courier,monospace;">procedure TForm1.Button3Click(Sender: TObject);</span><br />
<span style="font-family: "Courier New",Courier,monospace;">var</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc: IHTMLDocument2;</span><br />
<span style="font-family: "Courier New",Courier,monospace;">begin</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc:= WebBrowser1.Document as IHTMLDocument2;</span><br />
<span style="font-family: "Courier New",Courier,monospace;"> doc.designMode:= 'on';</span><br />
<span style="font-family: "Courier New",Courier,monospace;">end;</span> <br />
</div></blockquote> OK, That's it! We get this:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUZGrY9Enw0QDSzG74E3kQn1ETazUgqF51dlpBQyxaeR5gY7pfWRYUkDSDluGyOMapGVJ_TjrLfMX2kKqvLCjQcY-1nJXGuinouJb1gG8TfoIxHWA-gy2LbZYJglKEm-2ergHrSC_KPZPR/s1600-h/cook_html_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUZGrY9Enw0QDSzG74E3kQn1ETazUgqF51dlpBQyxaeR5gY7pfWRYUkDSDluGyOMapGVJ_TjrLfMX2kKqvLCjQcY-1nJXGuinouJb1gG8TfoIxHWA-gy2LbZYJglKEm-2ergHrSC_KPZPR/s400/cook_html_3.png" /></a><br />
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3567028112641831053.post-11656367254069847352009-12-15T15:43:00.000-08:002009-12-17T06:45:06.924-08:00Using Scintilla in Delphi 7Scintilla is a cool open source text editing control which supports syntax highlighting, code folding, auto-indentation, line numbers and many more features.<br />
<br />
A list of projects using scintilla can be found on their website (<a href="http://www.scintilla.org/ScintillaRelated.html">http://www.scintilla.org/ScintillaRelated.html</a>).<br />
To use Scintilla in Delphi you must install Delphi Scintilla Interface Components<br />
a.k.a delphisci which is no longer under development but since Delphi 7 itself is older, this shouldn’t be a problem.<br />
<br />
<b>Step 0</b><br />
I’ll use the following names in this tutorial:<br />
- DELPHI_INSTALLATION_FOLDER: The folder where your Delphi is installed<br />
- SYSTEM32: C:\Windows\System32<br />
- DELPHI_SCI_FOLDER: The folder where you unzip delphisci<br />
<br />
<div style="margin-bottom: 0cm;"><b>Step 1 (Getting ready) </b><br />
</div><div style="margin-bottom: 0cm;">Get a copy of delphisci from <a href="http://sourceforge.net/projects/delphisci/files/Delphi%20Scintilla%20Interface%20Cmp/Delphi%20Scintilla%20Interface%20Components%20v0.23/delphisci-0.23_UPD.zip/download">sourceforge</a>, unzip it and inside the unzipped folder, there should be a zip file called scilexer_precompiled_171CVS which contains scilexer.dll (the only external dependency) and put this scilexer.dll in SYSTEM32 if there isn’t one yet.<br />
</div><div style="margin-bottom: 0cm;"><br />
</div><div style="margin-bottom: 0cm;"><b>Step 2 (Installation)</b><br />
</div><div style="margin-bottom: 0cm;">In DELPHI_SCI_FOLDER, there's file names INSTALL which has the instructions for installing delphisci. Follow those instructions. If you struggle with that make sure you:<br />
</div><ol><li>Compiled the right project group for the version of Delphi you are using.<br />
</li>
<li>Installed the package into Delphi (Components->Install Package-> [choose scitD7.bpk from DELPHI_INSTALLATION_FOLDER\Projects\Bpl or go to Tools->Environment Options->Library and ckeck where your Bpl Output Directory is])</li>
</ol><div style="margin-bottom: 0cm;"><b>Step 3 (Successfully running it)</b><br />
If you successfully followed those instructions you should have a Scintilla tab on the components pallette but if you try to run any project using these Scintilla components you get a “[Fatal Error] … File not found: SciLexer.dcu”. That happens because you haven’t added the DELPHI_SCI_FOLDER \d7dcu folder to the Environment yet so Delphi is unable to locate these.<br />
</div><div style="margin-bottom: 0cm;"><br />
</div><div style="margin-bottom: 0cm;"></div><div style="margin-bottom: 0cm;"><b>Step 3.14 </b><br />
</div><div style="margin-bottom: 0cm;">To add the DELPHI_SCI_FOLDER \d7dcu folder to the Environment I’d normally create a folder in DELPHI_INSTALLATION_FOLDER\Scintilla and copy all the files from DELPHI_SCI_FOLDER \d7dcu into this new folder.<br />
</div><div style="margin-bottom: 0cm;"><br />
<b>Step 3.5</b><br />
Now on Delphi, go to Tools->Environment Options->Library and add DELPHI_INSTALLATION_FOLDER\Scintilla to the Library Path<br />
</div><div style="margin-bottom: 0cm;"><br />
<b>Step 4 (Testing)</b><br />
Now to test the installation, create a new application, drop some Scintilla controls to the form and Run it. <br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXeKnvWIZJ_GGusT7DfA9_j3uHH8C5C9rwpAEDMpeVI_-qHYZpOs9nvRNFRwfbhVUv8gyYgRMHXb3D0IOEoWHorMwOnEortaaOhMvqPK-BbYcR6ncRI_IfFFBjej1maMVSCBYssf13F0Gq/s1600-h/install_sci_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXeKnvWIZJ_GGusT7DfA9_j3uHH8C5C9rwpAEDMpeVI_-qHYZpOs9nvRNFRwfbhVUv8gyYgRMHXb3D0IOEoWHorMwOnEortaaOhMvqPK-BbYcR6ncRI_IfFFBjej1maMVSCBYssf13F0Gq/s320/install_sci_1.png" /></a><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><b>Step 5 (Using syntax highlighting)</b><br />
</div>When you first drop a TScintilla components on a form, it has no language set and getting the syntax highlighting to work took some working until I realised that you have to Right click on the control -> Select Prefered Languages -> Choose a language and press OK. Then on the property editor, expand the LanguageManager and on the SelectedLanguage drop-down pick the language you chose earlier.<br />
<div class="separator" style="clear: both; text-align: left;">And that's it!<br />
</div><div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4J-IwWh7IlUVIsI6F1gjTtl0mW9PYaJE28DRlPOW0qUgZ9baT9HyuwTOngOFBxIOfXOYMcmw0A2dGi1Z7gijYGAAomnxCUTKaoEdcFpIiLmDlCcn3_i4i43ct9U17pEBYUaPSQtM8Scxv/s1600-h/install_sci_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4J-IwWh7IlUVIsI6F1gjTtl0mW9PYaJE28DRlPOW0qUgZ9baT9HyuwTOngOFBxIOfXOYMcmw0A2dGi1Z7gijYGAAomnxCUTKaoEdcFpIiLmDlCcn3_i4i43ct9U17pEBYUaPSQtM8Scxv/s320/install_sci_2.png" /></a><br />
</div><br />
<div style="margin-bottom: 0cm;">Proceed to Let’s cook a simple yet powerful HTML Editor with Delphi for some action.<br />
</div><br />
<div style="text-align: center;"><span style="font-size: large;"><b>FIN</b></span><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-56294771705619421722009-01-06T06:54:00.000-08:002009-01-06T07:05:33.963-08:00How to get a 3G modem working on Ubuntu 8.04 and other ubuntu'sIn a <a href="http://www.tectonic.co.za/?p=1596">blog post</a> at tectonic that shows how to access to the internet with a 3G card through vodafone-mobile-connect-card-driver, I left a comment for those people struggling to get a permanent connection...<br /><br />The instructions are found <a href="http://www.tectonic.co.za/?p=1596">here</a><br /><br />Here's my addition:<br /><br />1. Plug in the card and restart the computer<br />2. On a terminal type: dir /dev/ttyUSB* and make sure you get something like this:<br />/dev/ttyUSB0<br />/dev/ttyUSB1<br />I found that the software seems to work perfectly only when /dev/ttyUSB0 and /dev/ttyUSB1 both refer to your 3G card. Other ttyUSB's don't seem to work for me<br />3. type sudo poff to make sure that all previous connections are closed. I used sudo because the vodafone-mobile-connect-card-driver-for-linux violates many permission rules when run as a normal user (the documentation told me that). Therefore sudo will grant him all the rights he needs.<br />4. type sudo vodafone-mobile-connect-card-driver-for-linux-debug so that you can see what’s going on. If the program seems to stop printing stuff on the terminal without having printed your contacts list yet, Try closing it and repeat steps 3 and 4.<br /><br />Enjoy the web!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-28619679104802047972009-01-06T06:42:00.000-08:002009-01-06T06:54:02.604-08:00How to download Ubuntu packages from windows without dependency problemsI've finally managed to download ubuntu packages from windows without worrying about unsatisfied dependencies.<br /><br />Today I woke up with one aim: download eclipse. But the problem is that eclipse comes with a host of dependencies, so looking over them in Synpatic, I saw this link that says "Generate downlaod script"<br />1. Mark the required package for installation<br />2. Generate a download script and remove the first line that says <span style="font-weight: bold; color: rgb(204, 204, 255);">"#!/bin/sh"</span><br />3. Download wget for windows from <a href="http://users.ugent.be/%7Ebpuype/wget/#download">http://users.ugent.be/~bpuype/wget/#download</a><br />4. Add the ".bat" extension to the script you generated<br />5. On a windows machine, double click on the script and watch it as it works its way through the packages.<br /><br />wget, Linux, Ubuntu, Synaptic, these things are cool!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3567028112641831053.post-42311482167661000902008-09-12T04:44:00.000-07:002008-09-12T04:55:25.288-07:00How to download music or videos online. (Without RealPlayer)<span style="font-weight: bold;">How to download music/video from websites which will just not let you save their contents on your computer using the menu File->Save as...</span><br /><br />Ever wonderer how to download a funny video you're watching online? Well there's a solution called “Real Player” but before I discovered that I always had suspecions concerning internet streams.<br /><br />Last year I asked a friend to download a video on YouTube for me. His answer was shoking but interesting. He told me: “The computer boffin is out of his mind. He thinks that it's possible to download stuff off YouTube”<br /><br />This answer shocked me. It revealed my ignorance concerning these streaming flash videos. Still I answered with an arrogant tone: “Sure you can, all you need is to write a little program that captures the stream”.<br /><br />Here's my theoretical solution which works with Internet Explorer 6 and 7. I still have to explore Firefox – I just don't have enough freedom, bandwidth and time to write a program that automates this but it shouldn't be hard to write.<br />All you need is patience.<br /><br /><span style="font-weight: bold;">Step 1:</span> Know your browser. IE stores temporary files in a super hidden folder which accumulates lots of junk as you make your way through the net. I presume these files accelerate things like refresh. The mysterious folder is under YOURUSERNAME\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5 or YOURUSERNAME\Local Settings\temporary internet files\content.ie5<br />Firefox (on my compter at least) stores its cache at YOURUSERNAME\AppData\Local\Mozilla\Firefox\Profiles\ejomzlqb.default\Cache<br />For the sake of simplicity I'll call content.ie5 Cache<br /><br /><span style="font-weight: bold;">Step 2:</span> Clear the cache. As you surf the net this folder only gets larger. It can reach a Gig or more without you noticing so I recommand clearing all temporary internet files and manually deleting all the subfolders/files in Cache before doing your thing.<br /><br /><span style="font-weight: bold;">Step 3:</span> Go to the page you wanna download the video from and let the video play until it reaches the end<br /><br /><span style="font-weight: bold;">Step 4:</span> Close your webbrowser immediately and search for the largest file in all of Cache's child folders. This largest file should normally be the video file which is generally encoded in FLV format. In case of music files it's often .MP3 files. So to make it play on your computer just add the appropriate extension to your file (i.e .FLV for videos, .mp3 for music) et Voila! this method works for almost anything for me be it video or audio. When it doesn't work there's a probability the file is encoded differently so just play with common media formats like .swf, .wmv, .mp4 etc... or simply open the file with something like <a href="http://notepad-plus.sourceforge.net">notepad++</a> and check the header.<br /><br />My friend's challenge was a good one! He helped me download more internet streams than I ever imagined. Fortunately Real Media released a plugin for IE users which allows them to download any FLV video. But this plugin doesn't always appear when you want it...Unknownnoreply@blogger.com0