Live data from Hacker News

Scripts I wrote that I use all the time

evanhahn.com

361–370 of 408 posts

Re: Scripts I wrote that I use all the time

#361

Earlier quoted context omitted.

Not all time is created equally though, so I disagree with that xkcd. If something is time sensitive it is worth spending a disproportionate amount of time to speed things up at some later time. For example if you’re debugging something live, in a live presentation, working on something with a tight deadline etc. Also you don’t necessarily know how often you’ll do something anyways.

> I disagree with that xkcd The xkcd doesn't seem to be pushing an agenda, just providing a lookup table. Time spent vs time saved is factual.

The title of the comic is “ Is It Worth the Time?”.

To take a concrete example, if I spend 30 minutes on a task every six months, over 5 years that’s 5 hours of “work” hours. So the implication is that it’s not worth automating if it takes more than 5 hours to automate.

But if those are 5 hours of application downtime, it’s pretty clearly worth it even if I have to spend way more than 5 hours to reduce downtime.

Re: Scripts I wrote that I use all the time

#362
post #6

This is exactly the kind of stuff I'm most interested in finding on HN. How do other developers work, and how can I get better at my work from it? What's always interesting to me is how many of these I'll see and initially think, "I don't really need that." Because I'm well aware of the effect (which I'm sure has a name - I suppose it's similar to induced demand) of "make $uncommon_task much cheaper" -> "$uncommon_ta…

I love this kind of stuff too, but too many times over the years I've found myself in environments without some of these higher level and more niche tools (including my own dot files), or the tool ends up abandoned, and I struggle to remember how to use the basics/builtins. I've gotten a lot more conservative about adopting them because of that.

Pretty much my take as well. I imagine spending a few hours a month customizing your shell and text editor (hello vim/Emacs folks) to be more efficient and powerful is _great_ for developers who rarely leave their own workstation. But I spend much of my day logging into random hosts that don't have my custom shell scripts and aliases, so I'm actively careful not to fill my muscle memory with custom shortcuts and the like.

Of course, I _do_ have some custom shell scripts and aliases, but these are only for things I will ever do locally.

Re: Scripts I wrote that I use all the time

#363
post #250

I have a bunch, but one that I rarely see mentioned but use all the time is memo(1) ( https://github.com/aktau/dotfiles/blob/master/bin/memo ). It memoizes the command passed to it. $ memo curl https://some-expensive.com/api/call | jq . | awk '...' Manually clearing it (for example if I know the underlying data has changed: $ memo -c curl https://some-expensive.com/api/call In-pipeline memoization (includes the input…

i see no way to name the memo in your examples, so how do you refer to them later? also, this seems a lot like an automated way to write shell scripts that you can pipe to and from. so why not use a shell script that won't surprise anyone instead of this, which might?

The name of the memo is the command that comes after it:

  $ memo my-complex-command --some-flag my-positional-arg-1
In this invocation, a hash (sha512) is taken of "my-complex-command --some-flag my-positional-arg-1", which is then stored in /tmp/memo/${USER}/{sha512hash}.zst (if you've got zstd installed, other compression extensions otherwise).

Re: Scripts I wrote that I use all the time

#364
post #250

I have a bunch, but one that I rarely see mentioned but use all the time is memo(1) ( https://github.com/aktau/dotfiles/blob/master/bin/memo ). It memoizes the command passed to it. $ memo curl https://some-expensive.com/api/call | jq . | awk '...' Manually clearing it (for example if I know the underlying data has changed: $ memo -c curl https://some-expensive.com/api/call In-pipeline memoization (includes the input…

> `curl ... | jq . | awk '...'` Uhm, jq _is_ as powerful (more) as awk. You can use jq directly and skip awk. (I know, old habits die hard, and learning functional programming languages is not easy.)

Yes, I know. I should've taken a different example. But it's also realistic in a way. When I'm doing one-offs, I will sometimes take shortcuts like this. I know awk fairly well, and I know enough of jq that I know invoking jq . pretty prints the inbound json on multiple lines. While I know I could create a proper jq expression, the combo will get me there quicker. Similarly I'll sometimes do:

  $ awk '...' | grep | ...
Because I'm too lazy to go back to the start of the awk invocation and add a match condition there. If I'm going to save it to a script, I'll clean it up. (And for jq, I gotta be honest that my starting point these days would probably be to show my contraption to an LLM and use its answer as a starting point, I don't use jq nearly enough to learn its language by memory.)

Re: Scripts I wrote that I use all the time

#365

Earlier quoted context omitted.

For me it's when I call customer service or support on the phone, and either give them an account #, or confirm a temporary password that I have been verbally given.

Are you referring to the nato alphabet utility? Or the alphabet script that prints abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ

Apologies, mistook for NATO. Maybe the alphabet is for fonts :)

Re: Scripts I wrote that I use all the time

#366

Earlier quoted context omitted.

They compete for time.

I'm saying that makes no sense, as I've wrote in the comment you're replying to.

Having a wife increases the opportunity costs of the time you spend on maintaining the scripts and also increases the costs while writing these (when the wife is nagging).

Re: Scripts I wrote that I use all the time

#368
post #342

Earlier quoted context omitted.

By definition, it the client Alice gives contractor Mallory access to user account alice, that's worse than giving them an account called mallory. Accounts are basically free. Not having accounts; that's expensive.

They specifically mentioned service accounts. If they’re given an user account to login as, they still might have to get into and use the service account, and its environment, from there. If the whole purpose was to get into the service account, and the service account is already setup for remote debug, then the client might prefer to skip the creation of the practically useless user account.

That's still not professional, but then again 99.9% of companies aren't.

Re: Scripts I wrote that I use all the time

#369

> alphabet just prints the English alphabet in upper and lowercase. I use this surprisingly often (probably about once a month) I genuinely wonder, why would anyone want to use this, often?

As a programmer, you sometimes want to make an alphabet lookup table. So, something like: var alpha_lu = "abcdefghijklmnopqrstuvwxyz"; Typing it out by hand is error prone as it's not easy to see if you've swapped the order or missed a character. I've needed the alphabet string or lookup rarely, but I have needed it before. Some applications could include making your own UUID function, making a small random naming sc…

Personally I only ever needed it once. I was re-implementing javascript function doing some strange string processing by using characters in the input string to calculate indexes of alphabet array to replace them with. Since I was using Python I just imported string.ascii_lowercase instead of manually typing the sequence, and when I showed the code to someone more experienced than me, I was told it's base64, so all my efforts were replaced with a single base64.b64_decode() call.

Re: Scripts I wrote that I use all the time

#370

These are great, and I have a few matching myself. Here are some super simple ones I didn't see that I use almost every day: cl="clear" g="git" h="history" ll="ls -al" path='echo -e ${PATH//:/\\n}' lv="live-server" And for common navigation: dl="cd ~/Downloads" dt="cd ~/Desktop"

I'm terrible about remembering shortcuts (edit a bash line in an editor? Can never remember it) but clear (CTRL-l) is one that really stuck. That and exit (CTRL-d). A guy I used to work with just mentioned it casually and someone it just seared itself into my brain.

Never new ctrl+l, that's great, thanks!
Post reply on HN