Live data from Hacker News

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

news.ycombinator.com

231–240 of 340 posts

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

#232

Most useful script I've ever written, and legitimately how I keep track of everything important in my life: #! /bin/bash function todo { if [ $# -eq 0 ] then vim ~/Dropbox/todo/todo_list.txt else vim "$HOME/Dropbox/todo/todo_list_$1.txt" fi } Sourcing this in my shell means I just have to type... todo To automatically get into my default todo list which is synced to dropbox (and thus accessible everywhere on mobile a…

I just have a Dropbox/todo.txt file opened permanently in Notepad++, no scripts and no need to type anything.

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

#233
post #26

This 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…

`alacritty --working-directory $(xcwd)` would be a bit shorter :)

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

#234
I have loads of DVDs and a hobby of mine is to back them up to my pc. So I created a utility to rip each title on a DVD to a folder, and then a CLI tool with machine learning to categorize title folders recursively under "Extra", "Episode", etc.

Bit more than a hack, but a simple thing which has made the whole process much easier

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

#235
I wrote some Emacs Lisp functions that I use a lot:

1. Toggle how function arguments are indented: either all on the same line, or all on separate lines.

2. Convert arbitrary piece of text into a literal string (i.e. with quotes).

3. Extension to Magit that calls git-grep.

4. Dired function that calls Ghostscript on multiple selected PDFs to combine them into a single PDF.

5. Magit extensions for internal Git commands added by the company I work for (they are all nonsense, but I have to deal with them and it's better to keep this nonsense to a minimum).

----

Stuff I don't use anymore, but used to be useful:

1. Govmomy Emacs Lisp wrapper for select functions that rendered information as Org tables (I don't need to work with VMWare anymore). Not sure if this counts as small, but it wasn't more than some 100-200 lines.

2. Emacs command to incrementally show duplicated lines.

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

#236
post #202

I got annoyed with unlocking my ebike with an app every day, so I created a car key enclosure with a Bluetooth chip to unlock it. So much work! Creating a custom PCB, writing software for the nRF52 chip, learning about BLE, security levels, GATT. Deep sleep and ultra low power usage. I use it every day and am really happy with it.

Sounds really cool, do you have a write-up of it anywhere?

https://blog.waleson.com/2022/03/the-worlds-first-cowboy-key...

Source code here: https://github.com/jtwaleson/cowboy-bike-remote-ble

I’m currently working on finalizing the PCB version, the first one had some flaws so the battery drained really quickly.

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

#237
This one liner is the heart of my anemic SSG. The main idea is to remove generated files if the source has been removed.

comm -23 1' "$DSTDIR/build-info") (gen_index) | xargs -n1 "$0" "$SRCDIR" "$DSTDIR" | sort | tee -a "$DSTDIR/build-info.new") | (cd "$DSTDIR" && xargs rm)

The rest is here: https://gist.github.com/hadrianw/060944011acfcadd889d937b960...

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

#238

Recently developed a small embedded device (using a nRF52840 microcontroller) that allows me to open my front gate remotely using my phone. I no longer have to carry around a gate remote. And my friends/guests can now open the gate from their phone as well. I couldn't find anything on the market for doing that so I'm glad I managed to do it (and it was a good opportunity to learn some embbedded programming and electr…

Neat! How did you reverse engineer the signal that your microcontroller had to send to the gate?

I got pretty far at decoding the signal with a RTL-SDR radio that I bought. It was a OOK code around 433mhz if I recall correctly. But I eventually abandoned that strategy as there was a simpler way to activate the gate through a direct electrical signal. So the device is just acts as a sort of switch now.

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

#239
A very basic one. I use Google drive a lot. It's a pain to go to Drive link and then look for the recent files and open it. So, I wrote a Gmail sidebar add in for the same. [1]

It does two things: 1. List the files in order of last modified or last opened. This way I can list 25 latest files and go to the ones opened by me. (no folders needed, just the last opened ones).

2. With last modified date, tells me when the file was modified last. (useful if you collect data in sheets from forms or other stuff, tells you when you have a new lead). Also tells you when the colleague you share a file with has edited it or not.

I wanted to enhance it with adding more stuff like: show diff, so I know what has changed. And then, show the content from a doc right here in sidebar, because well it's easier to type a mail by looking at that.

[1]: https://github.com/ankitmaloo/gmail-sidebar-drive

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

#240
post #161

Earlier quoted context omitted.

Since you have used several backup tools, I wonder which one you recommend.

Definitely Kopia. I was skeptical at first, it's a relatively new tool and not much is known about it (at least on HN) but it's uber-fast and compresses extremely well. Detection of duplicate blocks seems both more aggressive and faster compared to Borg and Restic. It's honestly a win on all fronts. It can sync to remote places -- which I don't care about as I have a local directory where it does its stuff and I then…

What's your opinion on bupstash?
Post reply on HN