Installing Ansible

Ansible is a bit like puPHPet, in that it provisions Vagrant boxes etc. My latest project is using PPI Framework 2, and provisions with Ansible, so I had to get everything installed.

Essentially we just clone from the Github repo and install a few python things:

$ git clone git:// --recursive
$ cd ansible
$ source hacking/env-setup
$ sudo easy_install pip
$ sudo pip install paramiko PyYAML Jinja2 httplib2 six

And that should be you. Run ansible from the terminal in ay folder now and you should get all the available options etc. Have fun!

Upgrade your Terminal!

If you are using the Bash terminal, or the Mac OSX Terminal, time to get rid of it! You need Zsh! (pronounced zoosh). From the Github page:

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. That sounds boring. Let's try this again.
Oh My Zsh is a way of life! Once installed, your terminal prompt will become the talk of the town or your money back! Each time you interface with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, "that is amazing. are you some sort of genius?" Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.

So, what are you waiting for? Give it a spin!

curl -L | sh

Or using wget:

wget -O - | sh

Well worth a try!

Stop iOS Web app links from launching Safari

You may have noticed that if you have made your website into an iOS webapp, that <a> tags leave the app and launch in Safari, which is slightly irritating. To fix this, it’s just a little Javascript:

<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(,e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script>


Fixing the Shellshock Vulnerability

While I was on holiday in Andalucia (Olé!) a vulnerability was found for the Bash shell, called Shellshock (or BashDoor).
So you’ll be wanting to secure yourself up then. First up, lets see if you are vulnerable:

env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

If the output contains ‘vulnerable’, then you need to fix it. If not, you’re all good. To fix it:

sudo apt-get update
sudo apt-get -s upgrade
sudo apt-get  upgrade

Now get back on with your work! 😉

iOS Web App Icons and Loading Screens

There’s a stack of different icon sizes and splash screen sizes now, depending which iPod, iPhone, or iPad you are using. iPad can also splash screen in Landscape, iPhone 5 has a different aspect ratio, etc! It has been a while since I last made web app icons etc, so I brought myself up to speed, and found the following Gist on Github:

Very handy 🙂

<!– Run in full-screen mode. –>
<meta name=“apple-mobile-web-app-capable” content=“yes”>
<!– Make the status bar black with white text. –>
<meta name=“apple-mobile-web-app-status-bar-style” content=“black”>
<!– Customize home screen title. –>
<meta name=“apple-mobile-web-app-title” content=“Web App”>
<!– Disable phone number detection. –>
<meta name=“format-detection” content=“telephone=no”>
<!– Set viewport. –>
<meta name=“viewport” content=“initial-scale=1”>
<!– Prevent text size adjustment on orientation change. –>
<style>html { webkittextsizeadjust: 100%; }</style>
<title>iOS 7 Web App</title>
<!– Icons –>
<!– iOS 7 iPad (retina) –>
<link href=“/static/images/apple-touch-icon-152×152.png”
<!– iOS 6 iPad (retina) –>
<link href=“/static/images/apple-touch-icon-144×144.png”
<!– iOS 7 iPhone (retina) –>
<link href=“/static/images/apple-touch-icon-120×120.png”
<!– iOS 6 iPhone (retina) –>
<link href=“/static/images/apple-touch-icon-114×114.png”
<!– iOS 7 iPad –>
<link href=“/static/images/apple-touch-icon-76×76.png”
<!– iOS 6 iPad –>
<link href=“/static/images/apple-touch-icon-72×72.png”
<!– iOS 6 iPhone –>
<link href=“/static/images/apple-touch-icon-57×57.png”
<!– Startup images –>
<!– iOS 6 & 7 iPad (retina, portrait) –>
<link href=“/static/images/apple-touch-startup-image-1536×2008.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: portrait)
and (-webkit-device-pixel-ratio: 2)”
<!– iOS 6 & 7 iPad (retina, landscape) –>
<link href=“/static/images/apple-touch-startup-image-1496×2048.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: landscape)
and (-webkit-device-pixel-ratio: 2)”
<!– iOS 6 iPad (portrait) –>
<link href=“/static/images/apple-touch-startup-image-768×1004.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: portrait)
and (-webkit-device-pixel-ratio: 1)”
<!– iOS 6 iPad (landscape) –>
<link href=“/static/images/apple-touch-startup-image-748×1024.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: landscape)
and (-webkit-device-pixel-ratio: 1)”
<!– iOS 6 & 7 iPhone 5 –>
<link href=“/static/images/apple-touch-startup-image-640×1096.png”
media=“(device-width: 320px) and (device-height: 568px)
and (-webkit-device-pixel-ratio: 2)”
<!– iOS 6 & 7 iPhone (retina) –>
<link href=“/static/images/apple-touch-startup-image-640×920.png”
media=“(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 2)”
<!– iOS 6 iPhone –>
<link href=“/static/images/apple-touch-startup-image-320×460.png”
media=“(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 1)”


Run Composer installed binaries globally

cd-ing into a directory then running ./command, or worse yet, php command.php, sucks!
As an example, I wanted to run the doctrine command from anywhere.
I already have composer installed globally, and no longer have to type php composer.phar, but I haven’t blogged it since it was pretty easy, but anyway here it is:

curl -sS | php
 sudo mv composer.phar /usr/local/bin/composer

Then you can just type composer from anywhere. If you already have composer you should run sudo composer self-update. Anyway on to our php binaries (Doctrine, PHPUnit, Behat, you name it). If it’s a fresh install of composer you should see when you type composer global install:

Composer could not find a composer.json file in /home/username/.composer

Now we know where we can create our composer.json. Go to the sites for the packages you would like and copy paste the require field info; Here is Doctrine’s:

       "doctrine/dbal": "2.3.4",
       "doctrine/orm": "2.3.5"

Now run composer global install and it will install in /home/username/.composer/vendor. The bin folder is inside that. Lastly we need to have our bin path set in our PATH environment variable, so the system knows to check that folder for a binary matching the command’s name. edit ~/.bashrc (it could be .bash_profile or something similar). At the end, paste this in:

export PATH=$PATH:/home/username/.composer/vendor/bin

now exit the shell and open a new terminal up and log back in. you can now type doctrine into the command line and lo and behold, your composer executables are rocking!

Setup SSH keys for login without password

Sick of being asked for your password? Set up SSH authorised keys and forget about it!

you@localmachine:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/you/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/
The key fingerprint is:

you@localmachine:~> chmod -R go-rwx ~/.ssh

Now copy the contents of /home/you/.ssh/, and SSH in for the last time with your password to your remote machine:

you@localmachine:~> ssh
Last login: Tue Jan 28 14:14:51 2014 from
CentOS release 6.3 (Final)> cd .ssh> nano authorized_keys

Paste in the contents you copied from your public key file. Make sure it is all on ONE LINE. Save and exit.> cd ..> chmod -R go-rwx ~/.ssh> exit
you@localmachine:.ssh> ssh
Last login: Tue Jan 28 15:28:51 2014 from
CentOS release 6.3 (Final)