
How I Automated My Job - codingcoop
https://medium.com/dailyjs/how-i-automated-my-job-with-node-js-94bf4e423017
======
ggregoire
Almost 10 years ago, when I just started to work, I had to do a repetitive
task. Something in IIS about 30-50 subdomain bindings. I told to myself “I’m
not going to do that manually, such a waste of time, let’s write a script!”. 5
hours later, I was still working on this script and I was stuck. I asked some
help to a senior colleague and his reply was: “you know, it would have taken
you only 10 min to do it manually”. :)

~~~
dougmwne
You are so right from a business standpoint. But what about personal
development? This is one of the ways developers are born. Sure the first one
or ten attempts to automate something might be a net loss to the business, but
eventually that junior employee has leveled up their programming skills and
developed an estimating sense of when to automate and when to suck it up. It's
easy to sit at our place of knowledge and tut at the beginers but we were all
beginers once.

~~~
shostack
I'm an "early" programmer and still poking my way around various toy side
projects to learn concepts and such.

Ubuntu and Bash had been somewhat of a mystery to me previously, but I
eventually got a virtual dev environment setup and was comfortable getting in
with navigating to my Vagrant folder, then executing 'vagrant up', 'vagrant
ssh', etc. and then navigating to my project.

That comfort turned to annoyance as I realized how unnecessary those few
keystrokes were. And despite how little time they took, I found myself getting
angry at the repetition of having to enter them.

So I decided to conquer my Bash scripting fears, and wrote what many would
consider to be a trivial script to navigate to the Vagrant folder on my host
machine, boot up the VM, and then navigate to the appropriate project folder
in the VM. Along the way I learned more about aliases, and also how to pass
commands from a host to a guest machine which was one of the roadblocks I
encountered.

I now can boot up and get into my project folder with a simple three character
alias from within any directory on my host machine.

Again--any experienced developer would be able to script this in minutes most
likely. Back then it took hours. And now those are the most satisfying three
characters I type, as every time I enter them, I get reminded of the progress
I'm making and that even trivial things may be candidates for automation.

~~~
sgwae
You could still save yourself the misery of typing one or two characters if
you fix that alias.

~~~
otisfunkmeyer
you just blew my mind. im not even kidding.

~~~
Latteland
Doesn't every developer eventually alias building to 'b' or maybe 'm'? It's
like a law of nature. Or you can just rebuild automatically every time you
save a file, like js people do.

------
nbar1
I like what the guy did, but am I the only one who feels most of these "I did
x with y" articles always end up trying to sell you something? What happened
to just sharing our knowledge with each other?

~~~
k1ns
Most content on the internet is created for marketing purposes, unfortunately.
I don't have much room to talk, as I do it myself. That doesn't mean that we
don't enjoy creating the content, or sharing our knowledge with others, but it
can definitely get old being the consumer of these pieces.

~~~
paulcole
> Most content on the internet is created for marketing purposes,
> unfortunately

Why is this unfortunate?

~~~
paulie_a
Because the marketing is incredibly low quality. It's equivalent of most mail
I get. Completely ignored.

------
navd
This article goes through discussing using tjs commander library for building
node cli’s. I’m not a big fan of the library.

A recent approach I’ve been taking is just parsing args with something like
minimist or zeit/arg and then handling the commands passed in.

It leads to a lot simpler code especially for small tasks like what is
described in the parent article.

Another tip, you could also use pkg to create binaries for your new cli
application so people don’t need node installed on their machine to run them.

~~~
abritinthebay
I'm curious as to what you mean by simpler code?

Commander leads to _incredibly_ simple code (as it just sets a list of
options) combined with helpful CLI help output.

~~~
jessaustin
Some of the meaning of the code is embedded in how commander is set up, which
if one is unfamiliar with it means the code is less explicit. Explicit is
good, and there is a sense in which explicitness leads to simplicity.

~~~
navd
Exactly, it’s a lot clearer to your future self, and any other maintainers how
the application works when you aren’t adhering to a “frameworks” way of doing
something. Especially for a simple cli.

Abstractions can be good, but I feel as though something like commander is
really just an unneccessary abstraction.

I’ll take simplicity first anyday.

------
christophclarke
Link to a post on ACM Queue about the benefits and ramifications of automating
as a habit:
[https://queue.acm.org/detail.cfm?id=3197520](https://queue.acm.org/detail.cfm?id=3197520)

~~~
mbubb
Tom L is a good writer - I have gotten a lot out of his books and articles
over the years - excellent point here:

"Since February 2015, the SRE (site reliability engineering) team at Stack
Overflow has switched from a mixture of Python and Bash to Go. Even though Go
isn't a scripting language, for small programs it compiles and runs nearly as
fast as Python takes to start. At Stack Overflow we tend to prefer compiled,
type-checked languages for large programs, especially when multiple people are
collaborating, and, therefore, no one person is familiar with every line of
code. Our policy was that Bash scripts couldn't be larger than 100 lines and
Python programs couldn't be larger than 1,000 lines. Those seemed like
reasonable limits. Rewriting scripts when they grew beyond the limit, however,
was a lot of work. It was better to start in Go and avoid the conversion."

Not Golang, per se, but over time you are limited by your tools. Big bash
scripts get unwieldy. Nodejs changes underlying dependencies (coincidentally
wrestling with 4 yr old nodejs this week).

------
nurettin
Reminds me of this:

[https://www.techworm.net/2016/06/programmer-automates-job-
si...](https://www.techworm.net/2016/06/programmer-automates-job-six-years-
forgets-coding-gets-caught-fired.html)

~~~
asdfman123
That's an article summarizing a reddit comment but splits it up.

This article is slightly better as it links to the original advice thread:

[https://boingboing.net/2016/06/08/coder-fired-
after-6-years-...](https://boingboing.net/2016/06/08/coder-fired-
after-6-years-for.html)

~~~
andai
That link eventually led me to this, which is one of the most enjoyable things
I have read recently:

American Dream:
[https://github.com/bibanon/bibanon/blob/master/Stories/Ameri...](https://github.com/bibanon/bibanon/blob/master/Stories/American-
Dream.md)

~~~
sethammons
Wow, I had read a first generation of that piece a long while back. It ended
right after the call to the guy with the same job code. It has grown!

------
ufmace
What I noticed about this - I'm not thrilled right now about using node to
write console helper scripts, but the CLI lib they're using here does have a
pretty nice interface. I do like Python generally for doing scripting type
things, but there doesn't seem to be any mindshare for any cli helper libs for
it other than click, which IMO has a really clumsy, awkward interface. Ruby is
generally my favorite go-to now, and it has a bunch of cli helper libs with a
variety of types of interfaces, at least some of which have what I consider to
be a really slick interface.

If I was better at Python, I might try my hand at writing a better Python cli
lib myself. I'm surprised nobody else has yet.

~~~
mixmastamyk
Not sure what you are referring to, Py CLI libs are a dime a dozen? Not to
mention argparse has been getting better.

[https://opensource.com/article/17/5/4-practical-python-
libra...](https://opensource.com/article/17/5/4-practical-python-libraries)

~~~
ufmace
I'm interested in finding a Python CLI lib for building command suite apps.
I've written a few with Click, and its architecture seems weird and clumsy to
me. I looked at that website, and it doesn't list any command suite libs other
than Click. There's a few other CLI-related libs, but for doing stuff like
making prompts work nicely.

My usual go-to for that kind of stuff is Escort for Ruby. Everything is
defined at a place and level that makes sense IMO.

~~~
mixmastamyk
Searched for "command suite" got nothing. Searched for "ruby escort," found
services in las vegas. ;)

If you mean sub-commands like version control software has, argparse can do
it. A bit clunky, but doable.

------
ColinWright
In respect of some of the comments elsewhere saying that the person would
probably have been better off just doing the damn job, XKCD has, of course,
got there first.

[https://xkcd.com/1205/](https://xkcd.com/1205/)

[https://xkcd.com/1319/](https://xkcd.com/1319/)

I reference these regularly to keep me on track doing things that actually
matter, rather than tinkering endlessly to save me having to do things that
are less interesting, but would take less time.

~~~
conanbatt
"automate" comes from "self" and "mating".

~~~
loco5niner
Automating comes from the roots "auto-" meaning "self-", and "mating", meaning
"screwing"

FTFY

------
krmmalik
On the subject of automation, has anyone been able to do or is there even any
scope for script level automation for video post-production? I'm talking
specifically Adobe Premiere. I have to constantly do a series of the same
actions on different content assets much like re-skinning. If anyone has had
any success - I'd be interested to learn from you.

~~~
BeefySwain
I have been looking into that of late and have found that the what little
scripting options Adobe provides are woefully inadequate for anything more
than basic macros.

I have been looking at FFMPEG for automating video post-production, and
recommend you do the same.

------
chris_wot
What I want to know is - how can I automate the Google Admin interface.
Because holy crap, is it _slow_.

Yeah, I'm sure there is an API :-) I just haven't gotten around to looking
into it yet, it's one of those annoying things that never gets to the point of
seriousness, but gets a few choice words from me when I have to use Google
Admin.

~~~
gratalis
Fortunately, much of GSuite admin api functionality is nicely wrapped up in
the free / open / well maintained GAM cli -
[https://github.com/jay0lee/GAM/wiki](https://github.com/jay0lee/GAM/wiki)

------
kostarelo
I have a simple rule. If I find my self doing something for the third time,
automate it.

------
eismcc
“Never send a Human to do a Machine’s job” - Agent Smith, The Matrix.

------
nameiscubanpete
> The Bash scripts were good, but if someone was working on a Windows machine,
> they couldn’t be run

Git Bash. The only requirement is installing Git For Windows, which is an easy
install.

~~~
wmgries
Better yet, Windows Subsystem for Linux: [https://docs.microsoft.com/en-
us/windows/wsl/install-win10](https://docs.microsoft.com/en-
us/windows/wsl/install-win10)

------
holtalanm
oh look, an add pushing a book thinly veiled as an informative blog post.

how original. Saw this on reddit earlier this week, and didn't read it then,
either.

------
vgy7ujm
Perl 42

------
misterbowfinger
I honestly refer to this whenever I want to automate a task:

[https://xkcd.com/1205/](https://xkcd.com/1205/)

~~~
misterbowfinger
And also this for the lulz

[https://xkcd.com/1319/](https://xkcd.com/1319/)

