Archive for the 'Work' Category

pgadmin3 - now it’s getting personal

Monday, February 18th, 2008

I really don’t mind if Debian lags behind with package versions. And I’ve gotten used to running an ancient version of “pgadmin3″ (the GUI client for PostgreSQL). But now that I upgraded a few pgsql servers from 8.2 to 8.3 and started pgadmin3 I was surprised - in a not at all fun way. Several warnings were displayed. Googling a little I found the cause:

“pgAdmin 1.6.x doesn’t support PostgreSQL 8.3.x. Upgrade to 1.8″

How funny. pgadmin3 in Debian depends on wxwidgets and apparently the current version of wxwidgets didn’t make it into Sid for stability reasons or whatever. So now I’m running into trouble with PostgreSQL 8.3. Somehow I can’t laugh about that. Alright… downgrading to 8.2 again. Is that even possible? Okay, pg_dropcluster and get my backup tapes out.

Fun and despair with ExtJS

Tuesday, January 15th, 2008

Since I started playing with Javascript about a year ago I became aware of a pretty large number of Javascript libraries that offer additional functions or even widgets for a nicer user interface. I had started with prototype/script.aculo.us because it was included by Pylons. But when I found out that I’m not really bound to it I started looking around in my usual pointless search for “the perfect tool” ™. Finally I stranded with jQuery and I fell in love with it quickly. Give me results quickly and I’m willing to dig into the more subtle parts of something.

Sure, other people told me that jQuery is lame and Dojo is it or YUI (the Yahoo UI library) or even ExtJS. ExtJS? Yes, I looked at that before. Very impressive demos like the “Web Desktop”. I didn’t want to write anything like that though so I enjoyed it as a proof-of-concept and was done with it. But somehow one of my current projects requires a “grid” - that is a table that acts as a paginator (you get shown chunks of data and can navigate back and forth) but allows you to select rows and run actions. Perhaps I would also need a tree view. ExtJS supported all that so I dumped jQuery for a moment and created a (Mercurial) branch of my project to try out ExtJS.

There were instantly a few things I didn’t like. The whole Javascript was 500 KB large. Hardly something I could use on a production web site. Imagine a >500 KB start page. I also had to throw away my CSS for a moment and use their stylesheet - with 850 not-documented classes. Anyway - I surrendered to that and started playing with ExtJS. Strangely loading the page took 10 seconds in Firefox. After some research I found out that there was a bug in FireBug (a Firefox extension that web developers can hardly live without) with large Javascript files. Yes, 500 KB is large. Finally I found a hacked version of it that disabled a few features just to work better with ExtJS.

So finally my application loaded the Ext-all.js (the documented order and list of files I had to include was wrong) and could copy/paste a grid example into my application. One day later it worked. I had defined Stores, Proxies, ColumnModels, Actions, GridPanels and PagingToolbars and after 150 lines of Javascript I finally loaded JSON data from my web service (running on Pylons) and had the grid fill with it. I better hadn’t looked into the generated HTML - made me dizzy looking at all the nested DIVs and TABLEs. My Pylons code was just 5-10 lines though. It was an adventure of surfing through the API documentation of ExtJS that is complete but unusable to me. It defines all possible parameters and options but those are inherited from one another, some aren’t documented because they are “common” and you hardly get an impression on what they mean or how to use them. There were nice examples and everything they did was well documented. But that didn’t help me do more than that. Even doing server-side sorting of the JSON data meant firing up FireBug and watching the parameters - I had expected that to be documented somewhere.
Finally I decided not to work with ExtJS any more. If my application consists of 90-95% Javascript and 5-10% Python/Pylons then I’m not spending my time as intended. Using ExtJS basically means surrendering to it. Just use their library and style sheet and change as little as possible. 500 KB Javascript and 850 CSS styles are pure bloat. And while their license is basically the LGPL they have some weird additional clauses in their license like you can’t use their theme graphics and styles outside of the ExtJS context. I understand that a library of such a quality can’t be maintained by a handful of volunteers. So I see that they want to make money with it if others start making money with it. But somehow it was too much legal stuff for me. I prefer software that is just free. MIT or BSD. Or even GPL - I don’t mind. (Everytime you complain about the complicated licensing you are pointed to their license consultants to convince you. :) ).

It’s a great library. It has great widgets. It even creates HTML that is strictly valid in all browsers I could find. But I was not ready to surrender my application to ExtJS. I wanted a grid to support my application. Fortunately I didn’t have to reinvent the wheel because Matt Knight has recently published his Ingrid grid plugin for jQuery serving me well. And another (ridiculous) point for jQuery: it has mailing lists. ExtJS has a web forum. I hate web forums. Some people say mailing lists are archaic. But I can delete threads or blacklist people or reply properly in a text format. Morale: the flashiest isn’t always the best - neither for the user nor for the developer.

Handy Firefox/Icewasel keyword searches for (packages|bugs|*).debian.org

Saturday, December 22nd, 2007

Just wanted to drop a tip on you about the Firefox keyword search feature. I use it to quickly access packages.debian.org on package information or to retrieve the BTS page for a bug number. With it you can use “bts 123456″ instead of “http://bugs.debian.org/123456″. May not appear much shorter but I like it anyway. Here an example on how to add a search keyword for packages.debian.org:

  1. Locate a search form (like on packages.debian.org), set all the select options like you want (e.g. only package in “unstable” and from “main”) and then right-click on the actual text field where you enter the search query and select “add a keyword for this search”:
    Iceweasel context menu to add a keyword search bookmark
  2. Give the bookmark a name (does not matter) and the keyword (should be short):
    name the bookmark
  3. Now you can use that keyword in the location bar (where you normally type the URL you want to surf to) and add the word that you search for:
    Using the bookmark in the location field
  4. You will be redirected to http://packages.debian.org/search?searchon=contents&keywords=cream&mode=path&suite=stable&arch=any

So basically getting the package page for this “cream” package means pressing Ctrl-L to highlight the location bar and just enter “pdo cream” and pressing Enter.

For me that was the second most valuable tip when using Firefox. The best tip would probably be how to make that monster take less than 10 seconds to react to mouse clicks on the menus when you have 20 tabs open simultaneously and to consume less than ridiculous 500 MB RAM or freeze up every minute when you use flashy sites like youtube. I really wish 3.x will finally fix that.

P.S. I wonder why wordpress shrinks all my images. I hope you can still guess what I meant.

If only I had studied partially… err… partials

Monday, February 19th, 2007

I have to admit it. Like millions of people everywhere I wasted my best years sitting in dusty lectures learning about 20 year old technology. (The technological elite of this country seriously learned from books where they talked about green CRTs and that color tubes are about to be invented… and that was in the 1990s.) The evilest lecture was called “theoretical basics of programming”. You learned about concepts that you would forget the instant that the semester ended. It was just a pretence to throw out half of the students. At least I had expected to learn something about programming. What did I learn? LISP, Assembler and Modula-2. Those languages are arguably not very useful. Okay, I understood the difference of functional and imperative programming languages. But later in my studies I found myself with no knowledge about object-oriented programming or at least C.

Last week most of my “master of computer science” arrogance suddenly dropped to zero when people in #pylons told me about “currying” and “partials”. I assumed to be an educated programmer but a dozen people flooded my IRC window with supportive comments like “that’s one of the most common paradigms besides recursion - didn’t you know that?“. Neither the Wikipedia page nor Pythons PEP309 really made sense at first. But now I understood the principle and it has already come handy…

A partial is just a function with preset parameters. Imagine that you have a function that takes a certain number of arguments. And you need to call that function time and again in your program. You may discover that one of the parameters always needs to be set to a certain default. How do you do that? Well, usually you pass that parameter along with every function call. With a partial you create a new function from the old function with certain parameters set. Say you have:

  • myfunc(foo=42, a=3, b=51, c=58)
  • myfunc(foo=42, z=12)
  • myfunc(foo=42, j=’hello world’)

You can create a new function with that foo=42 parameter already set:

  • myfunc2 = partial(myfunc, foo=42)

Now you can use that newly function and don’t have to care about foo=42 any longer:

  • myfunc2(a=3, b=51, c=58)
  • myfunc2(z=12)
  • myfunc2(j=’hello world’)

This may look ridiculous. But I already found my first use case for that. I needed to set certain arguments and then passed that newly created function around. Another part of the program would then just execute my function with the parameters I gave it
while adding further parameters.

The word partial is not very descriptive. But the word currying makes a lot more sense. You start with an empty pot on your oven and add ingredients (parameters). No idea if that’s the right metaphor but at least that tastes like I can remember that. :)

Getting back to the topic: my mentors at university tried to persuade me that studying is a good idea because you learn a lot about concepts that come handy for your job later. While I tend to believe that partially… why do I work with studied mathematicians and physicians in a network administration department? And most Ph.D.s I know at my employer create slideshows and emit buzzwords. Wasted time I tell you.