Ask HN: Small scripts, hacks and automations you're proud of?
301–310 of 340 posts
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#302Back in the modem days, I tapped into the pins between my modem and computer’s serial port and put a speaker between RX and GND, with a switch of course so I could turn it on and off. When on, it would make data noises at a reasonable volume indicating the current bandwidth usage. If a download got stalled, it was obvious even if I didn’t have that window in the foreground, or wasn’t even sitting at the computer. Als…
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#303I have a 10 line C# script which manages my notes. It's pinned to my Start menu. When I run it, it ensures an .md file for the current day is created in the folder for the current day, which is in the folder for the current month, which is in my notes folder, then opens VSCode on my notes folder with today's file focused. This is the bare minimum note structure which I can then break out into multiple files or move t…
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#304Earlier quoted context omitted.
oh I've been down the "I can just fix macOS" road. The sooner you move away the better. so much time wasted on plugins like these. you effort will just be null the second apple change the usability apis enabling hammerspoon, like they did countless times before. I don't even rename the name of the fallen apps before it. instead now I contribute things as long lived proper features on KDE and hopefully advance humanit…
I am down as soon as we can use the full M machines with Asahi Linux
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#305In 2004, the website All Music Guide did a horrible redesign. I was so irritated that I created a Firefox extension that did only one thing — it made All Music Guide a bit more useable. To my knowledge, this was the first "site-specific" browser extension, so I wrote a blog post about it: https://www.holovaty.com/writing/all-music-guide/ Aaron Boodman saw my post and decided to generalize the idea; he created Greasem…
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#306When I run a command that takes long, I run it (I use fish but any shell has an equivalent) like:
./mycommand && beep
or
./mycomand && play something.wav
It can be useful If I am doing something else on the computer or outside of it. It saves time from checking over and over if the command finished.
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#307I have a 10 line C# script which manages my notes. It's pinned to my Start menu. When I run it, it ensures an .md file for the current day is created in the folder for the current day, which is in the folder for the current month, which is in my notes folder, then opens VSCode on my notes folder with today's file focused. This is the bare minimum note structure which I can then break out into multiple files or move t…
What do you use for auto pasting images?
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#308I use it not for just persisting commands but leaving comments for future me such as github personal tokens or api keys etc.
[0] https://eli.thegreenplace.net/2013/06/11/keeping-persistent-...
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#309Re: Ask HN: Small scripts, hacks and automations you're proud of?
#310At my first software developer job (small company of about 400 people in a country in Asia), there was a company wide requirement that our working hours should be logged into OpenProject.
Logging the hours turned out to be painful because the UI was clunky. Too many clicks and page loads were needed. You probably see where this is going.
Iteration #1:
After working there for a year, one evening I checked out the API for OpenProject. The web interface itself includes a place to set an access token, and examining the browser network tab gave me additional information that I needed.
In about a couple of hours, I wrote a quick and dirty python script that would read a text file formatted this way:
etc
My script when invoked read the file line by line and pushed each entry to OpenProject via API calls.What took 15 minutes every evening now only took 30 seconds!
Having said that, this was a quick and dirty script, and although it worked fine I didn't want to spend time cleaning things up.
Iteration #2:
30 seconds was too long!
This was because for every line in my input text file it would establish a new API connection. So if there was 5 lines of input, it would make essentially the same 5 API calls.
(There's probably a proper way to bundle all input into a single API call, but that's not the approach I took.)
I realised that my workload is embarrassingly parallel. I altered my script to process each line in parallel.
What took 30 seconds on a typical day now only took like 5 seconds! (Depending on input size of course).
(My dirty script became dirtier in terms of code quality.)
Iteration #3:
Even though it took literally just 5 seconds, manually running the script every evening was a chore!
So I setup a cronjob to run at 6:05 pm everyday to run this automatically. 6 pm is when I usually call it a day.
On the occasional day that I stay a little bit longer, I just had to log in manually to OpenProject and do the necessary adjustments. No big deal.
Iteration #4:
Before the aforementioned cronjob ran I'd like to review what it's going to push. I discovered the notify-send utility in Linux that I can use to display a popup.
Wrote a crontab entry to show me the contents of the input file in a popup a few minutes before my other script ran.
Iteration #5:
(By this time I've been relying on this python script for over a year).
OCD finally became unbearable about the crappy code quality (even though I never actually had to look into the code at all for like 9 months by this point).
One weekend I rewrote everything in Go (to take advantage of goroutines, since my program could readily use those — and because parallel programming in other languages I knew felt like an afterthought, though that's a topic for another day). My keys and such things were now in a proper config file.
The Go program also ran without hiccups.
I left the place about 6 months later though.
It was fun!