Tuesday, April 21, 2009

GPL logo

is not very good. Its kind of crowded and ungainly.


Don't you think they should have come up with something more visually appealing? To me, even plain type looks better! Like this

GPLv3

The growing up of the GPL

I first ran into the GPL in some book. It could have been a coding book or a latex book. I didn't care about licenses at that age, but I remembered it because it contained the following extract:
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright
interest in the program `Gnomovision'
(which makes passes at compilers) written
by James Hacker.

signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
Now, these guys must be fun to hang out with! That's what I thought. Recently, I looked up GPL3. Stallman's blurb on why we should switch was all peachy and militant. But what really disappointed me was the end of the license:
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
    Copyright (C)   
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
So boring! These guys are grownup now. They're not any fun anymore...

Monday, April 20, 2009

Constantize.

Ahh Ruby... Suppose you have a string class that corresponds to a class name and you want to call a certain method on it, what do you do? Well you could do

eval class + '.method'


but that will be slow (as evals are slow) and apparently that looks ugly.

But the creator of Ruby must have run into that issue often. Because what you can do, is

class.constantize.method


This is an inflector that tries to find a declared constant with the name in the string. And in Ruby classes are constants...

Ruby regular expression evaluater

Rubular

Saturday, April 11, 2009

Thursday, April 9, 2009

Running a module as a script

Contents of module.py


def haha():
print 'haha'

def mama():
print 'mama'

if __name__ == "__main__":
haha()


Now invoke module.py as a script

python module.py

output:

haha

Saturday, April 4, 2009

Federal free file works

I think the IRS did a good job on the free file interface. The interface works on Firefox3.0 on a mac. I'm assuming it works on windows. There are a few minor glitches with cursor positioning on some text fields (when you need to go back and delete/edit stuff in a field) but its an allround good job. If all government stuff was like this it wouldn't hurt so much to pay the taxes.

Don't use 'type' as a field in a Rails database

I'm working on a new rails application. In one of the tables I have a field called 'type'. Everything was going fine, but whenever I set the 'type' field and saved the record it ignored the contents and set it to NULL. I couldn't figure it out.

Tangentially, I had set a bunch of fields to be 'string' and these are translated to be varchar(255) in the sqlite database and I wanted to test what happened if I went over the 255 character limit. So I typed in a string 260 characters long into the 'type' field using an external database app and saved the record. It saved just fine, and kept all the characters. Now I thought, let me load this in my rails app and see if it still sets it to NULL. I loaded it and got back this error message:


ActiveRecord::SubclassNotFound in ItemsController#show

The single-table inheritance mechanism failed to locate the subclass: 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Item.inheritance_column to use another column for that information.


Now they tell us !

Convention : good.
Informative error messages : good.
Not telling us what the convention is : bad

Bad Rails people, bad rails people.

To peek into the database I'm using the Sqlite manager plugin for firefox by Mrinal Kant. Its awesome.

Thursday, April 2, 2009

Free e-file for federal

Excellent! I always wondered why the IRS didn't allow you to e-file for free (unless you were below a certain income limit). I mean its free to paper file. It must cost the IRS a lot to go through badly handwritten paper forms. But this year I see that you can e-file for free whatever your income. Good.

Wednesday, April 1, 2009

Can't call one python script from another

Bookmarks in Eclipse!

I was jumping round my analysis code and getting tired of hunting to find the apropriate line I was working on. I thought wouldn't it be nice if there was a bookmark system. So I right clicked on the gutter in eclipse. And. Whaddya know? THERE'S A BOOKMARK SYSTEM. I love this IDE.