Day 19 - Automate a repetitive action

Please spend 20 minutes automating/systematizing some action that you perform repetitively.

Here are a few ideas:

  • Create a bin/deploy script to handle any tasks that you always perform before/after deploys. (One post-deploy task I like to include: open production in my browser to make sure I didn’t just hose it somehow.)
  • Create an alias for shell commands that you type frequently (git commands are good candidates). Here are my zsh aliases for more inspiration.
  • You know that thing you do all the time that makes you think “there has to be a better way”? Dig into that and see if you’re right.
  • Find a way to save yourself some keystrokes.

In general: find something you do at least a few times a week and see if you can make it more pleasant. Think of it as sanding down the rough edges in your development environment.

I think you’ll find this one quite satisfying. When I automate an annoying task, I get a little burst of dopamine each time I use my new, improved method to accomplish it. One-time effort; continuous payoff.

Enjoy!

1 Like

The one thing I do very often is after a branch switch to compile all assets and migrate the database. So I created a git alias for that :grinning:

Now to improve the branch switching on the cli

1 Like

I just spend some time yesterday automating a diffing script for our generated Xcode projects, so I spend the time today adding a few new aliases to my terminal.

BTW, nice one :smiley:
alias herkou='heroku'

4 Likes

I decided to spend this 20 minutes cleaning up and updating the makefile. I deleted the commands that were out of date, created a few ones for the most common tasks that are not just “one command”, and automated a few mini scripts for onboarding new people (and remove complexity from the readme!)

I improved a Vim mapping to save myself some keystrokes. :+1:

1 Like

Nice one and love the way how you organised in alphabetic order.

Have added alias to

  • open the worknotes
  • open browser

and all above with alias goodmorning

So from now going to start my day by greeting the terminal goodmorning.

2 Likes

Already have build/deploy pretty much automated through jenkins/ansible/fastlane/composer commands. So I went ahead an created a few new aliases to open websites I frequently use.

For the people who use lazygit - when you highlight a branch, click o to open a browser with the pull request screen already configured for the current branch.

For the people who don’t use lazygit. Try it out. It’s really efficient and joyful to use.

2 Likes

Hey friends,

late to the party today.

So this is totally meta: Apart from developing, I publish some tips on twitter occasionally, and emacs hacking is also a guilty pleasure.

I realized I was often finding myself copying code to https://carbon.now.sh to publish it, make a gist, and so on.

So I made an elisp defun that does all that for me:

(defun jr/gist-carbon-region ()
  "Create a gist, upload to carbon and put the gist URL in the kill ring.

  This function makes it easy to tweet a marked region: Invoke it and 
  the region will be uploaded to Github, the gist ID appended to carbon,
  and the default browser opened. As a convenience, the created gist URL
  is also placed in the kill ring.

  gist mode (https://github.com/defunkt/gist.el) is required."
  (interactive)
  (setq gist-view-gist nil)
  (gist-mode t)
  (gist-region (region-beginning) (region-end))
  (let
      ((gist-url (substring-no-properties (current-kill 0))))
    (string-match "gist\\.github\\.com\\/\\(.+\\)$" (substring-no-properties gist-url))
    
    (browse-url (concat "https://carbon.now.sh/" (match-string 1 (substring-no-properties gist-url))))
    )
  (gist-mode nil))

And here’s the corresponding tweet that was made using exactly this technique :wink:

This is a favorite pastime. Be sure to mind the time box though! :wink:

Main tasks are pretty much automated. But something can be improved. I wanted to learn more about terminal shortcuts. I use CTRL-W extensively to remove whole previous word. But there are more handy shortcuts out there: 13 Linux Terminal Shortcuts Every Power Linux User Must Know

Created some extra aliases for switching between project folders and common command like yarn hot :ok_hand:

Moved new commands from the readme of one repository into a Makefile we already used. It became more clear with recently joined team members that this is a valuable improvement :+1:

Automating using doit
Most of our python projects are quite well automated. Mostly i use pydoit for it - single dodo.py in the root denotes, everyone shall try to call $ doit list or even $ doit list --all to learn about subcommands available.

Automating using invoke
In recent months we use invoke utility (one finds a file tasks.py in project root).

Today I decided to automate uploading of our static website to SFTP server. All preparation went very well until I realized, that the project is written in (now obsolete) python 2.7 and despite the fact the libraries declare 2.7 compatibility, it did now work. I gave up.

The best automation: run a test from neovim editor
As I am using neovim editor, I have installed some plugin, which allows me to put cursor somewhere within test case in my code and press ,t to run it (there are other shortucts to run tests in a file and in the tests suite)

I got so used to this very efficient way of calling a test, that I reject to work in any other IDE, where such quick feature is missing.

Most tasks are pretty much automated by this point, so I spent some time today polishing rails generator for a typical development task we have

It’s funny, there are a couple of routine steps I go through like merging the develop branch onto staging and switching straight back to the develop branch that I have just got so used to doing. It’s always been in the back of my mind that I should alias it… It’s done now.

1 Like

aliases for heroku commands from your dotfiles were inspiring, made one which I always had to check the docs for again and again since i don’t use it that often. should try and remember now though that i’ve a new alias for it :smiley:

1 Like

I wanted learn more about shortcut terminals on Windows, so that I’ve spent my 20 mins reading this article Windows command prompt Keyboard shortcuts - Windows CMD - SS64.com and experimenting.

1 Like

Stole without shame from other developers on my team.
alias g.trimd=“git branch --merged develop | grep -v ‘^[ *]*develop$’ | xargs git branch -d”
alias g.trimm=“git branch --merged master | grep -v ‘^[ *]*master$’ | xargs git branch -d”
alias g.trimmm=“git branch --merged main | grep -v ‘^[ *]*main$’ | xargs git branch -d”

Took 20 minutes to setup a script to report on disk space remaining on our staging and production setups. Not quite, my development environment, but it has been on my mind to to rather than wait for the ticket to come around.