I’ve been using ngrok on quite a few projects lately. I’ve written about it before, but in short, it solves to problems for me.

  1. It tunnels back to localhost from a hostname that live on the net, allowing me to develop for webhooks that would barf on http://localhost:3000
  2. It provides a valid SSL cert. More and more the platforms I build apps for require HTTPS when talking to an app.

The downside is that it adds another moving part to the process. I’m too lazy for that, let’s automate it!

Everyone has their patterns, here’s mine for starting a new Rails project:

rvm use 2.3.1@project-name --create
gem install rails
rails new project-name
cd project-name
rvm use 2.3.1@project-name --ruby-version
echo '/.ruby-*' >> .gitignore

I was recently shown the Best. Chrome. Extension. Ever.

JSONView is a Chrome extension that formats JSON when opened in Chrome. Normally when you hit a URL that returns JSON, Chrome displays a pile of goo. Actually, it just display the JSON as is, but most rendered JSON is not well formatted (and doesn’t need to be, it’s not intended for humans).

JSONView cleans up the formatting and applies syntax highlighting. Better still, it displays any errors it finds while parsing the JSON. If you are developing an API that sends JSON, it’s a great way to make sure what you are sending is valid and, when it’s not, to debug the problem.

It seems like everyone knew about this before me, but if you don’t, you just might want to add your tool box.

Recently (I seem to start a lot of posts with “Recently”), I was on the road needed to access a server that was behind a firewall. There was no VPN and access was limited to a small set of IPs. I could however access another server in that set of IPs. That would let me bounce through for SSH access, but really I needed access from my laptop.

rsync will happy copy files between servers and will keep the ownership and permissions the same. However, if you aren’t the owner of all of the files then ownership sync requires the rsync on the receiving end (which we’ll call server B) to be running as root. Likewise on the sending server (server A) if we don’t own the files we might not be able to read them and again need to be running as root.

root on server A is easy, we can just use sudo:

sudo rsync -av /var/www server-b.example:/var

root on server B requires a little more finesse, we need to override the remote rsync command to include sudo, this is done with the --rsync-path path option:

sudo rsync -av --rsync-path="/usr/bin/sudo /usr/bin/rsync" /var/www server-b.example:/var

(This presumes you can run sudo without a password on server B, things get a little hairy if you can’t.)

Great. Done. But, what if you can’t log into server B with a password?

I’m embarking on a long, long over due project to organize my dotfiles, you know, all those files in your home directory that start with “.” and configure your software. (If you don’t then this isn’t the post or the blog for you.)

There are lots of schemes for storing and distributing dotfiles, and I’ll get to that. But first, I need to clean up the mess of living in the UNIX shell for 30 years. Really.

My goals are twofold: 1) Any time I spin up a new server, I want to be able to deploy my preferred configuration out to it. 2) I want a complete copy of my local machine’s config setting to make it (relatively) simple to setup on a new machine.

These goals conflict.

In my occasional series on waiting for things, I setup a BASH function to wait for AWS CloudFront invalidations. I mentioned it would be possible to invalid and wait in the same function, but was feeling lazy and left it to the reader. Well, I’ve gotten tired of the two step process, so I’m being industrious so I can be lazy.