Live data from Hacker News

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

news.ycombinator.com

111–120 of 340 posts

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

#111
I'm nursing a small fleet of CentOS 7 servers while we finish up migrations and upgrades this year. Most of these servers need certificates, but the built-in certbot package is really brittle (if not actually broken) depending on what plugins you might need to use. So I wrote a short wrapper script that handles everything for me:

https://gist.github.com/xenophonf/893b323b99644290fad420a54c...

It keeps the custom certbot install updated, and if anything goes wrong—and only if something goes wrong—I'll get an email thanks to chronic. Same goes for the install command outputs when running the wrapper/certbot interactively. You'll only see error messages when something breaks. Otherwise, it looks exactly like certbot was invoked directly, just with a short delay while the script does the install/update in the background.

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

#113
In my student days I bought and sold a lot of stuff online on a marketplace website that I guess was like Craig's list. The default sorting was by "recently posted" and your ad would very quickly get bumped off the front page. You couldn't post duplicate ads, so I made a Python scraper that would download all my ad text and photos, delete the ads, then recreate them, which meant I could stay on top of the page whenever I ran the script (which eventually I ended up running as a cron job of course).

Dunno if I'm proud of it, but I sold a bunch of stuff, most of which I'd bought by having other scrapers on other sites alert me when ads meeting my criteria were posted.

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

#114

I made a CLI tool for quickly starting new branches with draft PRs, asking for reviews, etc: https://github.com/dbalatero/work-cli Made a bunch of Hammerspoon plugins for macOS: - https://github.com/dbalatero/SkyRocket.spoon - mod+click to resize/drag windows - https://github.com/dbalatero/VimMode.spoon - Vim mode everywhere - https://github.com/dbalatero/HyperKey.spoon - pop-up menu for when you forget your keybinds…

that first plugin is genius! i'm totally gonna give it a go tomorrow!

edit: just opened the second. even better!

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

#115

I inadvertently caused a VERY VERY large corporation that is a household name to change its TOS through one of my little automation scripts. By little, I mean a few dozen lines of code and some ingenuity. The corp in question: Begins with V and ends with z and likes to screw customers. All above board, approved by several levels of various teams/depts. The head of a specific dept sent me several strongly worded texts…

Why sign NDAs? If you weren't violating the then TOS, what did you get in exchange to sign them?

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

#116
post #23

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…

"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)".

For me it was writing MIRC scripts that monitored the IRC channels I was in. So it was scrapping the content, but not nearly as elegant as what the OP mentioned.

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

#117
post #83

Earlier quoted context omitted.

> but it’s all queryable through an undocumented API How did you go about querying this?

My guess is the developer tools. Maybe the web page makes you open a date dropdown for "check-in" > select check-in date, same for checkout, hit "search", and then a pop-up would open saying "sorry, nothing available", which you'd have to dismiss before repeating the process, but in the developer tools you might be a able to see that there's an XHR query which is just something like /searchAvailability?checkIn=202303…

Yep, pretty much this along with some guessing at the stuff that was obfuscated (mostly response structure and the meaning of some of the data).

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

#118
Nothing specific per se, but I recently retrofitted this IBM Thinkpad I bought off ebay and installed Linux Mint onto it running i3WM. I basically control the entire OS with my tiny keyboard. I have a ton of hotkeys to just map movement of everything insanely fast. Using this alongside VIM allows for very efficient usage of my machine. Highly recommend.

Aside from this, I basically just rely on things like cntrl + p for search, various bash/shell scripting + chatgpt to be efficient. Always improving!

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

#119
I have started making bash scripts for converting various backup snapshots from one tool to another. So far I've covered:

- Borg to Restic - Borg to Kopia

They work quite fine, though Restic and Kopia lack the ability to change the root directory of the backup so if your script extracts to a unique temporary directory for each snapshot then you got some confusing output about no files being cached (Kopia) even though it technically deduplicates them quite well. (I suspect Borg doesn't have that ability as well.)

Haven't published them yet but I think I will sometime this year. If somebody pings me I'm very likely to work on them a bit more and publish them though.

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

#120
I created a callbox bot using Twilio about 10 years ago. It started as something simple: when my callbox bot is called, play dial tone 9 (to signal the callbox to open the door) and then send me a text message that someone is coming up. I wasn't too worried about people abusing the system and this worked really well.

Over the years, I've made it more complex. I added a simple menu system using text-to-speech and accepting the DTMF tones for the selection. This way I could tell people to enter a secret PIN and they could provision themselves access to my lobby. If they didn't know the secret PIN, there was an option to have it patch through to my phone so I could screen the guest using normal voice and I could manually press 9 on my cell phone.

It also has an SMS interface where I can select different modes and hours of operations. So when I host a poker night, I'd txt my bot "poker" and it would it update the menu system to be Poker themed so that when guests were at the callbox they'd be greeted with poker puns. When my friend comes to visit from Austin, I'd txt "StarCraft" and he'd get to hear some dumb SC2 puns. I have 20+ different modes now for various occasions over the years. Now when people visit they get their phones out and record the greeting half-expecting something that they would want to remember or share on social media.

Sadly, my building just replaced their callbox with a newer model that does not accept secondary input. So once the call is connected to Twilio, if the user touches any button on the callbox (e.g. to enter a secret PIN), it will disconnect the call. I suppose it's now time to use some voice-to-text options to bring back the interactivity, but I suspect the lag would make the experience more frustrating than fun.

Post reply on HN