Live data from Hacker News

Ask HN: Small scripts, hacks and automations you're proud of?

news.ycombinator.com

1–10 of 340 posts

Ask HN: Small scripts, hacks and automations you're proud of?

#1
I sometimes think back fondly of the small automation scripts I wrote over the years, so I wanted to ask you: Which scripts, hacks & automations did you create that your're proud of? Personally, I e.g. built a bot to automatically answer apartment ads [1], a small script to run Borg backup once per day [2], and a small automation to track the temperature in my aquarium [3].

1: https://gist.github.com/adewes/c9b2a71457c6c6f01f2f

2: https://gist.github.com/adewes/02e8a1f662d100a7ed80627801d0a...

3: https://gist.github.com/adewes/7a4c20a5a7379e19d78ba54521d3d...

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#2
This is more in the "hack" category, but here is a solution for bookmarking directories[1] that I am quite fond of:

  mkdir ~/.marks/
  export CDPATH=.:~/.marks/
  function mark { ln -sr "$(pwd)" ~/.marks/"$1"; }
Then:

  mark @name   # add bookmark called @name for the current directory
  cd @name     # jump to the bookmarked location
  cd @    # list all available bookmarks
It can list bookmarks, auto-complete, jump to sub-directories within bookmarks, all without introducing any new commands - just `cd`.

[1]: http://karolis.koncevicius.lt/posts/fast_navigation_in_the_c...

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#3
I wrote some scripts to automate the tedious parts of my photo-to-texture pipeline. I learned enough of Blender's API to make a small plug-in to handle some of the rendering tasks. None of these are particularly sophisticated or impressive but they've saved me a lot of time.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#7
All of my favorite things are little AutoHotkey shortcuts. I have several that basically just execute a Regex replace on whatever text is currently highlighted. It's ridiculously convenient to just have those functions ready to go any time.

But I started accumulating so many of them, it got to be a problem just remembering all the ones I had and how to trigger them. I had to start finding new ways of keeping them all organized. That led to figuring out two things that I'm still really proud of and use every day: custom right-click menus and Emacs-style keychords.

The custom right-click menu is: any time I right-click while also holding down Ctrl or Alt, it opens a right-click dialogue run by AutoHotkey, not the default one in the given context. That lets me visually select what I want to happen rather than needing an arcane key combo for every thing. All of my frequently-used Regex functions are right-click menus now.

The key chords are: if I trigger a "prep" hotkey first—my most-used one is "Alt+G" for "Go-to"—it sets up a keyboard hook that listens for the next key and then dispatches to a function based on that. So, "Alt+G H" would be really easy to remember in my head as "Go to Hacker news." And it pops open a new tab in my browser. I use that one a lot for opening desktop applications—"Alt+O C" maps in my head to "Open vs Code." Super easy to remember.

I've automated 80% of the most common navigation items at my job this way. My coworkers have seen me do it and stopped me to ask, "Wait, tell me how you did that." It looks and feels like magic.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#9
In 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 Greasemonkey, which was a single browser extension that could aggregate site-specific JS customizations. In the years since, this idea of "user scripts" has further developed, and I think some browsers even support the concept natively.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#10
So certainly not impressive, and morally ambiguous, but when chatGPT first released, I worked with it to create a python script that crawled The New Yorker sitemaps, found articles with embedded audio versions, downloaded the mp3 by reconstructing the file url using the article ID in the page source, and then renamed the file to match the page title and saved it to a well structured Google Drive directory. Now when I walk my dog, exercise, or clean, I'll put on a random article and have a much more enjoyable experience than a podcast would offer. The mp3s were publicly available so I think it's fine for personal use?

I'd never written a line of code in my life, so going through the iterative process of getting it functioning and fixing bugs was pretty invigorating. I could see where the generated code was going awry and describe it in natural language, and chatGPT would turn that into syntax and explain why it worked. Definitely a fun way to learn.

I'm sure it's ugly/inefficient, but here's the script:

https://pastebin.com/raw/DuAVAikD

Post reply on HN