Live data from Hacker News

Ask HN: What's your "it's not stupid if it works" story?

news.ycombinator.com

81–90 of 510 posts

Re: Ask HN: What's your "it's not stupid if it works" story?

#81

I worked at a startup where the core backend was 1 giant serverless Function. For error handling and recovery, the Function ran in a while loop. For all its faults, it worked and it was generating revenue. Enough that the startup got to a sizable Series A. That experience completely changed how I think about writing code at startups.

this is great. if you look at older game source code you find things like this. things that we view as horrible hacks which are both extremely stable and perform well. i see no reason to stop using these types of solutions, when appropriate.

Old games also didn't use a database, they saved everything in a giant text file.

I'm not sure if they were "extremely stable" though. Like Myspace, it might only work up until a certain point. What kills stuff is usually going viral.

Re: Ask HN: What's your "it's not stupid if it works" story?

#82
ZX Spectrum BASIC. Numbers could only be 8 digits, needed more for a Spacemaster RPG ship designer program I wrote for my friends. Came up with storing values as strings and splitting/manipulating them as numbers when required. About fifteen years old. Probably the smartest thing I have ever written, grin.

Re: Ask HN: What's your "it's not stupid if it works" story?

#83
post #81

Earlier quoted context omitted.

this is great. if you look at older game source code you find things like this. things that we view as horrible hacks which are both extremely stable and perform well. i see no reason to stop using these types of solutions, when appropriate.

Old games also didn't use a database, they saved everything in a giant text file. I'm not sure if they were "extremely stable" though. Like Myspace, it might only work up until a certain point. What kills stuff is usually going viral.

I think you maybe underestimate the utility and reliability of flat text files on a filesystem.

If you don’t trust a filesystem, you can’t trust anything that uses one.

Flat files don’t scale past a certain point, but that point is way higher than most believe it is.

Re: Ask HN: What's your "it's not stupid if it works" story?

#85
Mine's getting command output out of docker. For long builds (I had one that took 4 hours), it was gutting to have it fail a long way in and not be able to see the output of the RUN commands for thorough debugging.

So I devised a stupidly simple way: add && echo "asdfasdfsadf" after each RUN command. I mashed the keyboard each time to come up with some nonsense token. That way, docker would see RUN lines as different each time it built, which would prevent it using the cached layer, and thus would provide the commands' output.

I wrote the same thing (more completely) here: https://stackoverflow.com/a/73893889/5783745

(a comment on that answer provides an even better solution - use the timestamp to generate the nonsense token for you)

As stupid as this solution is, I've yet to find a better way.

Re: Ask HN: What's your "it's not stupid if it works" story?

#86
post #85

Mine's getting command output out of docker. For long builds (I had one that took 4 hours), it was gutting to have it fail a long way in and not be able to see the output of the RUN commands for thorough debugging. So I devised a stupidly simple way: add && echo "asdfasdfsadf" after each RUN command. I mashed the keyboard each time to come up with some nonsense token. That way, docker would see RUN lines as different…

I'm a Docker amateur, so this will be a dumb question, but if you were using that technique after every run line in a DockerFile, wouldn't they be the same every time they're run? Like, it's random, but it's the same random values stored in the file, so wouldn't the lines get cached? Or did you adjust the DockerFile each time?

Or am I completely missunderstanding?

Re: Ask HN: What's your "it's not stupid if it works" story?

#87
post #85

Mine's getting command output out of docker. For long builds (I had one that took 4 hours), it was gutting to have it fail a long way in and not be able to see the output of the RUN commands for thorough debugging. So I devised a stupidly simple way: add && echo "asdfasdfsadf" after each RUN command. I mashed the keyboard each time to come up with some nonsense token. That way, docker would see RUN lines as different…

I'm a Docker amateur, so this will be a dumb question, but if you were using that technique after every run line in a DockerFile, wouldn't they be the same every time they're run? Like, it's random, but it's the same random values stored in the file, so wouldn't the lines get cached? Or did you adjust the DockerFile each time? Or am I completely missunderstanding?

> Or am I completely missunderstanding?

No, I just didn't explain it very well. You have to mash the keyboard each time (i.e. each build) to come up with some new token. The reason this (dumb) idea was so useful was it was a choice between that (dumb idea) and either run with --no-cache (i.e. wait 2-3 hours) or build normally and not have a clear idea why it failed (since no console output for cached layers), so taking a moment to mash the keyboard in a few places (as absolutely stupid as that is) was way better than the alternative of not having complete console output (docker provides no way to --no-cache on a per layer basis, hence my stupid way of achieving it).

Re: Ask HN: What's your "it's not stupid if it works" story?

#88

15+ years ago, I was working on indexing gigabytes of text on a mobile CPU (before smart phones caused massive investment in such CPUs). Word normalization logic (e.g., sky/skies/sky's -> sky) was very slow, so I used a cache, which sped it up immensely. Conceptually the cache looked like {"sky": "sky", "skies": "sky", "sky's": "sky", "cats": "cat", ...}. I needed cache eviction logic as there was only 1 MB of RAM av…

Those are my favorite functions! Two lines of code with a page of text explaining why it works.

Re: Ask HN: What's your "it's not stupid if it works" story?

#89
We have a production service running for years that just mmaps an entire SSD and casts the pointer to the desired C++ data structure.

That SSD doesn't even have a file system on it, instead it directly stores one monstrous struct array filled with data. There's also no recovery, if the SSD breaks you need to recover all data from a backup.

But it works and it's mind-boggingly fast and cheap.

Re: Ask HN: What's your "it's not stupid if it works" story?

#90

Around 16 years ago, Wordpress security was just not up to snuff yet, and my popular Wordpress-based site kept getting hacked by pharmaceutical spammers and the like. After several such incidents, I wrote a "wrapper" that loaded before Wordpress to scrutinize incoming requests before a lick of Wordpress code was executed. It had blacklists, whitelists, automatic temporary IP blocking, and that sort of thing. There wa…

Haha you invented WAF! https://www.cloudflare.com/learning/ddos/glossary/web-applic...
Post reply on HN