Hacker News new | ask | show | jobs
by DIVx0 3895 days ago
I have a scratch folder full of stuff like this written in whatever scripting language is closest at hand, ruby, perl, python, etc. I'd wager most people here would have something similar.

I wonder if it would be an interesting project to comb though it all and see if any useful tools could be extracted. Probably not, like the code in this blog most of my one-offs are unashamedly terrible.

4 comments

I wholeheartedly recommend anyone to comb through their samples and post them on github - https://github.com/voltagex/junkcode is mine. Occasionally I'll graduate projects to their own repo.

This was inspired by http://samba.org/ftp/tridge/talks/junkcode.pdf - you may recognise the author!

I didn't really think it was that terrible or hard to understand. I have minimal experience with Ruby and it made sense to me. Doing this sort of thing was why I learned how to program in the first place.
Couldn't agree more. If you write something for one time use and it works how could it really be bad?
I have this dumb C program that scans a folder of .mp3 files and fixes their id3tags from shift-jis encoding to utf-8. Shift-jis isn't officially supported for mp3s, but Japanese Windows uses it as the default encoding for non-UCS2 strings, so when you display a tag that's "latin-1 encoded" on a Japanese locale, it shows up fine, but shows up as gibberish on everything else - https://github.com/moshev/tagfixr
> most of my one-offs are unashamedly terrible.

I never intended this to see the light of day, but since the topic warrants it, here is a python one-liner I'm using to put the indices of combinations of subsets into one list:

combos = map(list,reduce(lambda x,y: x+y,[[c for c in itertools.combinations(range(8),i)] for i in range(1,9)]))

yuck. These things usually end up as a result of testing and tweaking in an interactive shell.