Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. The Normalization of Inexplicable Failures (ihatethefuture.com)
    32comments
  2. In an $80 Motel Room, a Discovery to Shed Light on the Origins of Life (nytimes.com)
    32comments
  3. Ten Lines of Code That Changed My World (pixelambacht.nl)
    15comments
  4. Writing Efficient C++ Code (asawicki.info)
    26comments
  5. Replacing the old battery on rechargeable bike lights (jvns.ca)
    35comments
  6. Show HN: TinyAIArena watch AI agents battle it out (tinyaiarena.com)
    18comments
  7. There are no "rogue" AI agents (eoinhiggins.substack.com)
    47comments
  8. Walgit: A Git server that is one binary in front of an object store (github.com/rgodha24)
    4comments
  9. Flip Fluid on Flip Dots (mitxela.com)
    19comments
  10. Fakecloud: Local AWS cloud emulator for integration tests (fakecloud.dev)
    32comments
  11. The Cartesian Hand: In-Hand Manipulation with All-Linear Fingers (generalroboticslab.com)
    —discuss
  12. postmarketOS Rebrand: Nura (nura.eco)
    8comments
  13. Does Georgism work? Five years later (astralcodexten.com)
    388comments
  14. Go Concurrency Distilled (antonz.org)
    136comments
  15. Show HN: A CC0 museum of retro 3D tricks you can paste into a page (3d-retro.com)
    10comments
  16. Finally, A True Blue Rose Exists (sciencenews.org)
    29comments
  17. PipePipe: NewPipe hard fork implementing SponsorBlock (github.com/infinityloop1308)
    257comments
  18. Installing NeoVim caused original Vim undo files to be deleted (aresluna.org)
    231comments
  19. Rusty thoughts on "Parse, don't validate" (thegreenplace.net)
    17comments
  20. Unsealed Briefs in Authors’ Case v. Microsoft/OpenAI (authorsguild.org)
    522comments
  21. The internet discovers TLA+. Now what? (reasonable.io)
    47comments
  22. Show HN: Reladraw – A diagram language where you decide where to place things (github.com/reladraw)
    101comments
  23. DeepSeek Elastic Compute (DSec) (arxiv.org)
    97comments
  24. OpenAI halts training of latest models as reports mount of AI agents going rogue (theguardian.com)
    45comments
  25. Biology might not be quantum, but its math is quantumlike (quantamagazine.org)
    47comments
  26. "As a Language Model": Chat Template Switches LLM Self-Referential Voice (arxiv.org)
    94comments
  27. A searchable library of forgotten public-domain film clips from 1915 onward (movingimagearchive.com)
    27comments
  28. 10 Tells of a Slop UI (hereticpleb.vercel.app)
    169comments
  29. An agent used DNS to reach an external chatbot (alignment.openai.com)
    151comments
  30. Exploding variance of means of exponentials: least-squares to the rescue (francisbach.com)
    —discuss

Ten Lines of Code That Changed My World

62 pointsby 4h agopixelambacht.nl
15 comments
1h agoHN ↗

I have been collecting small code snippets that would make for good tattoos and I have to say, some of these ones would probably make a good addition to the collection.

I'm partially more in favor of "red" instead of "hotpink" for CSS, but that's just me.

1h agoHN ↗

You have this one right?

(){ :|:& };:

1h agoHN ↗

Don’t forget the function name at the very beginning!

:(){ :|:& };:

46m agoHN ↗

mine would be something like

    p { color: red; }

as a teenager my mind was blown as I reloaded the page and there it was; text now in red. I did that!

1h agoHN ↗

The BASIC print+goto loop might have been my first ever program too (in the 80s) but one thing for sure for me: it was definitely not “Hello, World”. I and others filled the screen with any number of silly things, random words, jokes and juvenile phrases, whatever, but for some reason, “Hello, World!” was a C thing, and I remember seeing it for the first time in a C class in high school, and then much more often in college.

I have memories of ‘poke’ as well. On the Atari 800 you could poke memory to change the keystroke repeat rate and delay before repeat started, so obviously we would turn down the delay to zero and turn up the repeat to max (it was maybe 60 characters per second), so anyone trying to type couldn’t hit the keys quickly enough to avoid repeating. You’d have to power-cycle the machine to fix it, so it was hilarious to 11 year old me.

Similar to his description of ‘poke’, but different mechanism - using debug.com on an IBM PC jr to edit the Ultimate III save files, and give myself maximum money and lives.

Good times!

41m agoHN ↗

Most definitely the juvenile phrases.

I think my second BASIC program was the "guess a number" one -- that seemed really popular in intro basic programming things in the 80s also since it showed keyboard input and conditionals and was, uh, fun-adjacent.

39m agoHN ↗

The reason that "Hello, World" is a C thing is that C is the source of the tradition around that phrase. In Kernighan and Richie's "The C Programming Language" printing "Hello, World" is the very first exercise.

26m agoHN ↗

Concur. Us hackers who got started with BASIC had a more fun and creative ethos.

34m agoHN ↗

My first shipped code was an art thing. C64 Basic. Poke random characters to random locations on the screen. Random colors, screen and border too. On infinite goto loop. Radio Shack (IIRC) in the local mall used it on all their C64s.

32m agoHN ↗

For debugging CSS, I prefer something along the lines of:

    * {
      outline: 1px solid hotpink !important;
      outline-offset: -1px !important;
    }

As in most cases the above snippet doesn't reflow content.

Exercise to the reader is to turn the above into a javascript bookmarklet toggle, and to add support for shading margins and padding.

16m agoHN ↗

if you're using firefox, you can generally juts ctrl-click on the page. It'll draw outlines around every child element without reflowing.

30m agoHN ↗

Here are 3 lines that capture something profound about Lisp: code can manufacture code that manufactures code:

———————

(defmacro twice (form)

  `(progn ,form ,form))

(twice (print "Reality"))

———————

twice doesn’t execute its argument twice. It rewrites the program itself before execution into:

(progn

    (print "Reality") 

    (print "Reality"))
14m agoHN ↗

Hmm. What a great question.

    while(1) { fork(); } 

Must have meant something to me, because it was in my Usenet sig. And then:

    exit(main(kfp->kargc, argv, environ));

from FreeBSD crt0; kind of a big moment for me to realize there was more C code underneath main().

Then:

    statements: /*E*/ | statement statements

The moment Yacc clicked for me; that line was profound but a more accurate depiction of the moment was realizing that all you were doing with the parser generator was building a tree, and that's what the side effects of each production were for: returning and plugging in tree nodes.

If there was a single line I could come up with for "double the size of the hash table when it fills up", that'd deserve a slot here.

Then, of course (we get to cheat because assembly):

    jmp .call
    .pop: pop esi
    ...
    .call: call .pop

The "delta offset" trick, which I believe came from x86 virus culture but was universal in 90s overflow exploits as a way to get position-independent references to strings and other memory things.

For sure:

    void walk(node *n) { if(!n) return; walk(n->left); visit(n); walk(n->right); }

I should figure out a way to fit a write-select(2) into a line because that's another "oh shit" moment for me.

Similarly: when Vern Paxson explained to me that he'd implemented TCP reassembly by simply opening up a file and using "seek" to place incoming segments in the right position. I could probably golf that down to a line! But it would be an annoying line.

12m agoHN ↗

Such a lovely article. Thanks for sharing.

11m agoHN ↗

This tiny batch script allowed for a poor man’s `touch` on Windows, which I used extensively from Windows NT to Windows 7. I typed `touch filename.txt` in the Total Commander mini-shell to quickly generate new, empty files.

This is funny to me, because I associate touch more with updating the timestamp of an existing file, and that script would miserably (destructively) be failing at that.