
Writing a personal automation API - rbanffy
https://dev.to/anotherdevblog/every-developer-should-write-a-personal-automation-api
======
jefflombardjr
Laziness ftw! -> [http://threevirtues.com/](http://threevirtues.com/)

Really not trying to self-promote, but genuinely interested in laziness as a
quality of great developers. I talked about it at a javascript meetup
[https://www.youtube.com/watch?v=JuqVmhJ4tDA](https://www.youtube.com/watch?v=JuqVmhJ4tDA)
(Ignore the David Foster Wallace hair, the math error. Security folks don't
worry that address is not valid).

I bought up lzy.io and wanted to make a lazy manifesto, but I don't think we
need any more manifestos, So I just collected some examples of programmers
taking laziness to new levels good and bad!

~~~
amelius
Funny that you mention laziness, because most programmers I know work harder
and are under more stress than most other people.

~~~
jefflombardjr
Hence the title "Working Hard to be Lazy"...

Here's a basic programming example say you're writing some front end
javascript to make a call to another site's api... if you have to do it once,
you probably will set the headers, and make the call right? Well if you have
to do it three or more times, it pays to be lazy and write some sort of
function to wrap the fetch call and automatically set the headers for you each
time.

This is the laziness that I'm advocating. It's not about people that don't put
effort in, it's about maximizing efficiency and taking processes approach. In
many cases truly lazy people will work twice as hard now to avoid work in the
future.

~~~
hamandcheese
I know lazy developers. They would just copy and paste the api call three
times. And if the api call really only needs to happen three times they might
be lauded for taking a pragmatic approach rather than over engineering.

~~~
jefflombardjr
[https://en.wikipedia.org/wiki/Rule_of_three_(computer_progra...](https://en.wikipedia.org/wiki/Rule_of_three_\(computer_programming\))

Totally agree that if you are only doing something exactly three times,
probably not worth it. That being said when was the last time you were
absolutely sure the requirements won’t change? Only the Sith deal in
absolutes.

~~~
swsieber
Has anybody else noticed that "Only Sith deal in absolutes" is an absolute?
Genuinely curious if it's just so obvious that it's never talked about, or if
people just don't stop to think abouy it...

(I mean, it's a pretty good piece of advice... we just never talk about the
irony)

~~~
khedoros1
> Has anybody else noticed that "Only Sith deal in absolutes" is an absolute?
> Genuinely curious if it's just so obvious that it's never talked about, or
> if people just don't stop to think abouy it...

I think you're just not usually around the people who talk about it. Here are
some example image macros.

[http://img.memecdn.com/only-sith-deals-an-
absolutes_fb_51269...](http://img.memecdn.com/only-sith-deals-an-
absolutes_fb_512697.jpg)

[https://img.memecdn.com/who-amp-039-s-really-on-the-dark-
sid...](https://img.memecdn.com/who-amp-039-s-really-on-the-dark-
side_fb_6700751.jpg)

[https://i.pinimg.com/originals/d9/32/8c/d9328c625f6f47e8d8a9...](https://i.pinimg.com/originals/d9/32/8c/d9328c625f6f47e8d8a99be102a56415.jpg)

[https://pics.me.me/only-a-sith-deals-in-absolutes-that-
itsel...](https://pics.me.me/only-a-sith-deals-in-absolutes-that-itself-is-
an-20291123.png)

[https://pics.onsizzle.com/whats-wrong-obi-wan-kenobi-
tells-a...](https://pics.onsizzle.com/whats-wrong-obi-wan-kenobi-tells-anakin-
that-only-sith-7661489.png)

------
wgj
Maybe I just tried it at the wrong time, but several years ago I tried IFTTT
for a few weeks. Events frequently fired late or not at all. It seemed useless
in a situation where you needed some confidence in the timeliness or
consistency of events.

Does anyone use IFTTT heavily and have a better experience? Are you able to
rely on it?

~~~
spikej
I moved to a self-hosted Huginn instance instead for the very same reasons...
(and the fact that it doesn't allow for any granular control)

------
DarkCrusader2
Off-topic but every time I open their site I am blown away by how fast their
pages load. It's an absolute delight to navigate their blog.

~~~
cvsh
Pretty annoying, though, that they hijack users' familiarity with the red dot
to deliver the useless notification that "You are not logged in on this
device".

~~~
mtpn
It's essentially an ad that gets you to click it by making you think you are
somehow logged in on a site you don't have an account on. I emailed them about
this because I think it's an awful pattern, and did get a response but not one
that indicated they understood the problem with this deceptive marketing
technique. It makes me avoid clicking links to dev.to.

------
raldu
Although a fun activity, do not set high expectations out of personal
automation. I think the quoted XKCD [1] (also [2]) strip illustrates the glory
and peril of personal automation enough.

Automation makes most sense in the true context where it belongs, "business."
Automating a complicated e-mail marketing process with targeting, statistics
and all makes sense because you need tens of thousands of instances of that
process to be executed to create business value.

Except for rare idiosyncratic use cases, spending time in personal automation
is more of a hobbyist and educational activity. Further, if the use case is
not "that" rare, there is almost always "an app for that" anyway. Therefore,
have no high expectations out of that.

With that disclaimer in mind, if you are into it, check out the open-source
project Huginn [3] that can "Create agents that monitor and act on your
behalf." for personal automation. Lastly, the industry standard of cloud API
integration currently might be Zapier [4], which has more integrations,
(business) battle-tested features compared to end-user oriented IFTTT.

\----

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

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

3: [https://github.com/huginn/huginn](https://github.com/huginn/huginn)

4: [https://zapier.com](https://zapier.com)

~~~
gt_
The comic strip was tough to swallow for me, having spent the last few months
automating configuration of my Windows workstation setup I use for 3D/VR. I
was doing freelance jobs and had my workstation collapse a few times during
aggressive deadline sprints so I figured I would automate the rebuild so that
reinstalling the OS becomes more of a Plan A than a Plan B.

Why am I posting this here? I am honestly on the fence about whether this has
been a good use of my time. It took longer than expected and I had to use
Powershell for some of it, which was just dreadful. It _was_ ‘for business’
but I am still not sure it was a great call. Has anyone else out there found
themselves automating something like this? Was it worth it?

~~~
barrkel
Automating something usually involves a risk from predicting the future: the
cost of automation is amortized over the number of repetitions, but you don't
always repeat everything.

It's generally cheaper to automate something if you can perform it on a
command line. With command history, it's easy enough to copy the commands and
turn them into a script with appropriate parameterization.

It doesn't help you a great deal with Windows if you've been doing everything
with GUIs. But Powershell itself is an investment that can pay off. If you can
automate more everyday tasks, the pain of learning is amortized away.

I generally stick with the Unix-like shell that Cygwin gives me, and use the
same commands and idioms on as I do on Linux and on Mac, on the very few
occasions I use a Mac.

~~~
gt_
My setup script starts by making a backup of the registry, then configuring
Python. I use Python for most of the rest and Powershell only where necessary.
Contrary to what my comment may suggest, I am actually a software minimalist.
A large part of my setup involves removing clutter from the desktop
environment. I have avoided cygwin partially just so I'm not scared of native
windows command line, which I find not quite as bad as Powershell to work
with, but more limited in interacting with the OS of course. I am familiar
with basic linux Bash already and that's what I'm comparing all of this to.
Maybe now is a good time to adopt cygwin because, well, better late than
never.

~~~
barrkel
Getting Cygwin set up right takes a little bit of work - it's much easier if
you're familiar with configuring a Linux shell and terminal to taste. Out of
the box, it's a bit rough; kind of similar to how Emacs is a bit rough.

I am scared of the Windows command line - not because it's scary, but because
it's so limited. I feel almost helpless, all my tools are missing, it's just
so awful.

In practice, the reason I use Windows is mostly games, but it's rare I fire
them up these days - I have to upgrade and/or re-verify my Steam account
almost every time I start the client. Outside of that the browser and the
terminal are almost all I use, and I can have them just as easily elsewhere.

My point being my experience may not translate to your environment quite as
well.

Registry in Cygwin is mounted under /proc/registry:

    
    
        ~$ ls -l /proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
        total 0
        dr-xr-x--- 72 SYSTEM  SYSTEM 0 Dec 16 23:57  CurrentVersion
        dr-xr-x---  2 SYSTEM  SYSTEM 0 Dec 13 01:58  DWM
        dr-xr-x---  4 SYSTEM  SYSTEM 0 Dec 13 01:48  PrivacySettingsBeforeCreatorsUpdate
        dr-xr-x---  6 SYSTEM  SYSTEM 0 Dec 13 01:52  Shell
        dr-xr-x---  4 SYSTEM  SYSTEM 0 Dec 13 01:47  TabletPC
        dr-xr-x---  3 SYSTEM  SYSTEM 0 Dec 13 01:47 'Windows Error Reporting'
        dr-xr-----  3 barrkel None   0 Dec 13 01:58  Winlogon
    

It's read-only however. Cygwin `regtool` lets you poke values in.

------
apearson
Instead of IFTTT, I've been using node-red for my automation needs. Really
enjoying it.

~~~
aryehof
I also use node-red for my automation needs very successfully. I found IFTTT
to be unreliable and limited for my purposes, and node-red has also filled the
void left by the closure of Yahoo Pipes.

------
jungletime
Significant portion of my days (maybe 30%) is doing repetitive things I do
every day. So really thinking about how to improve, automate, or save a few
minutes during the morning or evening routine would pay off greatly.

When I think of personal automation api. It would be to help me with my
routines

1\. Shower 2\. Shave 3\. Brush teeth. 4\. Check email 5\. Plan my day 4\. Make
breakfast 5\. Exercise 6\. Sleep

Any of the above could be optimized to be excellent.

For example playing my favorite podcast automatically while I go to the
bathroom would be nice. But knowing/using the best shampoo, soap, or
toothpaste is also of great value. Same with what breakfast to prepare/eat. Or
the gym/workout routine to follow. Technology might help a little, but some
active thinking about what and how to optimize is needed.

~~~
T2_t2
Right click -> Sort Room/Desk/Bookshelf/Bathroom is the feature I want for
life.

------
k__
I never understood IFTTT.

Every person I asked used it to sync some stuff from A to B, never heard
something interesting...

~~~
anon151516888
It's a gimmick, and gimped when it comes to what you really want to do. E.g.
each integration "thing" is superficial and you can't script most of it.
You're locked into their crappy UI and "endpoint" data.

You're better off renting a entire VPS and creating code that polls all your
data sources and create your own task pipeline.

------
paultopia
I'm thinking of doing this to better enable work from an iPad. Mostly in terms
of things like having push button access to command line tools via api,
everything from compilers to pandoc. But the real sticking point is that
there's no universal easy way to actually get a file attached to a http
request with iOS sandboxing---the best I can come up with is emailing
everything in and building the api around reading subject lines. Which seems a
little... hassle-full?

~~~
detaro
On Android there's a bunch of apps which will register as a share target and
let you configure a bunch of HTTP endpoints of your choosing to send it to, I
would be surprised if there isn't an iOS equivalent?

~~~
paultopia
Hmmmm.... I wonder if there's a way to do this with pythonista. It does have a
share sheet module. Combine that with the base64 point below...

------
kilon
For me the hard part is finding what to automate. Automation is not only about
saving time but taking away the annoying stuff as well making your efforts
more efficient. There is no silly graph to predict how valuable an automation
will be. Python started as a simple bash like scripting language and nowadays
it grown to epic proportions. Automation needs time to mature. People tend to
overestimate the value of their time vs the value of automation. Even the
language we speak took thousands of years to develop, talking about huge waste
of time. But hey someone has to push human progress forward.

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

------
abhiyerra
I use Zapier for this since you can inject code via Python between tasks if
needed. Also filters and such. IFTTT is great for consumer stuff but not
having multisteps has been annoying.

------
Tehchops
Author cites the all too relevant XKCD with regards to "automating things".

Curious to hear if anyone else is making IFTTT work for them on a daily basis.
My initial experience with IFTTT was buggy, tasks would fire inconsistently,
with no clear way to debug.

~~~
eastendguy
Not me (but also curious to hear!).

I tried it but never understood the value they provide for users with basic
programming and scripting knowledge.

I either use the API directly, or, if not available or I only need some quick
and dirty solution, resort to web browser automation tools like Kantu.

~~~
newfoundglory
Why would I bother doing that instead of just using an existing recipe? The
benefit is laziness.

~~~
mathgeek
Because the existing recipes are one-size-fits-all. If you need an sort of
customization, you end up rolling your own anyway. Many of us started coding
for that kind.of reason to begin with.

~~~
newfoundglory
Well, yea. But ignoring the existence of the recipes that you do need just
because you want a custom one for something else is silly.

------
agumonkey
I'm still unable to use cron properly. i'm too lo-tech for this

