Vagrant Box With This Name Already Exists

Due to the unique approach of Canonical to packaging vagrant boxes, the current ubuntu/xenial box has a hardcoded machine name which causes an error when you try to bring up a second VM using the same base box:

A VirtualBox machine with the name 'ubuntu-xenial-16.04-cloudimg' already exists.
Please use another name or delete the machine with the existing name, and try again.

There’s a stackoverflow question about this and a good answer (not the accepted one, the highest-voted one) which helped me a bit but it still wasn’t completely clear to me how to fix my problem and I had to dig about a bit. Continue reading

Heroku “No app specified”

I’ve been having a maddening problem where one (but only one) of my heroku apps doesn’t know which heroku app it is, which means I need to append --app app-name to every single command. It seemed to happen when I moved my app to an organisation rather than having it on my personal account, but in fact the problem was that at the same time I did that, I set up the build server to deploy it – and so I removed the old heroku git remote and then never added the new one because I exactly shouldn’t be pushing to heroku from my laptop as we now deploy via Jenkins.

I was looking for some config file or something that heroku would read but what it actually does is look at whether any of your git remotes are heroku and if so, assume by default that you mean that project! The git URL is on the “Settings” screen from the Heroku web interface, and you just need to add it as a remote to your local project:

git remote add heroku [paste git url from settings screen]

Hopefully this helps someone else stop having to type --app app-name every time they need to do something with their app, it was a tiny problem but quite an annoying one!

MySQL 5.7 Introduces a JSON Data Type

There’s a new JSON data type available in MySQL 5.7 that I’ve been playing with. I wanted to share some examples of when it’s useful to have JSON data in your MySQL database and how to work with the new data types (not least so I can refer back to them later!)

MySQL isn’t the first database to offer JSON storage; the document databases (such as MongoDB, CouchDB) work on a JSON or JSON-ish basis by design, and other platforms including PostgreSQL, Oracle and SQL Server also have varying degress of JSON support. With such wide adoption as MySQL has, the JSON features are now reaching a new tribe of developers. Continue reading

Documentation First: A Recipe for API Success

I’ve shipped a handful of greenfield APIs in recent months for different clients, and in each case I’ve been building the documentation before the API. I hadn’t really recognised it as a pattern until someone else commented on it, but I do find this approach has worked well for my projects, so I thought I’d share my thoughts on this in a bit more detail. Continue reading

Use Ngrok for Testing APIs on Dev

Recently I was hastily building an API for a client and I wanted to run some tests against it. I’ve written before about using Runscope for API testing, but this was against a local dev platform (inside a VM, not directly on my laptop) rather than a public API. The same problem arises if you want to access a local site or API from elsewhere or from a mobile device. In all these scenarios, ngrok is your friend. Continue reading

API Testing with Runscope

I work with a lot of APIs and I really appreciate good tools. Lately I’ve been really enjoying using Runscope for testing and monitoring my APIs so I thought I’d share how I work with this tool, which has a great one-person free tier *and* the ability to import/export tests so if you need to work with a team with just the free tier (the examples here are from an open source project which is an obvious use case where it’s hard to fund tools), it’s clunky but doable. The idea here is just to show you around how to create your own API tests with Runscope (and also to write down what I did so I can point both my future self and others at this!) Continue reading

Git Won’t Check Out A Path It Autocompleted

One of my git repositories has developed a tendency to refuse to checkout a feature branch locally that exists on the remote repo. My git bash completion works, but then strange things happen! It turned out to be that I had two remotes with the same refspec, so I thought I’d write down the behaviour I saw and hopefully help someone else to fix this problem faster if they see it. Continue reading

Why My Open Source Project Needs a Code of Conduct

I’m an open source project maintainer, working on the projects associated with joind.in, and recently we added a Code of Conduct to all our projects (we have quite a few as you can see from our github organisation page https://github.com/joindin).

I feel the same way about codes of conduct for open source projects as I do about codes of conduct for events. You can absolutely run a totally safe and effective event without one, but by having one you make very clear what your expectations are – and in turn this manages the expectations of the people attending that event. Continue reading

Ada Lovelace Day: The Allies

It’s Ada Lovelace day, a day when we celebrate women in technology. This year I’d like to mention a group of people who make the biggest difference in the tech life of any minority: the allies. Continue reading

Git Pull Causes a Merge

If you type git pull and expect a fast-forward update, but get a merge instead, don’t panic! This usually happens when we’re collaborating on a branch with other people, and we’ve made changes on our local version of a branch, and someone else (or the other you, if you use git to sync between multiple dev platforms) has made changes to the remote version of a branch in the meantime. It also happens really frequently in teams where all commits are to the master branch … yet another reason to have a decent branching strategy.

All that’s happened is something like this:

$ git log --oneline --all --graph --decorate
* 054f163 (HEAD, branch1) Installation instructions for the application
| * 0ce808c (origin/branch1) Fixing template layout
|/  
* 927aad9 A random change of 731 to ideas2.txt

Since the last common commit, there are commits on your local branch, and the remote one. You could just let the merge go ahead but there are other options. You could also check out a new branch at this point, reset your tracking branch to the right place and then reapply your changes using cherry-pick or by rebasing and then fast-forward merging your branch. Continue reading