If you password protect your SSH keys (and you should) and you don’t store those passwords in your macOS keychain or Linux equivalent (slightly paranoid, but not a bad idea), you have to add keys to ssh-agent with ssh-add before using them. Otherwise, you’ll be prompted for the key’s password on each use. This always bites me when doing deploys, I get prompted multiple times as the deploy process makes multiple SSH connections.

Fortunately, there’s a simple fix.

Not long ago I shared a Bash function that takes filenames in the form of filename.rb:NNN, where NNN is a line number, opens the file in Emacs, and jumps to that line. This format is commonly used in error messages and the output of test frameworks.

However, there’s another format I run into all the time, the format Github uses in URLs when linking to a specific line number:

1
https://github.com/someorg/somerepo/blob/somebranch/app/controllers/application_controller.rb#L38

Here, the line number is in the form ‘#LNN’, which makes total sense as a URL fragment identifier. I get a lot of these URL in chat when discussing problems and I decided to add support for them to my function.

Another, macOS (Mojave), another major Emacs release, let’s get building.

Ironically, I started this post in vi. Why? I’d updated brew and a change in the ImageMagik version broke Emacs.

The complexity of this exercise waxes and wanes as the dependencies of Emacs change and as the versions of tools Apple ships get old or get updated. This time around, there is one new requirement.

Long ago I shared my EmacsClient setup. The short of it was that I always have Emacs running and set $EDITOR in such a way that things like git commit open a new frame in my existing session. I also had a simple Bash alias that let me open any file in a frame as well:

1
alias ec="$EMACSCLIENT -c -n"

Where $EMACSCLIENT is the path to emacsclient on whatever system I’m on, -c is to create a new frame for the file, and -n to tell emacsclient to exit immediately instead of waiting for me to finish editing.

This has served me well for years. However, there’s one bit of laziness I’ve been wanting to implement. Handling filenames (or file paths) that include line numbers, i.e. filename.rb:123.

If you try to build Ruby 1.9.3 using rvm install ruby-1.9.3-p551, it will barf with compiler errors. The workaround, found here, is to use:

1
rvm install ruby-1.9.3-p551 --with-gcc=gcc

You will get a warning:

Ruby ‘ruby-1.9.3-p551’ was built using clang - but it’s not (fully) supported, expect errors.

However, I have run into any errors.

Yes, 1.9.3 is not supported and, in a perfect world, I would be able to upgrade projects using it.

No, I don’t care if you hate RVM.

An update to my somewhat popular How I Start Rails Projects post. As before, I start with:

1
2
3
4
5
6
rvm use 2.4.1@project-name --create
gem install rails
rails new project-name
cd project-name
rvm use 2.4.1@project-name --ruby-version
echo '/.ruby-*' >> .gitignore

The only change is bumping Ruby to 2.4.1.

But this leads to a rant:

Ever put your Mac to sleep only to come back find it’s still awake? This happens because something is telling the power management subsystem it can’t sleep yet.

A quick one today — creating S3 Static Website Hosting redirects with the AWS CLI. Clients often want to have www.example.com redirect to example.com or vice versa. Why? Because SEO. I suspect “SEO” is smart enough recognize one site with two URLs, but hey, I just work here.

It’s easy enough to do this sort of thing in Apache or NGINX. However, if the real site is in AWS, especially CloudFront, I like the simplicity and single purposeness of using S3 Static Website hosting to for redirects.