Ask HN: Which scripts are you most glad you've written?

12 points by christinac ↗ HN
For personal things, side projects, or work -- which tasks have you automated or scripted and now wouldn't want to deal with manually?

11 comments

[ 3.5 ms ] story [ 32.9 ms ] thread
Definitely not the alarm for the next morning that took me half the night learning bash and fixing the alarm script. It looked awesome, though if I say so myself.
While I don't like Windows much and dual boot it mainly out of necessity, it was pretty easy to whip up a trigger (in the GUI task scheduler) for a script to trigger alarm music even when the computer was sleeping.

The procedure goes something along the lines of "RTC trigger wakes up sleeping computer, computer waits to connect to network, opens spotify url of playlist." It lets me turn off the LED and fan nightmare that is my desktop and still use it as an alarm.

I'm not even sure how to access that in debian, nvm i didn't try to fix the apc issues, yet. I'm sure there's a command already, anyhow.
1. Recurring billing and dunning.

Subscription renewals are a little script that runs daily. If the charge is declined, a mail gets sent and a date for the next reattempt is set in the database for when the script should try again.

A series of charge attempts and mails go out on a schedule asking the customer to update their payment information or get in touch. The mails are all prewritten, and at least 75% of subscriptions are recovered through this automated process.

It saves time, I don't have to handle following up on declined charges myself (which I hate to do manually), and it's worth six figures a year compared to just letting subscriptions lapse because of one declined charge.

2. Off-site backups and code that validates they're complete and restore-able. It's peace of mind. No server runs forever; you will eventually need that backup.

A script to open all the files I need open, on the appropriate workspaces, for each of the projects I'm currently working on. It feels so slow to do that manually, and it's still satisfying watching all those files open themselves on various workspaces.
I use tmuxinator in a similar fashion.

Starts my vim instance, bash prompt, sources virtualenv, server instances, and console/repl.

I start-up in about 5 seconds.

A Bash script to monitor OpenERP server, restart it if it has been killed by some other process. Note: OpenERP server used to stop working after 15 to 20 hours automatically. Thanks
A Perl script that parses a Progress ABL(1) source file "A" and spit out a new Progress ABL program that would correctly declare all the input and output variables of "A" and invoke it.

(At the time we had to deal with "stored procedures" with tens of input and output parameters, and testing these was a time-consuming and error prone problem, people would save invoking scripts, running them to find what had changed in the parameters list and manually update them).

(1) A 4GL proprietary language. Just think of PL/SQL with the practical parts surgically removed.

Hourly emails when disc is almost full (absolute and relative) and later automatic cleanup of old files on production servers. Saved me trouble countless times.
A visio/VBA script to parse a Tivoli Maestro job configuration file and create a flow chart of the dependencies of each batch job. I was asked to manually document this and would have spent months documenting the hundreds of jobs. Also, the jobs changed on a frequent basis.