Sunday, April 27, 2008


I am a little late to install KDE 4 since it was out in the last year. One of my biggest woe was 'what if it is not fully compatible to KDE 3?' It didn't happen, yet. I enabled OpenGL. After I lost interests about compiz-fusion, it's been a long time to work with visual effects.
KDE4 looked nice. At first, I was confused from reorganized menu. But once used to it, it was useful. I liked tab with recent items. KDE4 has zoom feature. I am not sure if it is from OpenGL because it responds pretty fast.
Migration is generally successful. Now, I have to find a time for my work desktop.

Wednesday, April 16, 2008

Another 2:00am wakeup

This happens quite often, these days. I used to sleep through the night. Usually I enjoy doing things in early morning, like 5:00am. 2 isn't good time to wake up. This happens especially I get to sleep with some thoughts. Last night, I was thinking about 'How to generalize test directories'. I collected good number of test cases. My solution is providing default callback handlers, and specific handlers will override if specified. Loading/Unloading/Reloading modules at runtime isn't fun, but better than introspect.
If someone asks 'why is introspect bad?', I don't want to say it is bad. It isn't suitable for callback handler. The code is half open, and the rest half will be provided at runtime. Thanks to duck typing, traceback will byte me way later. With introspect, class name doesn't need to be fixed. I need to grab class name on the fly. But, other than this benefit, whole chain of responsibility comes after that. It is very difficult problem to figure out "Is this the callback handler for event A or B, or is it really a call back handler??" C++ compiler will be useful in this case ;)
If constraining class name by fixing it, I know what I am binding. Much simpler and yeah.. I am lazy.

Tuesday, April 15, 2008

Drawing Chart options.

Pretty chart drawing is a very attractive feature in any software. Why chart is nice? Human perceives 3D space, but human communication is 1D space (Linear!) We speak in just one direction. We read in one direction. But, mixing one segment of information with another is not natural communication method. Remember your history class. For comparative topics between other nations along side with time line, it requires some table. Primitive 2D communication. And if table can be quantified, Chart can come into play for visualizing the quantity. Enhanced 2D communication.

Okay, my tool of choice is python.
First option. Raw rendering using Xlib or GTK or Qt4. Unless they support widgets to play with, rendering with fundamental components (Point, Line, Rectangle, Circle) is painful. It is not an option but making life painful.
Next option. PyChart. Free library to generate image of a chart. Eh~~ okay to use, but not pretty. If I am drawing something, the fancier the better!
Then, Chart Director from Prettier, and free if their credit lable can be bearable. To remove this label, I need to purchase the license. Fortunately, their pricing makes very sense. However, not free.
ReportLab can be another option. ReportLab is a perfect tool for PDF generation, but not very good for rendering sophisticated graphs. And its output format is only PDF.
Gnuplot is another good one. Especially, for time series, gnuplot is one of the best. But, it is a mathematical graph. If I am drawing certain shape, and it does not meet mathematical property, it is not good. And gnuplot speaks its own language. Need to learn it from the documentation.

Google Chart API is my choice. And they begin to support geographical map chart. How nice is it. Limitation of map chart is the size. I can not create bigger map than size of 440x220. Other than that, Google Chart API wins all other options. Wait... Other libraries don't even mention map support. Google API already won on it.

But~~ it is web-request. No problem. Python has great urllib2 library.
Here is my sample code.

import urllib2

# If you are behind proxy to go through,
my_proxy = urllib2.ProxyHandler( {"http" : "http://proxy_host:proxy_port"} )
opener = urllib2.build_opener(my_proxy)

api_url = ''
chart_property = dict(cht='p3', chd='t:30,20,50', chs='250x100', chl='Hello|World|Raymond')

def make_request( api_url, chart_property ):
  return api_url + "?" + '&'.join( [ "%s=%s" % (k,v) for k,v in chart_property.items() ] )

png = urllib2.urlopen(make_request(api_url, chart_property)).read()
fh = open('test.png','w')
print >> fh, png

Monday, April 14, 2008

Nice python interactive: ipython

ipython can be replaced with default command line python interpreter. One obvious add on from default python is readline capability. [TAB] will look up locals() and filenames at the same time. NICE! Noah Gift, the organizer of PyAtl introduced this in the presentation, and the very night, I tried and liked it.

Friday, April 11, 2008


Last month, I joined Python users group in Atlanta. Yesterday was my second attendance. Before the meet up, some members had dinner together in a restaurant. People are very nice, but more importantly, the presentations are great. Here is our group page

Thursday, April 10, 2008

Find glibc version.

This morning, one of my co-worker asked me how to find the version of glibc on the system. I never thought about this problem. Generally, if version number is not specified in the .so name, we just hope that it is defined in the program that can be accessed. Version number is totally man made, and nothing to do with the program by itself.
Eh~~ I will be short this time. gnu_get_libc_version() returns a char pointer. I guessed it from the symbol table of /usr/lib/libc.a. I actually began that this would be a variable (hoped not to be static variable.) It was a function.

Wednesday, April 9, 2008


I am alive... Just too busy for blogging. No active project is going on. Well, it's been a long time I activated my own project. Recently, I draw some basic shapes for my son like triangles, squares, circles, and put them on OpenGL using python-opengl. Some pyramids, boxes, spheres, etc. Thanks to my son, I refreshed some opengl stuff that I haven't touched since undergrad.
Then, he wanted a car on screen. Okay, I thought it was easy. Just find a free 3D model and import in my python script. Wrong! It depends how the model is represented. If it is written in 3D-Max, it needs some other script to convert for opengl to understand. What if my son wants something like 'Mickey Mouse'? He will recognize fake Mickey. He will want REAL Mickey which is really expensive.
I better learn some drawing skill :)