Hacker News new | ask | show | jobs
Ask HN: Share some of your easy code 'wins'?
9 points by eurvin 2313 days ago
Hi HN,

I am reading so many horror stories about spagetthi code and errors that take down whole commercial websites, I thought it was a good idea to share some of you positive easy coding win stories? When were you assigned a (on the surface) hard task to just google, copy paste and be done with it? I am very curious. :)

5 comments

Back in 2000 I was a new college grad doing manual data entry as a temp in Boston for 1200-page industrial supply catalogs, wishing I had majored in CS instead of English. (I've programmed since 8 and by then I already knew BASIC, Pascal, C, C++, Java, Perl, Scheme, and Javascript, but I thought the humanities were more interesting. Alas there aren't many jobs reading Shakespeare or Dostoevsky. :-)

The idea was that this army of temps would enter data into a home-grown Java app, then someone would push a button to spit it all out as XML files, and then there was a Perl program that would read the XML files and "drive" QuarkXPress to automatically create pages with optimal product position to minimize whitespace at the bottom of columns. But there was a bug and every special character got printed with extra spaces around it. For example ™ ® © ° ± ² – — ‘ ’ “ ”. There were hundreds per page. (Think row after row of 1¼” ID 1¾” OD Fastenal™ Supertight® hex nut.) So just when they thought the project was over, they asked us all to stay and use red pens to mark up proofs so that another army of graphic designers could fix the problems in Quark by hand.

I looked at the Perl code, and it was using a regex to replace our own special codes (something like [tm] etc IIRC) with the unicode chars, but the regex had extra spaces, something like

    s/\[(\w+)\]/ $replacements{$1} /g
Elsewhere the developer was fond of the /x option, so I assume he just omitted it here.

I tried editing the code and saw that it fixed the problem, so I told my manager. He asked me to write a letter to the developer (who was in another office across town), so that night I wrote a 3-page explanation and brought it in. To remove two blank spaces.

A day or two later my manager said the developer approved, and he asked me what salary I'd accept to work there full-time as a programmer. :-)

Simply awesome!
I don't know if this is what you mean but many years ago I answered a CL computer gig add from someone that wanted their static Website ported from their current host to a free host as their contract had expired.

With just a few wget commands and a dns redirect, $100 was sent to my Paypal account, the guy was so happy he refered me to a bunch of others needing the same thing done.

haha, nice one! This exactly the kind of story i was thinking about.
Actually over the years Craigslist has been a great resource for making a few extra bucks. There is always the usual adds asking for expert programmers to make the next facebook or twitter and I have never replied to them, but atleast once a week there is a person looking for help that is willing to pay a fair price for pretty easy work.

I just checked the Craigslist adds in my old city (I moved up to Northern Canada and am building a farm) and I found a perfect example of someone looking for help with a pretty easy job. (Im not replying to it as I'm focused on other projects)

https://vancouver.craigslist.org/van/cpg/d/vancouver-drm-pro...

Nice find! The add is still there so you are right. If you look in the right place, you can find easy work.
I was asked to write a fuzzy word matching algorithm that would allow for a certain number of typos/misspellings. Turns out there’s a well-known algorithm for that[0].

[0] https://en.m.wikipedia.org/wiki/Levenshtein_distance

Levenshtein distance is a measure, not a fuzzy word matching algorithm.

Did you brute force your searches to match anything within a levenshtein distance of X?

We had a really simple document storage component to a webapp I was working on. Customers wanted to be able to search them so we had a ticket chilling in the backlog with the maximum point value to implement Solr. I ended up implementing it in an hour by taking the raw text out of the PDF with some library, shoving it into a Postgres column, and doing a LIKE query.
Sadly I have much more opposite stories - something seemed simple at the beginning but then it turned out to be a black hole :).
That's what i'm experiencing on a daily basis