Ian Lewis Ian Lewis is a web developer living in Tokyo Japan. His current interests are in Django, python, alternative databases and rapid web application development.
About Me...

Dynamically Adding a Method to Classes or Class Instances in Python

In Python you sometimes want to dynamically add methods to classes or class instances (objects). In Python code, the most obvious way to accomplish this might be something like the following but it has one caveat, class MyObj(object): def __init__(self, val): self.val = val def new_method(self, value): return self.val + value obj = MyObj[...]

How to be a 10x programmer

I recently read a blog post that is a satirical look at how to gain a reputation as a guru programmer by converting code to your own code and making it hard for other programmers to get their work done. It's called 3 Simple Rules That Will Make You a ‘Superstar’ Developer and it's very tongue in cheek. It outlines 3 simple rules to be a superstar programmer. Rule 1: Write lots of code. i.e.[...]

Unreadable

What is it about some C programmers that makes them write code that looks like this: if(len<16) { for(k=start;k<start+len;k+=j) { j=1;x=V[I[k]+h]; for(i=1;k+i<start+len;i++) { if(V[I[k+i]+h]<x) { x=V[I[k+i]+h]; j=0; }; if(V[I[k+i]+h]==x) { tmp=I[k+j];I[k+j]=I[k+i];I[k+i]=tmp; j++; }; }; for(i=0;i<j;i++) V[[...]

Introduction to Algorithms

Today my copy of Introduction to Algorithms came in the mail (a gift from the family). I've decided, mostly inspired by Peteris Krumins to revisit classic algorithms as it's been a while since I've taken a look at them. I have decided to also take a look at the MIT Intro to Algorithms course in order to revisit algorithms and concepts. I won't provide any lecture notes or anything since Pete[...]

Google Analytics for Mobile Sites

I implemented tracking using Google Analytics for my company's mobile sites using a technique described by Peter van der Graff on his site. The technique involves performing a GET to to an image on Google's server and passing it a bunch of options. Incidentally this is because JavaScript can perform gets of images but not gets for any other kinds of content (as an aside, this kind of protecti[...]

Gnucash 2.2.3

Gnucash 2.2.3 was released the other day and contains my first contribution to the project. Albiet, a pretty small and lame patch for a small bugfix, but a patch nonetheless!! I hope to do some more work particularly on the QIF import, eventually making it work with the generic importer, and then expand my contributions to include improvements for multi-currency and reporting.

MochiKit does makes java suck less

So the last few days I've been playing around with MochiKit and working with Javascript. Until now I have done some Javascript here and there but not too much. MochiKit seems to make it a lot easier by providing you with lots of useful functions for things you do often. In fact it's so popular that I have a hard time explaining to myself why I hadn't tried to use it up until now. I'm certainl[...]

Internet Explorer is CRAP!! [CSS Edition]

In the same vein as my first post bashing Internet Explorer I wanted to point out a few CSS bugs/unsupported features that are notable in Internet Explorer. For those who are not familiar, CSS is a stylesheet language which helps you to layout your forms. It's used on basically every major website on the internet. But Internet Explorer, even though it is the most widely used browser, does not[...]

MDB2 transaction bug

There is currently a bug in the current stable release of MDB2 (2.4.1) that breaks transaction support with MySQL databases. It seems to occur anytime the server cababilities are checked twice (This basically means that it occurs when creating multiple connections to the database). After running into this bug I took a dive into the code for MDB2 and found that was caused by the use of a stat[...]

Internet Explorer is CRAP!!

Basically the title says it all. Since I started doing web development I've lost count of the number of bugs that I've found in Internet Explorer but I want to highlight a couple that were especially annoying to me. 1.) The <button> tag doesn't work. The button tag has a value attribute which is supposed to be sent as the value of the post when I submit a form but it's not. The display value[...]