Damn, This Boy Can Code
· From the 2010–2013 blog
According to Fisheye I wrote and made awesome 1,764 lines of python over the weekend. I fuckin' rock. This was probably both the easiest and hardest code I've written in a while. Easy because there were really no rules, I just had to get some shit into a file with a .py extension and check it in so the boys could tell me what I fucked up on. Hard because I really don't want to set us up for problems as time goes on - this code (though hopefully it gets tweaked and tweaked) will be very much fundamental going forward. I do have to say though that key value stores like Redis are pretty kick-ass. After this weekends adventure I firmly think almost everyone that uses something like MySql should really be using something like Redis (especially when they cant define their schemas anyways). Its fast, its simple, and it makes a ton of sense - just look at the key: OBJ:$ID$:ATTRIBUTE = VALUE. how fucking sensible is that! I have a bunch of objects, they have ids, and attributes with values. object + id + attribute is your key, and then you just load a value or retrieve its value simple as that. the api is even easy, no SQL, none of that shit - remember its simple. object.attribute = redis.get("%s:%s:%s" % (object.class, object.id, attribute)) BAM! The other thing that I have to bring up, and I'm sorry to my partners for this, is that I have been writing a bit of ruby lately. and more or less I have been writing ruby inside of files with .py extensions - sorry. enjoy the code review I guess.