Don't spend 6mins doing it by hand when you can spend 6h failing to automate it
twitter.com
twitter.com
Maybe it saves me time, and maybe it doesn't. Perhaps it makes tasks more repeatable. Mostly it makes me less likely to drop out and switch to a career in beach combing.
If you really have written the same code many times, you might be able to get away with a search-and-replace approach, and with a little luck everything you break will get caught by a compiler. But the more different ways you wrote it, the more likely you are to make things worse.
Learning a refactoring toolkit might be a fun project, but it may well take more than just a few hours. Code-that-writes-code is pretty tricky.
As you say, the alternative is also risky. So getting it right may be worth the effort. But in a lot of cases, it will be quite a bit of effort.
There's also the angle of keeping your eye in with other languages, e.g learning or keeping your python skills up to date if you need to do a quick bit of scripting to automate a task (and you don't usually use python).
I posit there is a hackerish view of sailing, especially bigger boats. Complex systems with a lot of dependencies, and eg the weather gods to contend with.
Enjoy your courses. I'm envious.
There's one script I wrote to partially automate posting podcasts. (I really should add a couple of additional steps.) It's almost certainly saved me time over time. But it also automates a fiddly process that's very easy to get something wrong if I do it by hand.
https://blog.danslimmon.com/2019/07/15/do-nothing-scripting-...
"Oh shit, this is taking longer than I thought -- so I'm just going to have to park it in a semi-finished state, and get back to it later. Grand, now I have two problems."
place.
Alternatively, you could replicate those errors at scale....
Do it by hand at least once or twice before trying to automate it.
Doing it by hand often teaches unexpected lessons and can shorten the automation effort.
I have seen far too often the jump from never done a thing to preparing to do a thing a million times a day.
But I am deeply lazy. My father made me count fish hooks by hand from bulk into those dozen boxes for his fishing tackle wholesale business. I was, maybe 8? Couple of cents per box. Couldn't stand it. So I eyeballed batch sizes, and made mistakes. Should've weighed them. Boy did he get mad. But nope, no way I was going to count every one of those little hooks.
That's the way I feel about the repetitive parts of ops. It takes a while to figure out the repetitive bits though, and abstract those correctly.
The end result though, is beautiful. It's cleaner, more precise, more technically correct, and more consistent than what I was producing before. It makes what was already one of the most profitable parts of my business even more profitable. One of the big side benefits is I gained a lot more knowledge in the process that I've already been able to apply in other contexts.
So... it can be really painful and time-consuming to automate, but there are more benefits than just the future time savings.
This task tracker worked fine for a period of time, until the list of Jobs exploded. The company added dozens of different types of tasks people could do, correlating to different products that had different delivery dates. Every person in the department had to be aware of every kind of sub-task they would be responsible for, and they had to manually subscribe to that sub-task or work would get lost. People spent a large amount of time every day selecting and un-selecting tasks just so they could view a focused list of todos, especially anyone in a shared role like Admins, or Lead Designer (who would also complete Design QA steps for other designers).
Having to do this multiple times a day really irritated me. I didn't have access to the codebase and management wasn't whitelisting any extra development, so I hacked around the problem. I discovered that sub-task subscriptions were stored in a cookie on the users' machine, so I built a JS Bookmarklet that would read your cookie and help you create a new bookmarklet you could save to your bookmarks bar. This new bookmarklet would automatically navigate you to the task tracker, switch out your list of subscribed sub-tasks, and reload the page. I made a simple HTML help page instructing users how to use the tool, and I provided a basic set of pre-baked bookmarklets to get people started. Simple stuff like, "Website Development Approvals" or "Templates Ready for Build" or "Work Order ready for Design".
This automation _exploded_. I instantly saved 20 minutes a day across 20+ people. But more importantly, this simple bit of code introduced and formalized the idea of a "Role Queue" at the company. Business Admins had confidence they weren't missing work items, because they all collaborated on maintaining an authoritative set of bookmarklets for their work. Same for Designers, QA, Developers, etc. This in turn changed how the departments were run. People could work off the "same" queues, tag team work, and make group decisions on priority.
Where before everyone saw a slightly different lists of work and felt different levels of stress, now there was consensus between coworkers. I saved thousands of man-hours, and really smoothed out the path to production for a new product, all because at its core, I resented having to do such a stupid task like "just click these boxes and uncheck these and save" just to go from viewing "Ad buildout" to "Website buildout"
Funny thing, the company is still using my bookmarklet code. Every now and then I get a text from an old friend or two working there laughing about the code comments I put into my core bookmarklet builder.
/**
* BetterQueues by Titus Johnson
* This is hack to make it easier to view work queues
* If you're reading this and this code is still in use, you need to get a better job
*/You’ve made my day.
The first time I used awk I struggled and probably took way longer than necessary, but the second time a similar task (process a bunch of columnar data and extract certain values) took no time.
Worth it.
Check this out, spaced repetition for learning how to code: https://www.youtube.com/watch?v=kshXDo8psj8
Essentially, every time you encounter friction with something you write it down in Anki.
Anki then takes care of presenting the information to you based on how well you're able to recall.
After confusing Array.prototype.slice() and Array.prototype.splice() one too many times, I finally added it to Anki. I don't confuse them anymore.
Couple weeks later after learning python, okay those take 5 minutes of human time to run. I made it a point to always automate regardless of time saved/wasted.
Paid off big for my career.
An example: Adding chamfers to cutting boards. Sure, this could be done with a 45 degree bit in the CNC, but any deviation in board width/height/thickness means reprogramming the machine, and you can chamfer with a palm router in the time it takes just to affix the board to the CNC.
One thing that helped me was to invest in building simple libraries and tools that I would commonly use to make the automation faster. One such one was a script (called super-script) that would build the skeleton of another script, prompting for all the command-line parameters that I needed for the script and including all the command-line code that would convert the parameters into an easy to access data structure. This script would also prompt for help text for the params and create code to print that out when `--help` was fed into the output script.
This did two things:
1. made the new script easier to write
2. made the new script *MUCH* easier to share
By getting #2, the payback for automation was way way faster. It might take a year for payback if only I used my script, but it might take only days if 30 or 40 of my colleagues also used it.But hey, it passes CI so who's gonna know?
It's all about maximizing downtime.
A computer does not have curse of knowledge, and is much less likely to change its behavior (forget to execute a line of code, or run a command it was not instructed to do) in the long run.
"We down bad here too?"
Looks pretty legit...
But it becomes a massive load of configuration, and I've had to rewrite from scratch three times.
When you have even just preprod and prod, it can be hard to get the savings, but once you have infrastructure copies in four or five different environments and five or six AWS regions, then things start to really pay off.
My "tool" tries to abstract the means of forming a set of infrastructure, the means for delivering commands to it (ssh, AWS ssm, kubectl, dockerrun, or other means), tries to abstract the clouds to do multicloud (but I've never tested this). Man is it hard to do all that. Config config config, context context context.
But it pays off eventually. Someday I might get the time to open source it, probably when the current job kicks me to the curb and no one has a use for it but me. I won't try to say it would be useful to others though.
That's the kicker on complex automation, with Conway's law in the mix, it is very hard to see what hidden dependcies/hardcodes there are based on your stack, software, team/company, policies, etc. To abstract that is such a mound of configuration it almost starts to collapse upon itself.
It took me three years before I could fully automate a cassandra cluster in multiple regions, data loads, spawn loadtests, run them, and tear it all down in near pushbutton. But man do you get more powerful when you can script stuff like this. Woe be to them that has to try to parse them apart.
I've taken to writing a sort of "workflow engine" that is based on filesystems and subdirectories, so I organize the code into individual scripts I can run together, or I can run it on a parent directory and go "run all these scripts as a workflow". So now I almost have an adhoc workflow engine, which is probably a "any sufficiently advanced code has a bad LISP engine in it" joke almost.
The issue is no one makes a general thing like this I can see. Ansible is tied up in ssh, saltstack relies on their UDP delivery. Most things like those two have bolt-on for k8s but it is hokey.
I do think the "COMMAND LINE" is the most universal standard of automation, but I think it's a bit underappreciated.
The problem is most of the "I automate everything" people seem to use handwritten bash scripts for everything, instead of purpose built tools for whatever it is, even when those tools exist.
Just think of all the features that Kubernetes do, they all used to be some ghetto scripts here and there. Another good example is Airflow.