Ten Lines Of Code That Changed My World

Ten Lines Of Code That Changed My World

十行改变我世界的代码

September 25, 2026 2026年9月25日

Ten lines of code that, one way or another, mean something to me. Either because I wrote them, I extensively copied them, or they made me laugh. Or cry. 这十行代码以各种方式对我意义非凡。要么是因为我亲手编写过,要么是因为我大量引用过,又或者它们曾让我开怀大笑,甚至潸然泪下。

Hello World

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! 我不记得第一次敲下这段代码是什么时候,也不确定是否就是这个版本。可能当时没有逗号,或者感叹号更多一些。尽管如此,计算机还是照做了,欢快地向世界问好,尤其是向那个第一次与计算机交流、瞪大眼睛的孩子问好。第二行代码深刻地传达了一个道理:计算机只会执行你告诉它的任何指令。Hello world 永存!

Holy JavaScript weirdness, Batman!

见鬼的 JavaScript,蝙蝠侠!

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. 把这行代码复制并粘贴到浏览器的控制台中,你就能体验到老派流行文化电视节目与极客编程幽默的碰撞,外加一大剂“JavaScript 真蠢”的调侃。这是一个经典之作,我第一次运行它时真的笑出了声。

Self modifying 6502 assembly code

6502 自修改汇编代码

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. 机器语言是与硬件最贴近的语言。没有警告,没有日志,没有防护栏。它甚至允许你在运行时通过覆盖代码本身的字节来修改自己。就像这个例子,你更新了源地址和目标地址的高位字节。分支循环从 $2000 到 $20FF,随后的 INC 指令将地址从 $2000 改为 $2100,然后再重新开始循环。(6502 是小端序,所以我们使用 +2 和 +5 而不是 +1 和 +4)。这是最底层的操作,硬核且略带危险。意识到这一点让我深刻体会到:当在如此接近硬件的层面编程时,一切皆有可能。

touch.bat

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. 这个微小的批处理脚本在 Windows 上实现了一个“穷人版”的 touch 命令,我从 Windows NT 到 Windows 7 一直都在大量使用它。我在 Total Commander 的迷你 shell 中输入 touch filename.txt 来快速生成新的空文件。没有它我简直活不下去。

CSS debugger

CSS 调试器

border: 10px solid hotpink;

The console.log of the cascades! The var_dump() of the styles! The printf() of the sheets! And always hotpink. 这是层叠样式表里的 console.log!是样式里的 var_dump()!是样式表里的 printf()!而且永远是亮粉色。

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, energy 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. 只需将特定的字节“戳”(POKE)进计算机内存中当前二进制代码的正确位置,你就能瞬间获得无限生命、能量或金钱。这不仅让你能在游戏中作弊,还带来了一个强有力的认知:只要你知道在哪里 PEEK(读取)和 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. “主意是这样的,”韦恩继续说道,“每当我们遇到那些进展缓慢的周——你知道的,就是那种实际上没修复任何 Bug 或进行任何改动的周——我们就从循环里删掉一个零。然后我们告诉经理,我们在最新的变更请求中遇到了一些速度问题,但经过一番深奥的优化,我们成功地大幅提升了速度,应该能在下周完成变更请求。”这是一个有趣的故事,对于那些曾经在枯燥、无意义的项目中苦苦挣扎的人来说,这个主意或许还有点吸引力。

RTFM or rm -rf /

查阅手册或 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 disappear! 如果你在 2000 年代左右遇到 Linux 问题,通常会去 IRC 寻求帮助。在那里,许多人找到了解决所有 Linux 问题的“灵丹妙药”,而且总是同一个答案:以 root 身份登录,然后运行 rm -rf /。毫无疑问,它能让所有 Linux 问题消失!

SKAN2.PAS

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. 那是 90 年代初,学校终于建立了局域网,所以我和我的赛博朋克脚本小子、菜鸟、精英黑客朋友们自然要探索一番。我们知道所有用户名都是三个字母组成的,而那些未使用的账户会保留默认密码。于是,我们用 Borland Pascal 拼凑了这个极其粗糙的用户名扫描器。它的 Bug 比代码行数还多,但勉强能用。(毕竟它是 2.00 版本!)我们愉快地黑进了所有能找到的闲置账户,然后……就没然后了。

CSS280

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). 这是一首仅用 280 个字符的 CSS 编写的动画诗。没有 JavaScript,甚至没有 HTML——它可以在一个空文档中运行,只需一个 <style> 块和这 280 个纯 CSS 字符。这个人为的限制是继 Twitter 早期 140 字符限制后的升级,允许发布简短的代码片段,你可以将其复制到空的 CodePen 中查看有趣的效果。我特别为 1e+9 的持续时间感到自豪,它比无限(无论是在时间上还是字符数上)都要短。