Live data from Hacker News

Ask HN: What's your proudest hack?

news.ycombinator.com

11–20 of 414 posts

Re: Ask HN: What's your proudest hack?

#11
This is so completely random, and not really code related, but it was huge at the time (circa 1990). I was compiling large bibliographies of research documents for NSF that eventually had to be read into Word Perfect 5.1 for DOS for printing. We had written a very complex system of WP macros to search for tags that we programmatically put in the file, but they took forever to run and would often crash. My colleague and I found that we could only use search/replace to send begin/end pairs of tags for any formatting code (e.g. bold, italics). However, if we replaced the closing tags first, then the opening one, WP would notice that there were pairs of empty tags and get rid of the extra closing tag so that the underlying text would be formatted properly.

We were doing this everyday, so it cut the processing time from many hours to seconds. We swore each other to secrecy about this development and marched off to Dunkin’ Donuts with our giant ice coffee belt-loop holsters to celebrate.

Re: Ask HN: What's your proudest hack?

#12
Best hack:

Rewriting a C++ matrix library to change its API back in 1996/1997, for a 100x speedup.

It was a nice library... It had things like a = b + c; ... but back then, C++ really didn't have tools to support that syntax with great performance. Especially mixed with a bad allocator, that prevented multi-threaded allocation.

Re: Ask HN: What's your proudest hack?

#13
I'd have to think more about "proudest" but here is a recent one:

Reshaped RAID by

* LVM moving entire storage off to external iscsi SAN * wiping the controller config and recreating it from scratch in desired layout * migrating it back from SAN

(before the whiners, it had backups and it was a node in cluster so even if it died no availability loss).

Similar weird admin trick was

* removing all of the nonessential LVs in LVM * creating a big fat file in /dev/shm (essentially ramdisk) * migrating storage to that file * shredding content of hard drives * voila, shredding drives of system without restarting and with still having ability to clean shutdown it.

Re: Ask HN: What's your proudest hack?

#14
My favorite hacks mostly came from when I worked in a robotics+computer vision research lab, ~13 years ago.

If you've never worked with stereo vision systems, they have multiple cameras as input. The algorithms need to know the exact position of each camera. These calibrations are extremely sensitive - if the camera moves even a teensy bit, the algorithms start to fail because the image features aren't where they expect. Anytime we had a bad calibration, we needed to rerun calibration. This was a process where we waved a checkerboard in front of the cameras at tons of different angles, and software would process all the images and deduce the pose of each camera. It typically took at least an hour, and sometimes it'd fail and you'd need to redo it. Typically we'd need to recalibrate systems every few weeks, no matter how hard we tried to make the whole rig rigid.

Anyways, one day I accidentally drove the robot's sensor head into a table right before a demo with the people funding the project. The program started spitting out "BAD CALIBRATION" warnings. This would basically mean we'd need to cancel or postpone the demo to recalibrate, which would look really bad since they traveled all the way to our office only to be told "never mind!"

As a last-ditch effort. I grabbed the cameras and started wiggling them back and forth, and managed to force them into an orientation where the calibration worked. The demo went off perfectly. I later told the researchers about it and they hated it. "You should just always do calibration," etc.

My favorite hack that I've seen someone else do was at Google, where some specific project had a weird test that checked some ratio like "lines of tests to lines of code." Someone checked in a test with the comment "If you're not cheating you're not trying", and it just had the same assertion over and over for hundreds of lines to satisfy the metric. I never looked into why the person couldn't just disable the test, but I like the simplicity of the solution.

Re: Ask HN: What's your proudest hack?

#15
my hack for making the `htmx:confirm` event act like it is blocking:

https://github.com/bigskysoftware/htmx/blob/a3c414dcee94fd03...

basically, redesign the arguments for a function such that I can call it again at a given spot with one parameter changed and, to a first order approximation, it acts as if the function is resumable.

I've used this trick in a few places now, just recently in idiomorph to allow head elements to load before the rest of the content is morphed:

https://github.com/bigskysoftware/idiomorph/blob/e6dfc189fa3...

Re: Ask HN: What's your proudest hack?

#19
Not that hacky or mind-boggling, but does involve a hex editor and lots of money...

I added support for the '\ ' PostScript escaped space sequence to a custom, high-performance PDF parser.

A former employer used this to derive key figures from financial statements. Any change to the parser had to be Pareto-optimal: so if you modified the parser, it should not fail to parse any key figure that was previously possible to parse. Adding this improved reading word-wrapped text in hundreds of cases and key figures in dozens; I recall that my bosses thought it must be a mistake, and that I had to convince them by finding the right section in some Adobe PDF spec.

I wasn't an expert at the PDF format. But stumbling on a number split in two by apparently nothing, and digging up a 0x5C 0x20 '\ ' with a hex editor, I seemed to recall that PDF was built on top of PostScript, and that TeX / LaTeX syntax was somehow related to PostScript. So it struck me that what was a literal backslash in the PDF must just be an escape sequence.

Re: Ask HN: What's your proudest hack?

#20
post #17

2 daily scheduled 20 minute naps (8AM, 3PM) with noise cancelling headphones and a face mask neutralizes the side effects of sleep fragmentation with a new child.

isn't 8AM still part of the night sleep? do you wake up super early? I would expecting something like 11AM, 3PM :D
Post reply on HN