Nick Shears - Web Developer

Devon, UK

Install Ruby from Source on Ubuntu 18

March 26, 2020
$ sudo apt-get update
$ sudo apt-get install -y build-essentials
$ wget
$ tar -xvzf ruby-2.6.5.tar.gz
$ ./configure
$ make
$ sudo make install

psql: could not connect to server: No such file or directory (Mac OS X)

January 15, 2020

I got this error after restarting my Mac.

The solution was to

$ brew services stop postgresql
$ rm /usr/local/var/postgres/
$ brew services start postgresql

Solution found here

Heroku - Exporting and Importing PG Databases

January 23, 2019

First, you need to capture.

$ heroku pg:backups:capture

To download locally

$ heroku pg:backups:download

To get a URL to download the Backup

$ heroku pg:backups:url

To import the database into another Heroku app, you can do

$ heroku pg:backups:capture --app app1
$ heroku pg:backups:url --app app1

$ heroku pg:backups:restore '^THE_ABOVE_URL^' DATABASE_URL --app app2

To import locally from a Heroku app you can do

$ heroku pg:backups:capture --app my_app
$ heroku pg:backups:download --app my_app
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -d mydb latest.dump

Multiple lightweight apps/hobby projects on a single server with Dokku

November 27, 2018

I previously had a whole bunch of lightweight hobby projects scattered across the web on different hosts such as Digital Ocean, Heroku and AWS.
The thing is, hosting separate apps can get expensive relatively quickly if you want a service that's always on, or allows more than a few thousand database rows (Heroku).

So recently I started playing around with Dokku. It allows you to setup multiple apps and keep them separated from each other on the same server via Docker.

It probably took about an hour of playing around to figure out what I was doing, but I now have 5/6 hobby apps all running smoothly on a 5 dollars a month Digital Ocean Droplet - this website being one of them :) very cool.

OSX – Keyboard shortcut to maximize a window

November 10, 2018

Go to Keyboard -> Shortcuts

Inside App Shortcuts, create a new shortcut titled “Zoom”. Enter your key combination of choice and there you go, you should be able to maximize all windows now with ease.

Why there is no built in shortcut for doing this by default baffles me, but oh well.

This was done on MacOs High Sierra 10.13.6.

Better Project Management in Sublime Text

September 10, 2018

If you’re working with multiple projects, then quickly switching between them is a necessity. For years I’ve been switching between using the built in project switcher in Sublime text and simply opening Sublime up from my project directory in the terminal.

Opening from the terminal gets annoying after a while and any opened tabs etc are no longer there from the previous session. The built in project manager for Sublime is good whilst it works, but the issue is that it forgets about projects that haven’t been opened for a while – they disappear from the quick switch list, which means opening up the project file manually all over again. The other downside is that you have to manage the Sublime project file and the Sublime workspace file yourself.

Fortunately, there’s a great little package for Sublime called “Project Manager”. This is everything the built in Sublime project manager should be. No need to worry about where the project and workspace files are as they’re all centrally stored on the fly by the plugin when you create a new project. The quick switch doesn’t forget about projects that haven’t been opened in a while either. It’s super easy and fast to use. No more project management hassle.

A really convenient way to increase Mac storage

September 8, 2018

I own the MacBook Pro (Retina, 13 inch, early 2015), and for the past 6 months I’ve been battling with the limitation of 128gb hard drive space. It’s been painful – constantly moving stuff over to an external hard drive, storing stuff in the cloud and deleting junk files etc.

I’d previously tried out SD cards, but they weren’t suitable or safe since I work from place to place and my laptop is always sat at different angles – this means the SD card would be susceptible to damage or snapping due to it sticking out.

After research I assumed that the only thing left was either getting a brand new Mac or digging in and replacing the hard drive myself. Fortunately, I came across a saviour – Transcend JetDrive. These babies don’t protrude from the mac at all, once inserted, they lie flush to the side of the MacBook. You can pick ‘em up in 64gb, 128gb and 256gb versions.

The only downside is that they’re a bit tricky to get back out – for me that’s not a problem as I intend to just keep it in the slot permanently. I do occasionally need to use the SD Card slot for other means, like transferring data from a camera, but for that I’m just going to use a USB SD Card Reader in the future.

Turn Websites into OS X Apps

September 8, 2018

Sometimes I prefer using the web interface for websites over the desktop app, and sometimes the website I’m using doesn’t provide a desktop app at all. In these situations I find it annoying to keep a separate web browser tab or window open – especially if it’s a site that I’ll be using frequently. I’d much rather have it sit open in my Dock, waiting and ready to be used like a normal app.

Fortunately, I recently stumbled upon Fluid – You simply open it up, give it a website url, a name and an optional icon and hit create. You’ll now have a brand new app that will open up and stick around in your dock just like a normal application.

First thing I’ve done is use fluid to create an app for the Facebook “Messenger” website. Since an official desktop client doesn’t currently exist and the third party solutions I’ve tried over the years are always breaking (Goofy etc).

Secondly, I’m accessing a Task Management website all day through the week for which a desktop client doesn’t exist – this now sits in my Dock for convenient and fast access.

Fluid has been a great find and something I expect I’ll find many more uses for.

Troubleshooting PDFKit and wkhtmltopdf in Rails

April 19, 2017

I’ve spent the past couple of days trying to generate PDF files successfully with PDFkit and wkhtmltopdf. It’s been a frustrating process to say the least.


1. You can’t use files with any other extension than .html when passing a file to, they must be .html files.

2. If you are trying to include assets in the PDF by making requests to your local server, you’ll need to run a web server capable of handling multiple processes (Unicorn or similar), otherwise the request will hang. I got around this by just including the required assets inline in the page.

3. Be careful with the file content that you’re passing to PDFKit, certain HTML syntax cannot be converted to PDF successfully.

4. If the page you are converting to a PDF is dependent on javascript generating content that might not be immediately visible, you will need to pass a javascript_delay option to E.g. :javascript_delay => 1000.

5. To have a better chance at debugging the issue causing you trouble, set the verbose option to true in a PDFkit initializer.

6. Get familiar with using wkhtmltopdf. PDFKit is just a Ruby wrapper around wkhtmltopdf, so try and reproduce the command that PDFKit is running by manually entering it in your terminal. This way you can rule out wkhtmltopdf being the troublemaker and narrow it down to an issue on the web server.