Are you bored with your normal job – doing the same task again & again? have you ever thought of writing some scripts to automate daily tasks? well, it seems either you are lazy nor not a smart guy. sorry if I am rude :p This is the story of a badass programmer who will teach you how to do everyday tasks on automation, this also includes sending messages to your wife? Before that Let me give a brief introduction on how our lives are!
Introducing the So-called ‘Life’
Though most people proceed with their monotonous lives, doing certain monotonous tasks every day, and though not being exactly content with what they’re doing; computers provide an escape route. Computers were made by man to do these monotonous jobs. Now that we have computers everywhere cough watches cough and enough automation tools like IFTTT, there are some jobs which require a more… human touch.
The Main Story – Automate Daily Tasks
An employee posted this on a Russian bash.org, detailing about the scripts written by their build engineer, who left their company. Scripts are basically just a list of commands to be executed by a computer. If anything requires running a lot of repetitive commands, you could simply write it as a script; which is exactly what the build engineer did.
He was a guy who liked to literally live in the terminal (viz. uses a command line interface). He used vim, a very popular (but very hard) command line text editor, was using the DOT language to create diagrams, and wrote wiki posts in markdown (a lightweight markup language like HTML). If anything required more than 1.5 minutes of his time, he’d write a script to automate it. Given below, are some of the scripts he wrote. You’re gonna love this.
Scripts he wrote –
- smack-my-b*tch-up.sh: Sends his wife a text message saying that he’s stuck at work, along with a random reason selected from a list of reasons. This is added to cron (a time-based job scheduler) which runs after 9 pm, *if* there’s an active ssh session on his system, viz. he’s still working.
- Kumar-asshole.sh: Looks at his mailbox for emails from a person called “Kumar” and looks for keywords like “help”, “trouble”, “sorry” etc. If the keywords are found – the script connects into Kumar’s server and restores his database to the previous backup. It also goes on to send a reply: “no worries mate, be careful next time”.
- hangover.sh: another cronjob that is set to specific dates. This would send an automatic email like “not feeling well/gonna work from home” etc., and adds a random “reason” from another predefined array of strings. This would run if there are no active sessions (viz. he isn’t logged in) on his computer by 8:45 am.
- f*ckingcoffee.sh: *taking the oscar of scripts* This waits exactly 17 seconds (!), then opens an SSH session to their coffee machine (which surprisingly, was on the network, running Linux and sshd!) and sends some weird gibberish to it which looks like binary commands. It turns out that this makes the coffee machine to start brewing a mid-sized half-caf latte and waits for another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from his desk.
Now that; we call a hacker.
If you are wishing to accomplish similar goals, Github user NARKOZ, has written a proof-of-concept for these scripts here, in ruby, and python, which might interest you; if you have similar goals in mind.
The next time you’re facing monotony; learn to write scripts like this guy *wink*.