Live data from Hacker News

Ask HN: Do you ever go back and admire a piece of code you wrote?

news.ycombinator.com

221–230 of 267 posts

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#222
post #43

I do sometimes go back and stare at this wonder I crafted once: s=>s[0]+/.*( .|z)|...s.s?|T..|M[i-t]+|[AFINOUW][^o]v?|.*/.exec(s)[0].slice(-1).toUpperCase() It does something pretty useful, that has surely been written many times over. But unlikely ever as succinctly as this. :)

Alright, I'll bite - what does it do?

https://codegolf.stackexchange.com/a/122957, perhaps?

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#223

Earlier quoted context omitted.

The guys who installed new tile in my shower put in a custom shower niche that incorporated an interesting tile pattern, and I was glad to notice them taking pictures of it when they were done. It was neat to see their pride in creating an elegant one-of-a-kind feature (in what was otherwise a fairly routine project).

I sometimes wonder why it’s so difficult to find people like that.

Are you like that?

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#224
Rarely !

But what regularly happens is that I stumble on my own comments and/or helper methods, which saves me a ton of time.

Turns out that having a clean code structure with clear places to have those 5-liners that you need all the time is really useful, and by now I've got so much of them that they compose quite powerfully ! And old comments are like gold nuggets when the time comes to debug.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#226
It's been years since I've asked a question on Stack Exchange. There comes a point when any place I get caught up nobody can help me. So there are several questions I've answered myself. Of course, working in the same space six months later, I'll have a problem, search for it, and land on the question on Stack Exchange that I've answered months earlier. It's happened a few times.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#227
My number one favorite time is after I sold a company. Two years later, the company contacted me as the old CTO and asked me about some piece of core technology. They asked me to take them through it and show them what was going on since they wanted to migrate it into something else.

My first question was, "Haven't the other developers ever touched it." They said no. This core piece of technology scaled to way more users and was essential to making 100s of thousands of dollars for the company. It didn't even break once in two years. It was core to the service and they were just asking how to move it. I was so proud of previous me.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#228

Earlier quoted context omitted.

What's awful are those bad days when it's actually hours and hours of feeling like an idiot, draining you away, and then when you figure it out you still feel like an idiot because first off it was so simple and second of all solving something in minutes is not going to wash away hours of feeling like an idiot. Luckily as I have gotten older I have gotten fewer and fewer of those days.

I learn to accept when I am tired and need to take a break. Sometimes hours of needling through code can be solved in minutes on a fresh brain. I used to be stubborn and wouldn’t stop until I had made some progress and that went on making a tired day into an exercise in frustration. Took a while to have the confidence to shut down and start fresh the next day.

This hit me real hard, thank you I need to become better at this.

Just had a few frustrating days at work, lo and behold problem solved elegantly in 1 hour on a Great Prayer Day where I was supposed to be off-work.

The simple solution was just writing out a truth-table and then implementing it using the new C# switch expression to make sure I had all combinations taken into consideration.

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#229
Yes. But if you can figure out what it does you’re going to be really sad.

{ eval "package " . __PACKAGE__ . '::' . (0+$class) . "; use base qw(" . join(' ', map { ref($_) || $_ } @_) . ");" }

This might help:

my $package = bless $class, __PACKAGE__ . '::' . (0+$class);

Or this:

return Devel::Pointer::unsmash_hv(substr(ref $self, 2+length(__PACKAGE__))); }

Re: Ask HN: Do you ever go back and admire a piece of code you wrote?

#230

I have a Notion database of code Snippets for this purpose. Described this in a recent blog post: https://tkainrad.dev/posts/managing-my-personal-knowledge-ba... It's nice to take a moment after finishing a project, a challenging task, or whenever you feel like it and preserve snippets that you are proud of. Going through these pieces of code later brings back memories of these past projects, teams, tasks,...

+1 for db of code snippets - things like:

cat ~/src/example-code/py/numpy-masked-array.py

save me tons of time for those hairy things that I had to eat an hour to figure out and then use infrequently

Post reply on HN