TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Share some of your easy code 'wins'?

9 pointsby eurvinabout 5 years ago
Hi HN,<p>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

pjungwirabout 5 years ago
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&#x27;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&#x27;t many jobs reading Shakespeare or Dostoevsky. :-)<p>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 &quot;drive&quot; 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.<p>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<p><pre><code> s&#x2F;\[(\w+)\]&#x2F; $replacements{$1} &#x2F;g </code></pre> Elsewhere the developer was fond of the &#x2F;x option, so I assume he just omitted it here.<p>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.<p>A day or two later my manager said the developer approved, and he asked me what salary I&#x27;d accept to work there full-time as a programmer. :-)
评论 #22378503 未加载
sigmaprimusabout 5 years ago
I don&#x27;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.<p>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.
评论 #22370557 未加载
gshdgabout 5 years ago
I was asked to write a fuzzy word matching algorithm that would allow for a certain number of typos&#x2F;misspellings. Turns out there’s a well-known algorithm for that[0].<p>[0] <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Levenshtein_distance" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Levenshtein_distance</a>
评论 #22386205 未加载
dyejeabout 5 years ago
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.
matijashabout 5 years ago
Sadly I have much more opposite stories - something seemed simple at the beginning but then it turned out to be a black hole :).
评论 #22378758 未加载