十行改变我世界的代码
Ten Lines of Code That Changed My World

原始链接: https://pixelambacht.nl/2026/ten-lines-of-code/

这十段代码片段集锦如同程序员职业生涯的一部怀旧编年史,记录了技术成长的里程碑,也捕捉了代码生涯中那些奇思妙想的幽默瞬间。 从最初学习 BASIC 语言编写“Hello World”循环时的好奇,到通过 `POKE` 指令探索内存操纵时的兴奋,再到学生时代编写 Pascal 账号扫描器时的叛逆尝试,这些代码行标记了学习路上的关键节点。这份清单展现了开发者工具箱的多样性:既有像 Windows 系统 `touch.bat` 变通方案这样的实用技巧,也有“亮粉色” CSS 调试法,以及 `rm -rf /` 那种充满传奇色彩的危险诱惑。它同样歌颂了这一行中创意与荒诞的一面,包括 JavaScript 的幽默梗、自修改的 6502 汇编语言,以及一段限制在 280 字符内、充满诗意且极具动感的 CSS 代码块。 归根结底,这些代码片段反映了开发者与他们作品之间的深厚联系——在这里,代码行不仅仅是指令;它们是记忆、是圈内笑话,更是对机器内部那份绝对控制力与混乱感的有力见证。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 改变我世界的十行代码 ( pixelambacht.nl ) 8 分 由 dimonomid 发布 2 小时前 | 隐藏 | 往期 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

September 25, 2026

Ten lines of code that, one way or another, mean something to me. Either because I wrote them, or I extensively copied them, or they made me laugh. Or cry.

Hello world lines running down a homecomputer screen

Hello World

10 PRINT "HELLO, WORLD!"
20 GOTO 10

I don’t know when I typed this for the first time, or if it was exactly this version. Might have been without the comma, or with more exclamation marks.

Nevertheless, the computer obliged, cheerfully greeting the world, and very much in particular, the wide-eyed kid who had just communicated with a computer for the first time.

The second line drove home the point that a computer will do anything you tell it to. Hello world forever!

Holy JavaScript weirdness, Batman!

Array(16).join('wat' - 1) + ' Batman'

Copy the line and paste it your browser’s console for a crossover between old school pop culture TV and nerdy coding humor, with a big fat dose of “JavaScript is stupid” on top.

A classic, and a genuine LOL when I first ran it.

Self modifying 6502 assembly code

        LDX #$00        ; Load X with the value 0
.loop   LDA $2000,X     ; Load A with the byte at address $2000 + X
        STA $0400,X     ; Store A at address $0400 + X
        INX             ; Increase X by one
        BNE .loop       ; Branch back to .loop while X is not 0
        INC .loop+2     ; X is 0, increase the byte at .loop + 2
        INC .loop+5     ; Also increase the byte at .loop + 5
        LDA .loop+5     ; Load A with the byte at address .loop + 5
        CMP #$07        ; Compare it with 7
        BNE .loop       ; Branch back to .loop if A is not 7

Machine language is as close to the metal as it gets. No warnings, no logs, no guardrails. It even allows you to modify itself, by overwriting the actual bytes of the code while it runs.

Like in this example, where you update the high bytes of the source and destination addresses. The branch loops from $2000 to $20FF, and the subsequent INC changes the address from $2000 to $2100, before starting the loop again.

(The 6502 is little endian, so we do +2 and +5 instead of +1 and +4)

As low-level as it gets, hardcore, and slightly dangerous. Realizing you could do this really drove home the point that, when coding this close to the metal, anything goes.

touch.bat

type nul > .\"%*"

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. Couldn’t live without it.

CSS debugger

border: 10px solid hotpink;

The console.log of the cascades! The var_dump() of the styles! The printf() of the sheets!

And always hotpink.

Infinite lives

POKE 9450,173

Just poke a specific byte into the right place of the binary code currently in the computer’s memory, and you suddenly get infinite lives, enegry or money.

Not only did this allow you to cheat at the game, it also brought the powerful realization that everything in any game could be manipulated, as long as you knew where to PEEK and POKE.

The speed-up loop

for(i=0;i<1000000;i++) {;}

“The idea is,” Wayne continued, “whenever we have those really slow weeks – you know, the kind where don’t actually fix any bugs or make any other changes – we just drop one of the zeros on the loop. And then we just tell the manager that we ran into some speed issues with the latest change request, but after a whole lot of deep-juju optimization, we were able to speed things up significantly and should be able to do the change request the next week.”

A funny story, and for those of us who ever had to toil away on boring, aimless projects, an idea that might have its appeal.

RTFM or rm -rf /

# rm -rf /

If you ran into a problem with Linux around the 2000s, you often took to IRC in search for help. It was there that many found the magic cure to all Linux problems, which was always the same: log in as root, and run rm -rf /.

Without fail, it made every Linux problem dissappear!

SKAN2.PAS

{$M $4000,0,0 } {16 Kb stack}
{Skan v2.00 by Trexx}
Program Skan2;
uses crt,dos;
var a,b,c:char;
    b1:byte;
    str:string[3];
    Ends:boolean;
begin
    Ends:=False;
    a:='a';      {Start values}
    b:='a';
    c:='a';
    repeat
        inc(c);
        if (c='z') then
        begin
            inc(b);
            c:='a';
        end;
        if (b='z') then
        begin
            inc(a);
            b:='a';
        end;
        str:=a+b+c;
        {Change this when FULL.EXE is in another directory}
        exec('z:\public\full.exe',str);
        if (whereY>10) then readln;
    {Hit anykey to quit}
    until KeyPressed or Ends;
end.

It was the early 90s and our school finally set up a LAN, so of course my cyberpunk scriptkiddies lamers 1337 h4x0rz buddies and I explored it. We knew that all usernames consisted of three letters, and those not in use would be left at the default password.

So we whipped up this extremely crude username scanner in Borland Pascal. More bugs than lines of code, but it sorta did the job. (And it should — it’s version 2.00 after all!)

We happily hacked all the dormant accounts we could find, and then… moved on.

CSS280

*{transform:translateY(24vh);text-align:center}*>:before{animation:a 9s
1e+9 linear;content:'Roses are #F00'}@keyframes a{10%,15%,35%,40%,60%,65%,
85%,90%{opacity:1}12%,37%,62%,87%{opacity:0}25%{content:'Violets are #00F'
}50%{content:'All my base'}75%{content:'Are belong to you'}}

An animated poem in nothing but 280 characters of CSS. No JavaScript, not even HTML — it would run in an empty document with just a <style> block, and these 280 characters of pure CSS.

The artifical limit was a step up from the earlier 140 character limit, dictated by Twitter, allowing small snippets of code to be posted that you could copy over to an empty CodePen to see an amusing effect.

I’m especially proud of the 1e+9 duration, which is shorter than infinite (both in time as in character count).

联系我们 contact @ memedata.com