Live data from Hacker News

Ask HN: What's your proudest hack?

news.ycombinator.com

21–30 of 414 posts

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

#21
In my master's thesis, I was generating component graphs from source code. One issue I had was the generated graphs were suuuuper ugly due to the connections between components overlapping in a non-optimal way. Turns out, untangling graphs is a NP-HARD problem. I got around it by using a spring-repulsion simulation, where connections between components pulled them together but components repelled other components when they got close. It wasn't a perfect solution, but it got me 90% of the way!

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

#23
I often create screen recordings for my classes, but it's very boring and time consuming. I'm a perfectionist, and if I mistype a command I prefer to re-record everything. Moreover, every time one of the tools used in the videos gets a significant update, I feel compelled to redo the video.

I have started using xdotool [1] to create bash scripts that send mouse clicks and keystrokes to apps. Interleaving calls to xdotool with the "sleep" command [2] produce a convincing effect. If I need to redo a video to fix typos or after a program update, I just fix the bash script and restart the recording.

Alas, the only thing that is missing in my videos is the sound of keyboard clicks… But nothing is perfect!

[1] https://github.com/jordansissel/xdotool

[2] https://en.wikipedia.org/wiki/Sleep_(command)

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

#24
Debugging mysterious recurring hangs in a storage appliance. The nodes were connected via Infiniband, so there were two parts to the hack. The first was to write a program which would find all of the kernel memory areas and register them with the Infiniband controller. The second was to slurp up all of the memory on a hung node via Infiniband from one of its peers, and convert that into dump format so we could use gdb on it. After collecting a couple of dozen such dumps and poring over them for a couple of days, I was finally able to debug one of our most intractable problems.

That led to a second, though lesser, hack. The problem turned out to be code that was allocating way too much memory. (Userland programmers working in the kernel, ugh.) This would sometimes cause the stack pointer for one task to jump all the way over its task structure into the stack of the previous task, which would make that stack very confusing. That's why it took two days to figure out, even with dumps in hand. (Also, putting the stack right next to the task structure was a stupid decision on Linux's part.) To find the dozens of places where this was happening, I wrote a tool to disassemble all of our kernel code and look for the part of the function prolog that allocated stack space, thus creating a list of those that were allocating too much. Then I spent a week fixing them.

It was a grueling process, under lots of pressure at a struggling startup, but ultimately the result was very rewarding.

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

#25

I've worked on a single-machine computer vision system which used RabbitMQ to send messages around, including JPEG frames which were rather heavy, in contrast to other messages. After we hit a certain number of frames/second, RabbitMQ became a bottleneck. My solution was to write the JPEG frame in the shared memory, then pass around shared memory ID, offset and frame length, instead of the whole frame. Only services…

What's really awesome about this is I think you independently discovered a huge trick in performance optimization. "Zero copy" solutions for eliminating the overhead of moving frames around are very popular - if you look up that term you'll see it pop up everywhere. Companies/teams of engineers spend months coming up with this solution and its a reliable way to reduce overhead of moving data around. It works across all layers and in fact entire hardware architectures are designed to allow for this kind of stuff. Kudos :)

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

#26
About 15 years ago I was trying to debug a pesky timing issue and couldn't reproduce it.

I wrote a script to capture and replay network traces from Wireshark (then called Ethereal) that included keeping the timings intact. Caught the bug reliably every time.

I still think that's the best thing I every did.

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

#27
Was reminded the other day about the time I arrived early at the night shift to learn a particular manual "scheduling" technique (how to match single size and double size packages to hundreds of deliverables, and I think there was some options too).

I saw the excel file, asked for 5 minutes, came back after 15 and had solved the problem to such a degree that it went from wasting two hours for two teamleaders on every night we did this job to being almost trivial for one to do in 5 minutes.

And the solution was trivial. Like really trivial. But no one had thought of it before : )

Second best probably when I saved a messed up server in US (an person on site hadn't noticed the . in rm -rf ./bin and had proceeded to use sudo without thinking, as every Linux user does when they go through that dangerous phase).

I realized I still had one ssh connection to the server, realized either scp or rsync or something was in sbin (or somewhere else) and we could use it to copy the necessary binaries to get it back on track.

This easily saved us a 3 days (RHEL with Oracle 11g something easily took days to get right and it also was a massive pain to do).

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

#28
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

Kids love to wake up really really early. Like 5 or 6am. By 8am, the OP here probably had their kid in daycare or something already.
Post reply on HN