

Ask YC: Your Favorite Hack - DanielBMarkham

This is for all those people who have written more than one piece of software.<p>
What was your favorite and why?
======
cperciva
A conductor I know, when asked what his favourite piece of music is, always
answers with the name of a piece of music from the next concert he's
conducting -- and then goes on to point out that as soon as the concert is
over and he starts rehearsals for the next concert, he will have a new
favourite piece of music. As he points out, if what you're working on isn't
currently your favourite piece of music (or software), you're not giving it
the attention it deserves.

In that vein, my favourite piece of software is my (not finished yet, but
still very useful as it currently exists) "tarsnap" backup software
(<http://www.tarsnap.com>).

~~~
whacked_new
Good post. This is an interesting story by Tolstoy along the same lines:
[http://ebooks.adelaide.edu.au/t/tolstoy/leo/t65wm/chapter2.h...](http://ebooks.adelaide.edu.au/t/tolstoy/leo/t65wm/chapter2.html)

A great king would make his "favorite man" the man right next to him. A worker
would make his "favorite job" the one at hand. Now that is an extraordinary
feat.

------
rglullis
Hum, good one. I have a cool non-hack, actually.

In college, I worked for a while in the applied physics department. It was an
undergrad research project, where I was supposed to work with parallel systems
and cluster architectures. They use software that calculates "density
functional theory total-energy". Part of my project was to make this piece of
software run in multiple machines and speed up the simulations. That used to
take days to complete, sometimes weeks, and they wanted to reduce the period
of the cycle.

I never got to know the whole theory behind the software (I am a Computer
Engineer) but I did get to take a look at the manual explaining some of the
algorithms, while I was learning more about parallel systems using message
passing libraries.

I was just getting started on the whole "implement map, reduce, filter,
barrier" using MPI (in Fortran!) when I found a description of the software
where it showed how each atom in the strutcture, IIRC, needed to have its
plane-wave basis-set calculated. This calculation required a long list of
functions and was called for _every_ atom in the structure. Also, the software
consisted of long runs of this call, getting more approximate results at each
run.

Basically, I found an unbelievably parallelizable (is that a word?) piece of
code in a application that was mostly serial.

Let's just say this: it took me more time to find the place in the code that
have the call and even more time to make changes in the Makefile in order to
use Intel Fortran Compiler than the time it took me to add 5 lines of MPI code
and get the problem solved.

When we saw the speedup was directly proportional to the size of the cluster
(if we wanted double of the performance, just add the double of computers), I
realized that the feat (changing significantly the behavior of an program with
so little modification) would be hard to repeat.

It was no "major hack", but it made me value (a) proper documentation and (b)
getting a complete view of the system that I am supposed to work on and
modify.

------
aristus
A metasearch engine, written in Javascript, that executed entirely on the
browser. How? The page was hosted at d.o.w.s.e.r.bueno.org.
o.w.s.e.r.bueno.org pointed to Google, w.s.e.r.bueno.org pointed to Yahoo,
etc.

The XmlHttpRequests always appear to go to a root domain of the page, so it
worked.

That one still makes me grin.

~~~
DanielBMarkham
I like that a lot! Use the DNS system to outwit the stupid XMLHttpRequest
sandbox. Way cool.

~~~
aristus
Thanks, but while the restrictions on XHR are heavy, they aren't stupid. An
unnamed party used the same idea to implement a LAN sniffer: each successive
root domain pointed to the IP addresses of well-known routers, like
192.168.15.1. The script ran down the chain and attempted to log in to the
admin page of the router, using default passwords.

~~~
aston
The real point is that with enough smarts, you can get around the
restrictions, so you might as well eliminate them altogether so that there's
no false sense of security.

~~~
aristus
I feel that way sometimes when I can't do something cool. But it passes. No
restrictions on user processes is a major reason why "Windows security" is a
contradiction, for example. It doesn't work in an adversarial networked
environment.

------
pmd
Since 3 years I keep under my bed a hardprinted copy of the Solaris dynamic
linker source code, and another of the AIX kernel machine-dependent (esp. the
boot phase).

the Solaris RealTime Dynamic Linker code is available at:
[http://cvs.opensolaris.org/source/xref/onnv/onnv-
gate/usr/sr...](http://cvs.opensolaris.org/source/xref/onnv/onnv-
gate/usr/src/cmd/sgs/rtld/common/dlfcns.c)

and the AIX kernel is available on your favourite peer-to-peer network. This
is my bible. Look at the files under aix/bos/kernel/ml/, you will learn a lot
about kernel-land and Power(PC) architecture.

I enjoy it as a real piece of poetry, each function as an unique verse. You
can even appreciate some erotic pieces (especially if you try to compare your
reverse IDA analyse with the source).

If you are more openminded you can read the Linux kernel bootcode files (under
linux/arch/$ARCH/kernel/). The first time is still the harder one, and you'll
always remember it. But it worst it.

~~~
pc
s/erotic/exotic. Hopefully.

~~~
yters
At worst, no.

------
jgrahamc
Back in the mists of time I wrote code in BASIC and assembly for the Research
Machines 380Z/480Z computers. When they came out with their Z-NET network I
reverse engineered (with a friend) the packet send/receive APIs and we built
on top of it a reliable transport protocol that would enable us to guarantee
delivery of about 128 bytes of data to a machine on the network.

The entire code was stuffed into an unused block of data within the operating
system and when a packet was received the receiving code would get an
interrupt and would promptly CALL the code in the packet. We were able to
reliably deliver 128 bytes of machine code and have it execute on any machine.

This turned out to be very cool because it enabled us to build a complete
package for network management and monitoring (we could do stuff like mirror
the screen on any machine to another one).

John.

------
cstejerean
a couple of years ago I was working as a lab assistant in a university
computer lab. Part of my job was to check the printers hourly (in labs on 5
different floors) and see if they needed more paper. Being extremly lazy I
wrote a program that would log into the printers web based panel. This panel
displayed a paper level indicator as an image. I discovered tgat the image
filenames contained the percent full as a number (0, 25, 50, 75, 100). I had
my program regularly check all the printers, parse the paper level and alert
me if any printer was at 25 or empty.

------
german
A couple of years ago I took a course in Marine Ecology, for our final exam we
have to do a lot of calculations using the Shannon-Weiner index
(<http://en.wikipedia.org/wiki/Shannon_index>)

I wrote a program in my HP 48 calculator to solve it putting all the variables
in a list, it's my favorite hack because I was the only one in the class who
knew programming, so I finished the 2 hour exam in 30 minutes =)

------
mooneater
A tiny Win32 C program that would simply trigger print, then wait, then killed
the app - used to call a "mission critical" app that always hung after print
and thus couldnt be scripted, to automate the printing of hundreds of reports.

Fave b/c my manager insisted it could not be done, and it saved countless
hours of babysitting. Showing up at the office next morning to see the huge
pile of completed reports sitting there waiting was gratifying.

------
myoung8
My favorite hack was achieving the drop-down functionality seen in menus like
those on Digg and Facebook in about 5 lines of jQuery. It was particularly
satisfying because the jQuery plugin to emulate the effect is more than a
couple hundred lines long. It also works in all browsers :)

------
paulgb
A few years ago I wrote a blackjack game for iPods. Since the iPod can't
execute third party programs (without alternative firmware), However, they can
display interlinked text documents, so I wrote a program in c to generate a
document for each possible state of the game. Blackjack made this possible,
since there are only 5 or 6 states in any game.

I don't think I ever actually used it except for testing, it was more of a
"just because I can" project. To my amazement some people actually used it for
fun. I think it got into MAKE blog and a few other cool places.

------
jimm
I have to list three: DataVision (<http://datavision.sourceforge.net>) because
it's in use in fifty countries, a version of Objective-C I called Subjective-C
(1996) because it taught me about parsing and runtime stack manipulation, and
a Java applet-based image manipulation package that let you apply makeup (eye
shades and lip shades, with added gloss) to your own photo on the Web back in
1999, because it was ahead of its time.

------
gills
A heads-down flight display I built in the off-moments of a business trip.
Surprisingly enough the most satisfying code handled text display (remember
the text is constantly moving). Also, a python script to automate our build
and unit tests; whenever something broke or failed a test it would look up the
latest check-in and mail the error to the offending developer.

