HNHacker News
TopNewBestAskShowJobs

cyco130

620 karma · joined June 24, 2021

Developer, musician, and occasionally other things. Creator of Rakkas, Hattip, and vavite.
submissionscomments
cyco130··on Pee.ie – Public Toilets Near Me Ireland
Not saying it’s a bad idea but it’s not original. A certain George Costanza built it first.
cyco130··on The Copenhagen Book: general guideline on implementing auth in web applications
I don't think there's any difference between extending the existing session and creating a new one in Lucia's context.

In the first scenario, the attacker steals the token and uses it forever. In the second, the attacker steals the token and they'll get a fresh one near its expiry. They can still impersonate the user forever. The user might notice something when they get kicked out (because the attacker renewed the token, rendering the old one invalid) but it's unlikely. For good UX, you need a grace period anyway, otherwise legitimate users can have problems with parallel requests (request one causes a token refresh, request two gets rejected because it was initiated before the first one was completed).

You can use a second token (a refresh token) but it only pushes the risk to the second token. Now we need to worry about the second token being stolen and abused forever.

Refresh tokens are useful for not having to hit the database on every request though: Typically, the short lived session token can be validated without hitting the db (e.g. it's a signed JWT). But it means that you can't invalidate it when stolen, it will be valid until expiry time so the expiry time has to be short to limit the damage. For the refresh token, on the other hand, you do hit the db. Using a second token doesn't add any security, hitting the db does, because the refresh token can be invalidated (by deleting it from the db).

Lucia always hits the db (at least in their examples), so you can invalidate tokens anytime. To mitigate risks, you can allow the user to see and terminate their active sessions (preferably with time, location, and device info: "Logged in 12 AM yesterday from an iPhone in Copenhagen"). You could also notify the user when someone logs in from a new location or device.

That's about all you can do. There's simply no fully secure way of implementing long-lived sessions.

cyco130··on "Comedy is search" – theory on how jokes work
There is some connection between music and comedy (or at least joke punchlines, like many, I'm not convinced this theory explains how all comedy works): Musical structure almost always relies on establishing a pattern (repetition) and breaking it (contrast).
cyco130··on Don't defer Close() on writable files (2017)
See my reply to the sibling comment about try-with-resources. I'm not familiar with any of these mechanisms but giving access to suppressed exceptions is probably a step in the right direction.
cyco130··on Don't defer Close() on writable files (2017)
My Java knowledge is at least 10 years out of date so I'm not familiar with try-with-resources. But from what I can gather from Google, it looks like they now provide a way to access the suppressed exceptions, which is probably a step in the right direction.
cyco130··on Don't defer Close() on writable files (2017)
That's probably the best option I think. I've heard Ada does that (but don't quote me on that). If you can access the original errors from the `MultipleError` object, at least you can tell the user what exactly went wrong.

I don't thing there's one true right thing™ though. That's why explicit handling is necessary: The compiler doesn't have enough context to handle it for you. The programmer needs to decide what's the right way to handle it.

cyco130··on Don't defer Close() on writable files (2017)
This problem isn't solved with exceptions either. The problem is that finalizers (C++ destructors, Java's `finally` blocks, Go's `defer` etc.) shouldn't fail but `close()` can fail. Therefore, for 100% correctness, `close()` calls should be handled explicitly and not left to finalizers.

Finalizers shouldn't fail because they might be executed while another exception is already in flight. Three languages have three different behaviors when that happens but in my opinion they all do the wrong thing:

In C++, if you throw from a destructor while another exception is in flight, the program will be terminated. In Java, throwing from a `finally` block will "forget" the original exception. In Go (according to this article, I'm not familiar with it), error from `defer` will be ignored. None of these are ideal.

cyco130··on Clay (short for C Layout) is a high performance 2D UI layout library
Both Clay and the IDE look awesome!
cyco130··on Clay (short for C Layout) is a high performance 2D UI layout library
Hmm, I don't think so, doesn't seem similar. I see a mario.chr in the next tab, seems NES-related. Pretty sure it's our beloved 6502 :)
cyco130··on Clay (short for C Layout) is a high performance 2D UI layout library
Hey, that's 6502 code!
cyco130··on Let's Write a Reverb (2021)
Came to write this. The guy not only makes the best algorithmic reverb plugins out there and sells them very cheap, he also shares his obsessively deep and broad knowledge on the subject. Big fan.
cyco130··on German Navy still uses 8-inch floppy disks, working on emulating a replacement
Dear German Navy. I have built disk emulators before[1]. Please contact me if you need help :D

[1] https://sourceforge.net/projects/aspeqt. Better maintained fork: https://github.com/RespeQt/RespeQt

cyco130··on Qlock – A JavaScript Quine Clock
I can't believe I missed this Seinfeld reference opportunity!
cyco130··on Qlock – A JavaScript Quine Clock
I once used the word "quine" in Scrabble. We had a house rule that allowed all English words on English Wiktionary if you could give a more or less correct definition. I gave the computer science definition but it turns out it had a more interesting meaning that immediately caught on in that particular friend group: "To deny the existence or significance of something obviously real or important".

[1] https://en.wiktionary.org/wiki/quine#Verb

cyco130··on Why did Tom Lehrer swap fame for obscurity?
“I Got It from Agnes” is the funniest song ever written and I will refuse to socialize with anyone who thinks otherwise after hearing it. What a brilliant mind.
cyco130··on Winamp has announced that it is "opening up" its source code
Heh, I wish Justin had some time to lay his hands on it again after so many years. (On a second thought, I’m happier with him being busy with Reaper).
cyco130··on Clojure: Managing throughput with virtual threads
Aren't "virtual threads" built on a thread pool themselves? I suppose there would be no advantage in pooling an already pooled resource since presumably the runtime would manage pooling better than user code.
cyco130··on Hardest problem in computer science: centering things
Obligatory xkcd reference: https://xkcd.com/1015/
cyco130··on GenZ software engineers, according to older colleagues
But any non-trivial BASIC program had to include a few machine language subroutines here and there for speed. And people knew how to “hand-assemble” them without even an assembler.
cyco130··on Children need risk, fear, and excitement in play
When I was a kid (~10 yo), mothers of younger (~4 yo) kids would send them to the grocery store a few blocks away and ask us to follow them in secret to make sure they didn't get lost or run under a car or anything. This way they could build confidence in relative safety.

I believe it's now illegal in some jurisdictions.

cyco130··on Apple rejected Bing for wrong answers about Annie Lennox
> Giannandrea wasn't impressed by that, nor Bing's lack of local language coverage in markets Apple cared about, nor the poor progress Microsoft had made improving the search engine since the two tech giants previously discussed search preferences during 2015 and 2016.

Sounds like they had much more valid reasons than Bing being wrong about Annie Lennox's first band to me.

cyco130··on Concrete.css
Looks fine to me apart from the buttons. But if we're talking about "classless", some _has_ to mention Marx[1].

[1] https://mblode.github.io/marx

cyco130··on Edsger Dijkstra carried computer science on his shoulders (2020)
An the person who changed the title, inventing the now iconic trope "considered harmful" was none other than recently deceased Niklaus Wirth.
cyco130··on Programming Language Checklist (2011)
You may find Zig interesting: https://ziglang.org. The language is not C compatible but the tooling can compile C and C++ without hassle.
cyco130··on Reading QR codes without a computer
I was so happy that I'm still boasting about it some 25 years later!
cyco130··on Reading QR codes without a computer
Slightly off topic: One day in the late 90s or early 2000s, I wanted to transfer the contents of my Atari 8-bit disks to my PC. I did know about SIO2PC, a cable that converts between Atari's SIO port and the PC's serial port and a piece of software to go with it. But I didn't have the electronics skills to build one (even though it is actually very easy).

So I ended up writing a Basic program on the Atari to read data from the disk sector by sector and paint it on the screen (with the large 4-color pixels of graphics mode 3). The Atari was connected to the TV card of my PC and a Delphi program I wrote was running on the PC that kept taking screen shots and trying to decode the data from there. I quickly learned that empty sectors threw off my pixel position calibration so I added a mask pattern and a checksum. The sector address was also included. With that, I was able to transfer all my disk contents to my PC. To this day I consider it my greatest engineering achievement :)

Some ten years later, I went on to build an SIO2PC program called AspeQt. A more up-to-date community fork called RespeQt is still the most popular tool in that category used by the community. It even has its own subforum on AtariAge[1].

[1] https://forums.atariage.com/forum/184-respeqt-sio2pc-softwar...

cyco130··on What does the cerebellum do?
If you're curious about the pronunciation of Purkinje like me: In Czech, [purkɪɲɛ] (spelled Purkyně); in English, per-kin-jee [/pɝkɪnd͡ʒiː/].

https://www.youtube.com/watch?v=23MFfOsTDIs

cyco130··on Dennis Ritchie on the priorities of && || vs. == etc. (1982)
Pascal also uses the same operators for bitwise and logical and and or and they’re simply and and or.
cyco130··on Hattip – An Express-compatible runtime for Cloudflare, Netlify, Vercel, etc.
Author here. Missed this but thanks for sharing!

Important clarification though: Hattip is _not_ Express compatible nor it aims to be. It uses the completely different and incompatible fetch API instead of the node:http API.

cyco130··on 4B If Statements
But of course WebAssembly is the future. So we should reimplement it in WASM.
← PreviousPage 3 of 5Next →