Ten lines of code that changed my world
Thread
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
Ten lines of code that changed my world
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
probably_wrong · · focus · HN ↗
I'm partially more in favor of "red" instead of "hotpink" for CSS, but that's just me.
thenthenthen · · focus · HN ↗
(){ :|:& };:
mattrighetti · · focus · HN ↗
:(){ :|:& };:
apsurd · · focus · HN ↗
irregularbowels · · focus · HN ↗
[dead]
dahart · · focus · HN ↗
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!
dgacmu · · focus · HN ↗
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.
mcherm · · focus · HN ↗
gabrielsroka · · focus · HN ↗
bojan · · focus · HN ↗
NetMageSCW · · focus · HN ↗
guelo · · focus · HN ↗
andsoitis · · focus · HN ↗
codazoda · · focus · HN ↗
The first one runs on an ESP32 that I plan to use as a watch. The software works, I just need to finish the 3D printed case.
The second runs on an RP2350 connected to my living room TV via an HDMI cord.
I have some much appreciation for these old machines I grew up with.
yencabulator · · focus · HN ↗
chihuahua · · focus · HN ↗
dotancohen · · focus · HN ↗
whartung · · focus · HN ↗
Undaunted, Fred took a look around, found the power button, and turned the machine off. Yes, that power button next to the "DO NOT TURN OFF" sign.
As the monitor and LEDs faded to black, the giggling stopped and my friend and I stood aghast at Fred's treachery.
Fred left, and we were tasked with restarting the machine, getting to the monitor, keying in the hex code of the cassette loader, and reloading BASIC from cassette.
Got it to work on our second try!
tc43 · · focus · HN ↗
animal531 · · focus · HN ↗
It would start the Spectrum's "loading screen" border which would then scroll infinitely.
At some point I also opened it up to see what it looked like on the inside, but I managed to damage the keyboard in the process. Thereafter whenever I wanted to play a game (via joystick) I would have to use a piece of wire to manually select the rows/columns of the matching keys to enter the load command.
analog8374 · · focus · HN ↗
throw34889 · · focus · HN ↗
Exercise to the reader is to turn the above into a javascript bookmarklet toggle, and to add support for shading margins and padding.
chias · · focus · HN ↗
andsoitis · · focus · HN ↗
———————
(defmacro twice (form)
(twice (print "Reality"))———————
twice doesn’t execute its argument twice. It rewrites the program itself before execution into:
(progn (print "Reality") (print "Reality"))
tptacek · · focus · HN ↗
Then:
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):
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:
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.
ulfbert_inc · · focus · HN ↗
layer8 · · focus · HN ↗
This is funny, because I associate touch more with updating the timestamp of an existing file, and that script would miserably (and destructively) be failing at that.
xp84 · · focus · HN ↗
beanaroo · · focus · HN ↗
yencabulator · · focus · HN ↗
drfloyd51 · · focus · HN ↗
Back in the day, I looked down my nose at other young fledgling developers that would #define true 1. I knew only clarity and woe lived down that road.
As verbose as it was stupid.I felt superior because I knew that #define false 0 was the only Boolean keyword hack that would work.
Still verbose, and stupid, but at least it was correct.These days… I don’t feel as confident about anything as I did about those #defines.
yboris · · focus · HN ↗
0x000xca0xfe · · focus · HN ↗
chris_engel · · focus · HN ↗
outline: hotpink 1px solid;
not border! It destroys the layout. I mean, come on :)
yencabulator · · focus · HN ↗
yencabulator · · focus · HN ↗
chris_engel · · focus · HN ↗
Maybe you reconsider who's the youngling...
readthenotes1 · · focus · HN ↗
someObject.changeToClassOf(SomrOtherClass);
(or something like that--i'm was long ago).
In Smalltalk, changing an object's class preserves instance variable (attribute) values when possible, silently dropping if not, and gives it an SomeOtherClass's inheritance (and method dictionaries as a result).
It forced me to realize that an instance of a class wasn't permanently coupled to be an instance of the class that instantiated it or even its current class
awwaiid · · focus · HN ↗
... er, but also cool and inspirational :)
metanonsense · · focus · HN ↗
perilunar · · focus · HN ↗
oliyoung · · focus · HN ↗
nah, `rebeccapurple` <a href="https://meyerweb.com/eric/thoughts/2014/06/19/rebeccapurple/" rel="nofollow">https://meyerweb.com/eric/thoughts/2014/06/19/rebeccapurple/
nickthegreek · · focus · HN ↗
ghoul2 · · focus · HN ↗
bigbezet · · focus · HN ↗
bhavaniravi · · focus · HN ↗
drpython · · focus · HN ↗
Brought back a lot of memories.
In the early 2000s, when video games weren't protected against DLL injection hacks, I spent a lot of time writing DLL injectors for fun and learning.
The line I used in every experiment was:
`jmp $` (or `EB FE` in machine code)
It was the shortest infinite loop in x86 assembly, equivalent to `while 1: ;`
I would create a minimal DLL with this assembly code, inject it into games like Battlefield 1942, and observe it in OllyDbg. The injected DLL would then start on a new thread and access all the game data in memory.