Ask HN: Small scripts, hacks and automations you're proud of?
31–40 of 340 posts
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#32So 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…
"going through the iterative process of getting it functioning and fixing bugs was pretty invigorating." Damn right it is! Writing scrapers is definitely the gateway drug of programming. It's such an exciting feeling to step across the boundaries from "passive user at the mercy of the UI" to "I can do anything if I can conceptualise it (and break it up into steps)".
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#33This little script in my i3 keybindings opens a new terminal with the same working directory as the currently focused terminal, pretty useful for my workflow: bindsym ctrl+$alt+t exec xdotool getactivewindow getwindowpid | xargs ps | grep "alacritty" && (xdotool getactivewindow getwindowpid | xargs pgrep -P | xargs pwdx | cut -d":" -f 2 | xargs alacritty --working-directory ) || WINIT_X11_SCALE_FACTOR=1 alacritty htt…
Maybe something like this could do the same? But could also rely on that specific terminal emulator
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#34All 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…
I used the dialog box to create little 'applications' such as listing all the printers in the building (along with description) and allowing the staff to choose the printers they wanted to use (back around 2005 ish)
I had loads of these little scripts for staff to use - and some server side stuff (mainly windows) such as generating daily configs and collecting all the logs and looking for differences
I pretty much automated half my job, allowing me to do more interesting stuff
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#35 # Sort list by most common terms
alias sorn='sort | uniq -c | sort -n'
# Most common IP addresses:
$ cat access_log | awk '{ print $2 }' | sorn
# Last 30 modified files.
function new() {
ls -lat "$@" | head -30 ;
}
# I just downloaded something, where is it?
$ new ~/DownloadsRe: Ask HN: Small scripts, hacks and automations you're proud of?
#36Re: Ask HN: Small scripts, hacks and automations you're proud of?
#37This way I can quickly boot any Pi in my house (and there are quite a few now) to any arbitrary OS image just by renaming a symlink on the server.
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#38Re: Ask HN: Small scripts, hacks and automations you're proud of?
#39I use this now:
import { execSync } from 'child_process';
execSync('git add -A');
const modifiedFiles = execSync('git status --porcelain')
.toString()
.trim()
.split('\n')
.map((line) => line.replace(/^\s*[MADRCU?!]{1,2}\s+/, ''));
const fileList = modifiedFiles.join(', ');
const commitMessage = `Change: ${fileList}`;
execSync(`git commit -am '${commitMessage}'`);
"changes:summary": "tsx ./tools/changes-summary.ts",