Wednesday, March 18, 2009

One-liners

Python doesn't seem to be the language you'd immediately turn to if you wanted a one-liner to gazump your programmer buddies (well, at least it isn't for me), but can it be done? You betcha:

Lambda hell.


No way am I going to type this out! Especially as someone has already done this for us. :D

Edit: Forgot to mention who alerted me this monstrosity.

Wednesday, March 4, 2009

NDSTrim

Finally, a new post! Yay me, for drudging up enough silly stuff to write a post about!

Seriously though, it has been a pretty hectic week (tests, exams, assignments, the usual) so it's a wonder that I have any time left over for blogging. Anyhoos, I thought I would post up something that didn't take too much time to make, and is at least a somewhat fun exercise in Python coding for myself.

So, without further ado, let me present ndstrim.py! For those of you who like to back up their precious NDS games regularly, like I do, space is a consideration, especially if your collection runs into hundreds of games, like mine (I really do have a lot of games, don't ask). What this Python script does is trim your NDS backups (or ROMs) by a factor of up to 50%, depending on the actual size of the game itself.

How can it save that much, you wonder? Well, considering some ROMs might be 70-80 MB, they'll decide to use 128MB ROM cartridges, with the remaining space doing precisely...nothing. The space can add up real quick!

Anyway, the original C++ code was posted on a forum somewhere (I won't tell because I've forgotten where), and I simply took the liberty of translating it to the Bestest Programming Language in The World TM, because I can. If anyone reading this knows the original source of the code, please do tell me and so I can properly thank the guy. :)

I might write up a GUI (with wxPython) if I feel up to it, so Windows aficionados can enjoy the fruits of my work too! If you're impatient for some GUI goodness, go here and get your fix.