Aug 16, 2013
Most Bower packages will be fetched using a git:// URL, which connects on port 9418. This can be problematic if you’re behind a firewall which blocks this port.
You can get around this quite easily by telling Git to always use https:// instead of git://:
(Read more) Aug 7, 2013
git config --global url.https://.insteadOf git://
One of my favourite Ruby Rogues episodes (What Makes Beautiful Code) has a short section where the Rogues talk about the concept of dishonest code. David Brady wrote a really good piece on this, which I highly recommend reading.
What I want to talk about is a more specific variant of dishonest code: dishonest comments.
Take this code, for example:
e.stopPropagation() will stop this event from bubbling up to other event handlers. Now, what if somebody decides that the event should bubble up? They might do something like this:
@@ -1,4 +1,4 @@
+ // Let the event bubble up to the next handler
This is pretty common practice; a developer will leave a comment so that the next person understands why the (Read more) Aug 1, 2013
e.stopPropagation() is gone.
apt-get install php5 on a Debian/Ubuntu server, you’ll notice that APT will automatically install a bunch of
apache2 packages as well. This can be pretty annoying if you’re planning on using another web server (or no web server at all).
If you take a look at the package dependencies (Debian/Ubuntu) you’ll see why this happens -
php5 needs one of either
php5-fpm. APT doesn’t care which package it installs; it just picks the first package that satisfies the dependency, which is why you get the
You can get around this by installing one of the other dependencies before (Read more) Aug 1, 2013
php5. For example,
apt-get install php5-fpm php5 or
apt-get install php5-cgi php5.
Sometimes you’ll want to use your local SSH keys on your Vagrant boxes, so that you don’t have to manage password-less keys for each box. This can be done with SSH agent forwarding, which is explained in great detail on Unixwiz.net.
Setting this up is fairly straightforward. On the host machine, you need to add the following to
~/.ssh/config (which you should create if it doesn’t exist):
You need to replace
your.domain.com with either the domain or the IP address of your Vagrant box. You can wildcard this with
host *, but this is a really bad idea because it lets every server you SSH to access your keys.
Once you’ve done that, just run
ssh-add to ensure you ensure your identities are added to the SSH agent.
Now, add the following to the config block in your Vagrantfile:
config.ssh.forward_agent = true
That’s all it takes. You can make sure it worked by comparing the output of (Read more) Jul 17, 2013
ssh-add -L on both the host machine and the guest box.
There are plenty of discussions about which font is the best for programming. The problem is, there are so many “best” fonts that it’s difficult to choose one. Rather than have an exhaustive list of “best” fonts for programming, wouldn’t it be easier to simply know which fonts to avoid? (Read more) Jun 9, 2013
This evening I wanted to start hacking on a project of mine, which is a simple WordPress theme. My main development machine was being used by somebody else, so I decided to boot up my old Sony Vaio running Ubuntu. It’ll be simple, I thought. I’ve just got to clone the repo, run
bower install, and
grunt build, and I’ll be good to go. I was wrong.
First, the version of npm installed on the laptop is apparently so out-of-date that it can’t run the install. So I let it update itself (and all the other packages I have installed - why not?) with
sudo npm -g update. Being a Sunday night, my broadband connection is running spectacularly slow, so the update process takes about 10 minutes at 40kB/s. But hey, at least now I can run
npm install, right?
Nope. Now npm is throwing some errors with unhelpful messages, but that’s fine, I’ll just trawl through the error log. 5 minutes later, I figure out that ~/tmp belongs to root (probably from running (Read more) May 20, 2013
npm update as root). OK, fine, I’ll change the permissions and try again. This time
npm install works! But of course, my connection is so horribly slow and grunt has so many dependencies that the install process takes over 15 minutes.
Inspired by Eric Mann’s post on caching WordPress with Redis, I thought I’d experiment with a similar setup using Memcached. Any in-memory caching system should work just as well, but I’ve chosen Memcached because it’s already running on my server and because PHP already has a built-in libmemcached API.
My current setup is Nginx and PHP-FPM, with WP Super Cache. The cache is saved to the filesystem, allowing Nginx to serve static files (which it is very good at) without needing to pass any requests to PHP. This setup has worked very well, so I’ll be using it as a baseline.
To use Memcached, every request needs to be passed to PHP. My gut feeling was that this would be slower than serving static files with Nginx due to the overhead of spinning up a PHP process for each request.
To find out which of the two setups was faster, I measured the following metrics using WebPagetest and Blitz : (Read more) May 20, 2013
If you’ve used Linode’s LISH console to get remote access to your server, you’re probably familiar with the way the console wraps everything to 60x20 (columns x rows) - even when you’re connected via ssh in a much larger terminal. (Read more) Nov 14, 2012
Setting up your editor correctly can make working with other developers much less painful. Below are some things that I believe every developer should do when editing source code. Any good IDE or editor should have settings to do these things automatically - the points below are paired with their Sublime Text setting.
(Read more) Oct 12, 2012
- Trim trailing whitespace -
- Always use Unix line endings (LF) -
- Ensure files end with a new line -
- Automatically detect indentation style -
- Or, failing the above, have a way to quickly switch between indentation styles.
This post is to help me keep track of non-tech books that I would like to read.
Breakfast of Champions by Kurt Vonnegut
Slaughterhouse-Five by Kurt Vonnegut
Cat’s Cradle by Kurt Vonnegut
Do Androids Dream Of Electric Sheep by Philip K Dick
Neuromancer by William Gibson
Ham on Rye by Charles Bukowski (Read more) Sep 22, 2012
After upgrading php-fpm, my PHP-based sites were returning “502 Bad Gateway” errors. This can happen when the php5-fpm package reconfigures itself to listen on a different socket. Here’s how you can solve it.
Check to make sure that php-fpm is running with
ps aux | grep php - if you can’t see any php-fpm processes in the output, then you may need to re-install php-fpm. If php-fpm is running okay, then skip this first step.
sudo apt-get remove php5 php5-cgi php5-fpm
sudo apt-get install php5 php5-cgi php5-fpm
The thing to notice here is that the order in which you install the packages is important. In the past I have found that installing them in the wrong order causes the packages to be configured incorrectly.
Next, get php-fpm to listen on the correct host/port. In
/etc/php5/fpm/pool.d/www.conf change the
listen value to match the
fastcgi_pass location in your Nginx configuration. For example, I changed mine from:
listen = /var/run/php5-fpm.sock
If you are configuring php-fpm to listen on a Unix socket, you should also check that the socket file has the correct owner and permissions. While I wouldn’t recommend it, you can simply give read-write permissions to all with
sudo chmod go+rw /var/run/php5-fpm.sock.
Restart php-fpm with (Read more) Sep 12, 2012
sudo service php5-fpm restart and everything should work normally again.
Coming from PhpStorm (a full-featured IDE), I felt that Sublime Text was missing a few useful features. Luckily, one of the great things about Sublime is that it can be easily extended with plugins and packages. Perhaps the most useful package for Sublime is Sublime Package Control, which allows you to easily install and manage packages (it can even uninstall itself - über meta).
Below are some Sublime Text packages that I have found to be useful for web development. (Read more) Sep 4, 2012
In the early hours of 4 September 2010, I was sound asleep in my house on Mount Pleasant hill in Christchurch, New Zealand. At 4:35am I was woken by a deep rumbling sound. Seconds later, the floor and walls began to shake as my house was rocked back and forth on its foundations. I scrambled out of bed and hid in a doorway until the shaking stopped. After checking that my family was okay, I went upstairs and stepped onto the balcony to look out over Christchurch. The city was silent save for a few car alarms, and it was in this relative quiet that I came to understand the significance of this event. I didn’t realise it then, but that earthquake would become a catalyst for change in my life. (Read more) Aug 28, 2012
This post is a list of programming-related books that I intend to read at some point (in no particular order).
And some other resources that aren’t books: (Read more) Aug 19, 2012
Few people know about my ability to transform my feet into roller blades. Doctors around the world are perplexed, and also impressed. Biologists debate whether such a transformation is even possible.
I casually slide into the biologist debating hall and take a seat near the front. People are staring at my roller-feet, but I don’t care. I put my shades on. (Read more)