Wednesday, May 23, 2007

Python twisted part 2

Several days ago, I have introduced python twisted (and I just mentioned perl POE. ) The application that I have created on that day needed a new feature, Control Port. It wasn't a big deal. I opened another port with separate protocol that I have defined and spit back CSV of requested report. CSV can be easily turned into a graph. Supporting XML seems like too much for this but can be done easily thanks to BeautifulSoup. I also supported 'stop the daemon' for fun. Took me just 1 hour !!
The beauty of this was that control part seamlessly communicates with collectors because they are running under the same application. At the same time, I do NOT need to think about Threading and locking. How nice it is !!

Thursday, May 17, 2007

python twisted

It is just over 1 year that I have used twisted. I actually used Perl POE before I used twisted. It does not matter which one is chosen. Python users will use twisted, Perl users will use POE. They both are very useful. Personally, I prefer twisted simply because I am a python user.
These are called asynchronous high level network framework. Sometimes word 'abstracted' is attached in introductory contents.
First thing we have to focus is what it is. 'Abstracted' or 'High level' can be best described as 'Protocol Implemented'. I do not have to worry about protocol specifics. I just call methods from objects instantiated from twisted.SomePackage. And asynchronous means, not synchronous. Then, someone may ask what is synchronous? Let's simplify that 'synchronous' is similar way to have conversation between human beings. One person asks, and wait until the other responses. Peers don't speak at the same time. In asynch mode, they do. More in detail can be found in Unix Network Programming ( a.k.a UNP ). There are more in detail about asynchronous communication (non-blocking, signal driven, etc.) I recommend reading UNP for network programmers. Chapters about Async-communication was the best.
With these network frameworks, any network driven application can be very simplified in terms of number of lines of code. Especially, server applications processing custom protocols are very simplified. Buffer handling/IO handling is almost trivial and the performance is even faster thanks to async IO's better utilization of bandwidth.

This morning, I have written another network server processing message from various servers. The key word is 'This Morning'. That's right. I wrote this in low degree of hours. Actually, in 2 hours. I just process the message and stuff into sqlite3, and my life goes on. If I have to write the same code in C, it should take up at least 1 day. :)

Tuesday, May 8, 2007

Stripping HTML tag

I had to write a module to 'word count' a web page. This required to strip the HTML tags out of the url read. I quickly googled, but I felt that this kind of easy problem doesn't even need googling. So, I came up with simple solution.

This is very rough test code written using BeautifulSoup.

http://lucky.umd.edu/code/strip-htmltag.py

Tuesday, May 1, 2007

My tool set

1. springnote.com and basKet:

These are my note takers. I normally use springnote.com because of accessibility. 'Hey, it is another Korean website.' Sorry :)

2. Google tool set:

I do not have to explain what are google tool set. Google always brings one of the essential tools for life. Beginning with gmail, there are calendar, map, earth, doc, personalized google portlets, blog(Of course!), analytics, talk, and most infamous Google SEARCH! I can not live without google.

3. flickr, kflickr, flickrapi(by Beej)

This is one that google couldn't rule. I tried to use picasa from google, flickr really ruled. My pictures and my family's pictures are posted there.

4. kdissert, vym for brain storming.

There is a project called 'freemind'. I used to use it but after I migrated to KDE from gnome, I used kdissert instead. vym helps kdissert. 'freemind' is not a bad tool, but I like simplicity to use in kdissert.

5. bloglines for news read

I use this not only for news reader, but also for good article keeper with 'important' tag. That is very useful.

6. KDE desktop with Gentoo, Ubuntu

When using linux, I chose KDE for my desktop. I started with bare gnome about 7-8 years ago when I first used Linux ( At that time, I just started computer science degree ). Then I moved to blackbox, later it became fluxbox. Then, I moved back to gnome after CPU hits GHz and 512 Mb became general PC memory size. And then, I settled in KDE. KDE is just very easy and well-balanced desktop environment.

7. keychain for ssh-agent

Because of my work, I have to jump from machines to machines. Without this, typing up my password everytime should not be imagined!!

8. Other utilities for fun

Such as amaroK, mplayer, etc.