HACKER Q&A
📣 willvarfar

What's the best quick'n'dirty code you've ever made or seen?


Last week there was the super-popular Ask HN: What is the best code base you ever worked on? https://news.ycombinator.com/item?id=40818809

That question specifically mentioned top-down enforcement of best practices, and the comments chimed in on that.

So what have you seen that was great but at the other end of the spectrum? What was the best shortcut or simplification or cowboy coding you've ever made or seen?


  👤 efortis Accepted Answer ✓
A Software Multiplexer (Bitwise Table Lookup)

  /* Bits: selected, hovered */
  const colors = [
    grey,  // 00
    green, // 01
    blueA, // 10
    blueB  // 11
  ]
  const color = colors[selected << 1 | hovered]

https://blog.uirig.com/bitwise-table-lookup