Developing software in the Real World

Using ngrok to test on a mobile

To test a website that you're developing on your local computer on a mobile device such as a phone or tablet use ngrok. This is the way to do it: Start up ngrok: $ ngrok http my-dev-site.local:80 This will start up ngrok and give you a "Forwarding" URL such as In this case, it will direct all traffic to that URL to http://my-dev-site.local. If you run your website on a different port, such as… continue reading.

Hide the ST3 sidebar automatically

As a mostly keyboard user, I take advantage of the keyboard shortcuts in Sublime Text. However, the sidebar is quite a lot of effort to manage, especially as I mostly leave it closed. Firstly, you need cmd+k,cmd+b to open it. Then you type ctrl+k,ctrl+0 to focus it as opening it doesn't automatically set focus. Then you can navigate to the file you want and open it via pressing return. Finally, you type cmd+k,cmd+b to close… continue reading.

Screenshot of the active window on Mac

I find myself needing to take screen captures of the currently active window in OS X reasonably frequently. The built-in way to do this on a Mac is to use shift+cmd+4, then press space and then use your mouse to highlight the window and click. For a good proportion of the time, I'm not using a mouse, so this doesn't work great. There's a built-in command line utility called screencapture which requires you to know… continue reading.

Auto reloading a PDF on OS X

Currently, I create presentations using rst2pdf and so I regularly have vim open side by side with the Preview app showing the rendered PDF. I use a Makefile to create the PDF from the rst sources, so I just use :make in vim to rebuild the PDF file and then had to switch to Preview in order for it to reload the updated PDF file. Recently a friend wondered why the PDF viewer couldn't reload… continue reading.

Free the Geek appearance

I was delighted to spend an hour chatting with Matt Setter on episode 14 of Free the Geek. In this podcast, we talked about Slim 3 and development in general. Matthew gives me a great introduction (thanks!) and then we delve into the chat. We talk about the importance of semantic versioning as I think this is key to stability in a project. It's not very glamorous to work on code where you have to… continue reading.

Use vim's :make to preview Markdown

As it becomes more painful to use a pointing device for long periods of time, I find myself using vim more and so I'm paying more attention to customisation so that the things I'm used to from Sublime Text are available to me. One thing I'm used to is that when I run the build command on a Markdown file, I expect Marked for Mac to open and render the file that I'm writing. Vim… continue reading.

Styling rst2pdf tables

I currently use rst2pdf to create presentations slide decks from reStructured Text files. I like rST a lot as it's more expressive than Markdown and allows for extension. Tables in rST are marked up like this:

We create a PDF file with the command rst2pdf test.rst which produces a table that looks like this: To style, this we create styles within a style file and then compile using rst2pdf test.rst -s Let's start… continue reading.

installing XHGui via Ansible

I'm still using Ansible to provision Vagrant VMs. This is how I added the XHGui profiler to my standard setup. Theres a number steps we need to do: Install Composer Install the uprofiler PHP extension Install XHGui Set up for profiling Set up host for XHGui website Install Composer Installing Composer requires these tasks:

Firstly we download the Composer installer and run it to create composer.phar. We then rename to composer, make executable and… continue reading.

Shorter directory text in Bash prompt

Rather helpfully, David Goodwin left a comment about how he shortens the space taken up by the directory section of his terminal's PS1 prompt by using a Bash script to remove the middle portion. This is a really good idea, so I ported it into my PS1 set up which resulted in some rearranging and thought I'd share here as I modified for OS X and I don't want to lose it! The relevant portion… continue reading.

Setting OS X's Terminal Tab to the current directory

I use many tabs in a Terminal window quite frequently, and while the window title will show the current directory name, the tab title doesn't. You can manually change it using shift+cmd+i, but who can be bothered? Automating it so that the tab title always matches the current directory turns out to be really easy and just requires a few lines in ~/.profile. Firstly, we need a function that sets the tab's title to the… continue reading.