We have a DB2 backend and I started to test it with PyDB2. Here is a tutorial link. In short, nothing is surprising. It uses standard python DBAPI interface with some good utility in DB2.db2util package.
Initially, I thought this client package would give different usage because DB2 client is different than postgres, mysql, or Oracle. However, PyDB2 is written well by supporting standard API.
Thursday, May 8, 2008
Monday, May 5, 2008
Shell, Brace expansion
I found that I research this whenever I think of this function.
If I have to select file a,b,c only in /tmp, brace expansion is the answer. /tmp may have bunch of other files. Also repeating /tmp/a, /tmp/b, /tmp/c is annoying.
$ ls /tmp/{a,b,c}
Brace expansion is not used often, but when it is needed, it is super useful. I have to leave this note hoping that I have a place to lookup at least.
If I have to select file a,b,c only in /tmp, brace expansion is the answer. /tmp may have bunch of other files. Also repeating /tmp/a, /tmp/b, /tmp/c is annoying.
$ ls /tmp/{a,b,c}
Brace expansion is not used often, but when it is needed, it is super useful. I have to leave this note hoping that I have a place to lookup at least.
Sunday, April 27, 2008
KDE 4
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.
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.
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 advsofteng.com. 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.
#!/usr/bin/python
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 = 'http://chart.apis.google.com/chart'
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
fh.close()
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 advsofteng.com. 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.
#!/usr/bin/python
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 = 'http://chart.apis.google.com/chart'
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
fh.close()
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
PyAtl
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
Subscribe to:
Posts (Atom)
