<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
  <title>27smiles</title>
  <link href="http://27smiles.com/" />
  
  <updated>2011-06-24T08:59:05+01:00</updated>
  <id>tag:27smiles.com,2007-07-03:1</id>
  <author>
    <name>Richard Grundy</name>
  </author>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/27smiles" /><feedburner:info uri="27smiles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title>Deluge in Chrome extension</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/Uh5CM8Nbwj8/deluge-in-chrome" />
    <updated>2010-04-24T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2010-04-24:/2010/04/24/deluge-in-chrome</id>
    <content type="html">
      &lt;p&gt;During the christmas holidays I decided to have a play around with writing Chrome extensions, however it wasn't until now that I've decided to write a quick introduction post about it.&lt;/p&gt;
      
      &lt;p&gt;The extension I wrote gives a simple overview, with controls, of torrents for Deluge - Deluge is a multi-platform torrent application written in Python. You can see the name, size, progress, ETA and current speed of the torrents along with some actions: moving torrents up and down; pausing and resuming; toggling auto-managed, basically if they should obey the queue rules; and since version 0.5 you can now delete torrents, with the option to delete just the torrent file or the data and torrent file.&lt;/p&gt;
      
      &lt;p&gt;Here's a screenshot:&lt;/p&gt;
      
      &lt;p&gt;&lt;img src="/images/posts/2010-04-24-deluge-in-chrome/1.png" alt="" /&gt;&lt;/p&gt;
      
      &lt;h2&gt;Requirements&lt;/h2&gt;
      
      &lt;p&gt;The extension currently requires the 1.2.x series (I have yet to look into the 1.3 series). You also need to have the webUI running. Once installed, on the options page, enter the address of the webUI and the port it's running on. You may also enter the password which will do the initial login for you, however, this isn't required and you can login to the webUI manually if you wish.&lt;/p&gt;
      
      &lt;h2&gt;Getting it&lt;/h2&gt;
      
      &lt;p&gt;The extension can be found on the &lt;a href="https://chrome.google.com/extensions/detail/pbenannnhhgfhhijhlpgfbjagebjeeel"&gt;Chrome extension page&lt;/a&gt;. Please feel free to give a rating! =)&lt;/p&gt;
      
      &lt;p&gt;For developer folk the code can be found on &lt;a href="http://github.com/RichGuk/deluge-in-chrome"&gt;github&lt;/a&gt;, I'm more than happy to accept patches for fixes, improvements and new features.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2010/04/24/deluge-in-chrome</feedburner:origLink></entry>
  <entry>
    <title>Securely backup your VPS using Duplicity &amp; GnuPG</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/QpwGGj08KyY/securely-backup-of-vps-with-duplicity-and-gpg" />
    <updated>2010-04-07T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2010-04-07:/2010/04/07/securely-backup-of-vps-with-duplicity-and-gpg</id>
    <content type="html">
      &lt;div class="figure box left no_margin_top"&gt;&lt;img src="/images/posts/2010-04-07-securely-backup-of-vps-with-duplicity-and-gpg/3271760209_dba5b4f12c_m.jpg" width="240" height="160"&gt;&lt;p&gt;&lt;img class="cc" src="/images/darkness/creative_commons.png" width="16" height="16" title="Creative Commons image" alt="CC"&gt; &lt;a href="http://www.flickr.com/photos/comedynose/3271760209/"&gt;comedynose&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
      
      
      &lt;p&gt;It's always a good idea to backup your data; it gives you protection from data loss and hardware failure. If you host sensitive data, or applications for customers, it's a good idea to encrypt the backups, ensuring their secure and can be safely kept just about anywhere.&lt;/p&gt;
      
      &lt;p&gt;There are lots of backup scripts, solutions and services around: &lt;a href="http://samba.anu.edu.au/rsync/"&gt;Rsync&lt;/a&gt;, &lt;a href="http://s3sync.net/wiki"&gt;s3sync&lt;/a&gt;, &lt;a href="http://rdiff-backup.nongnu.org/"&gt;Rdiff-backup&lt;/a&gt;, &lt;a href="http://www.jungledisk.com/"&gt;Jungle Disk&lt;/a&gt; and &lt;a href="http://www.nongnu.org/duplicity/"&gt;Duplicity&lt;/a&gt; being just a few. After trying a few of them I decided to go with Duplicity for my &lt;a href="http://www.linode.com/?r=00870b85cb89e8747f4319189550b4943bc7483b"&gt;Linode&lt;/a&gt; VPS; it provided a simple, yet powerful, way of doing encrypted backups.&lt;/p&gt;
      
      &lt;p&gt;Duplicity uses librsync and GnuPG to incrementally encrypt archives of files that have changed since the last backup. You can transfer the backups using a whole range of protocols: ftp, imap, rsync, s3 and scp for example - I store backups on my local file server, however, due to the encrypted nature they could easily be stored on something like Amazon's S3.&lt;/p&gt;
      
      &lt;p&gt;The MAN pages have more information on the &lt;a href="http://www.nongnu.org/duplicity/duplicity.1.html#toc4"&gt;actions&lt;/a&gt;, &lt;a href="http://www.nongnu.org/duplicity/duplicity.1.html#toc5"&gt;options&lt;/a&gt; and &lt;a href="http://www.nongnu.org/duplicity/duplicity.1.html#toc6"&gt;URL formats&lt;/a&gt; for duplicity, it also provides several &lt;a href="http://www.nongnu.org/duplicity/duplicity.1.html#toc3"&gt;examples&lt;/a&gt;.&lt;/p&gt;
      &lt;h2&gt;Installing duplicity and its dependencies&lt;/h2&gt;
      
      &lt;p&gt;Duplicity is written in python, which needs to be installed if it isn't already (not something covered here). You can install Duplicity via Debian's package manager, but the version is outdated and lacks newer features; to get the latest version it's best to install it from source.&lt;/p&gt;
      
      &lt;p&gt;The following dependencies need to be met:&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;Python v2.3 or later&lt;/li&gt;
      &lt;li&gt;librsync v0.9.6 or later&lt;/li&gt;
      &lt;li&gt;GnuPG for encryption&lt;/li&gt;
      &lt;li&gt;NcFTP version 3.1.9 or later&lt;/li&gt;
      &lt;li&gt;Boto 0.9d or later&lt;/li&gt;
      &lt;li&gt;Python development files (python-dev)&lt;/li&gt;
      &lt;li&gt;librsync development files (librsync-dev)&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;Debian users can simply run the following to get all of the required dependencies:&lt;/p&gt;
      
      &lt;pre&gt;$ sudo aptitude build-dep duplicity&lt;/pre&gt;
      
      
      &lt;p&gt;Fetch the latest stable release, which as of writing this was 0.6.08b:&lt;/p&gt;
      
      &lt;pre&gt;$ mkdir sources&lt;br&gt;$ cd sources&lt;br&gt;$ wget http://code.launchpad.net/duplicity/0.6-series/0.6.08b/+download/duplicity-0.6.08b.tar.gz&lt;/pre&gt;
      
      
      &lt;p&gt;Extract the tarball:&lt;/p&gt;
      
      &lt;pre&gt;$ tar xvzf duplicity-0.6.08b.tar.gz&lt;br&gt;$ cd duplicity-0.6.08b&lt;/pre&gt;
      
      
      &lt;p&gt;Finally, install Duplicity:&lt;/p&gt;
      
      &lt;pre&gt;$ sudo python setup.py install&lt;/pre&gt;
      
      
      &lt;p&gt;If successful then you should be able to verify by running:&lt;/p&gt;
      
      &lt;pre&gt;$ duplicity --version&lt;/pre&gt;
      
      
      
      
      &lt;div class="figure box right no_margin_top"&gt;&lt;img src="/images/posts/2010-04-07-securely-backup-of-vps-with-duplicity-and-gpg/288491653_0d8802adef_m.jpg" width="240" height="180"&gt;&lt;p&gt;&lt;img class="cc" src="/images/darkness/creative_commons.png" width="16" height="16" title="Creative Commons image" alt="CC"&gt; &lt;a href="http://www.flickr.com/photos/pong/288491653/"&gt;pong&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
      
      
      &lt;h2&gt;Encryption &amp;amp; Keys&lt;/h2&gt;
      
      &lt;p&gt;Duplicity takes care of the gpg encryption for us, all we have to do is supply a public encryption and signature key. The encryption key is used to protect the data from nosey people, while the signature key is used to ensure the integrity of the backups.&lt;/p&gt;
      
      &lt;p&gt;By default, if you omit the signature key, the encryption key is used for signing as well. It's highly recommended to create separate signature and encryption keys; the passphrase for the signature needs to be available in the script, therefore, using the same key for encryption and signing leaves your encrypted files exposed.&lt;/p&gt;
      
      &lt;p&gt;On your local machine, not your production server, you can generate the keys with this command:&lt;/p&gt;
      
      &lt;pre&gt;$ gpg --gen-key&lt;/pre&gt;
      
      
      &lt;p&gt;You will be given a choice of key types, I normally go with the default - same thing with the key length and expiry. When you're asked to enter a name, you can put what you want, I tend to put the name of the server and which key it is, signature or encryption.&lt;/p&gt;
      
      &lt;p&gt;Example of the encryption key generation:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;gpg --gen-key&lt;/span&gt;&lt;span class=line id=LC2&gt;gpg (GnuPG) 1.4.10; Copyright (C) 2008 Free Software Foundation, Inc.&lt;/span&gt;&lt;span class=line id=LC3&gt;This is free software: you are free to change and redistribute it.&lt;/span&gt;&lt;span class=line id=LC4&gt;There is NO WARRANTY, to the extent permitted by law.&lt;/span&gt;&lt;span class=line id=LC5&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC6&gt;Please select what kind of key you want:&lt;/span&gt;&lt;span class=line id=LC7&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(1) RSA and RSA (default)&lt;/span&gt;&lt;span class=line id=LC8&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(2) DSA and Elgamal&lt;/span&gt;&lt;span class=line id=LC9&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(3) DSA (sign only)&lt;/span&gt;&lt;span class=line id=LC10&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(4) RSA (sign only)&lt;/span&gt;&lt;span class=line id=LC11&gt;Your selection? &lt;/span&gt;&lt;span class=line id=LC12&gt;*press enter*&lt;/span&gt;&lt;span class=line id=LC13&gt;RSA keys may be between 1024 and 4096 bits long.&lt;/span&gt;&lt;span class=line id=LC14&gt;What keysize do you want? (2048) &lt;/span&gt;&lt;span class=line id=LC15&gt;Requested keysize is 2048 bits&lt;/span&gt;&lt;span class=line id=LC16&gt;*press enter*&lt;/span&gt;&lt;span class=line id=LC17&gt;Please specify how long the key should be valid.&lt;/span&gt;&lt;span class=line id=LC18&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0 = key does not expire&lt;/span&gt;&lt;span class=line id=LC19&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;n&amp;gt;  = key expires in n days&lt;/span&gt;&lt;span class=line id=LC20&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;n&amp;gt;w = key expires in n weeks&lt;/span&gt;&lt;span class=line id=LC21&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;n&amp;gt;m = key expires in n months&lt;/span&gt;&lt;span class=line id=LC22&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;n&amp;gt;y = key expires in n years&lt;/span&gt;&lt;span class=line id=LC23&gt;Key is valid for? (0) &lt;/span&gt;&lt;span class=line id=LC24&gt;*press enter*&lt;/span&gt;&lt;span class=line id=LC25&gt;Key does not expire at all&lt;/span&gt;&lt;span class=line id=LC26&gt;Is this correct? (y/N) y&lt;/span&gt;&lt;span class=line id=LC27&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC28&gt;You need a user ID to identify your key; the software constructs the user ID&lt;/span&gt;&lt;span class=line id=LC29&gt;from the Real Name, Comment and Email Address in this form:&lt;/span&gt;&lt;span class=line id=LC30&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Heinrich Heine (Der Dichter) &amp;lt;heinrichh@duesseldorf.de&amp;gt;"&lt;/span&gt;&lt;span class=line id=LC31&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC32&gt;Real name: Edge Backup Encryption Key&lt;/span&gt;&lt;span class=line id=LC33&gt;Email address: me@domain.com&lt;/span&gt;&lt;span class=line id=LC34&gt;Comment: Encryption key for Edge backups&lt;/span&gt;&lt;span class=line id=LC35&gt;You selected this USER-ID:&lt;/span&gt;&lt;span class=line id=LC36&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"Edge Backup Encryption Key (Encryption key for Edge backups) &amp;lt;me@domain.com&amp;gt;"&lt;/span&gt;&lt;span class=line id=LC37&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC38&gt;Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O&lt;/span&gt;&lt;span class=line id=LC39&gt;You need a Passphrase to protect your secret key.&lt;/span&gt;&lt;span class=line id=LC40&gt;*enter passphrase, make sure secure*&lt;/span&gt;&lt;span class=line id=LC41&gt;We need to generate a lot of random bytes. It is a good idea to perform&lt;/span&gt;&lt;span class=line id=LC42&gt;some other action (type on the keyboard, move the mouse, utilize the&lt;/span&gt;&lt;span class=line id=LC43&gt;disks) during the prime generation; this gives the random number&lt;/span&gt;&lt;span class=line id=LC44&gt;generator a better chance to gain enough entropy.&lt;/span&gt;&lt;span class=line id=LC45&gt;....................+++++&lt;/span&gt;&lt;span class=line id=LC46&gt;...+++++&lt;/span&gt;&lt;span class=line id=LC47&gt;We need to generate a lot of random bytes. It is a good idea to perform&lt;/span&gt;&lt;span class=line id=LC48&gt;some other action (type on the keyboard, move the mouse, utilize the&lt;/span&gt;&lt;span class=line id=LC49&gt;disks) during the prime generation; this gives the random number&lt;/span&gt;&lt;span class=line id=LC50&gt;generator a better chance to gain enough entropy.&lt;/span&gt;&lt;span class=line id=LC51&gt;.....+++++&lt;/span&gt;&lt;span class=line id=LC52&gt;+++++&lt;/span&gt;&lt;span class=line id=LC53&gt;gpg: key B5FC8737 marked as ultimately trusted&lt;/span&gt;&lt;span class=line id=LC54&gt;public and secret key created and signed.&lt;/span&gt;&lt;span class=line id=LC55&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC56&gt;gpg: checking the trustdb&lt;/span&gt;&lt;span class=line id=LC57&gt;gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model&lt;/span&gt;&lt;span class=line id=LC58&gt;gpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u&lt;/span&gt;&lt;span class=line id=LC59&gt;pub   2048R/B5FC8737 2010-04-03&lt;/span&gt;&lt;span class=line id=LC60&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Key fingerprint = 2365 2F64 0808 8A90 644C  9AEF FBBD B843 B5FC 8737&lt;/span&gt;&lt;span class=line id=LC61&gt;uid                  Edge Backup Encryption Key (Encryption key for Edge backups) &amp;lt;me@domain.com&amp;gt;&lt;/span&gt;&lt;span class=line id=LC62&gt;sub   2048R/9ABB5804 2010-04-03&lt;/span&gt;&lt;span class=line id=LC63&gt;&lt;br/&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/355213/ddde96add95b1675321ed9625f5059154bc2055b/gen.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/355213#file_gen.txt" style="float:right;margin-right:10px;color:#666"&gt;gen.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/355213"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                  &lt;/div&gt;
      
      
      &lt;p&gt;Do exactly the same for the signature key, but make sure you use a different passphrase.&lt;/p&gt;
      
      &lt;p&gt;Once both keys have been created you need to export and copy the public encryption and private signature keys to the production box; the safest way to do this is SCP/SSH.&lt;/p&gt;
      
      &lt;p&gt;To export the keys run the following commands:&lt;/p&gt;
      
      &lt;pre&gt;$ gpg --export -a 'Edge Backup Encryption' &gt; edge.enc.pub.gpg&lt;br&gt;$ gpg --export-secret-keys -a 'Edge Backup Signature' &gt; backup.sig.sec.gpg&lt;/pre&gt;
      
      
      &lt;p&gt;Transfer them to the production box:&lt;/p&gt;
      
      &lt;pre&gt;$ scp edge.enc.pub.gpg backup.sig.sec.gpg rich@server.com:/tmp&lt;/pre&gt;
      
      
      &lt;p&gt;Import the transferred keys by running the following command (on the production box):&lt;/p&gt;
      
      &lt;pre&gt;$ gpg --import /tmp/backup.enc.pub.gpg&lt;br&gt;$ gpg --import-secret-keys /tmp/backup.enc.sec.gpg&lt;/pre&gt;
      
      
      &lt;p&gt;Verify the keys were imported correctly, we also need to note down the key IDs:&lt;/p&gt;
      
      &lt;pre&gt;$ gpg --list-keys&lt;br&gt;$ gpg --list-secret-keys&lt;/pre&gt;
      
      
      
      
      &lt;div class="gist"&gt;                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;/root/.gnupg/pubring.gpg&lt;/span&gt;&lt;span class=line id=LC2&gt;------------------------&lt;/span&gt;&lt;span class=line id=LC3&gt;pub   2048R/5FD0100F 2010-04-04&lt;/span&gt;&lt;span class=line id=LC4&gt;uid                  Edge Backup Encryption Key (Encryption key for edge backups) &amp;lt;me@domain.com&amp;gt;&lt;/span&gt;&lt;span class=line id=LC5&gt;sub   2048R/48F61F08 2010-04-04&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;pub   2048R/7F73FA36 2010-04-04&lt;/span&gt;&lt;span class=line id=LC8&gt;uid                  Edge Backup Signature Key (Signature key for edge backups) &amp;lt;me@domain.com&amp;gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;sub   2048R/A67F8410 2010-04-04&lt;/span&gt;&lt;span class=line id=LC10&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC11&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC12&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC13&gt;/root/.gnupg/secring.gpg&lt;/span&gt;&lt;span class=line id=LC14&gt;------------------------&lt;/span&gt;&lt;span class=line id=LC15&gt;sec   2048R/7F73FA36 2010-04-04&lt;/span&gt;&lt;span class=line id=LC16&gt;uid                  Edge Backup Signature Key (Signature key for edge backups) &amp;lt;me@domain.com&amp;gt;&lt;/span&gt;&lt;span class=line id=LC17&gt;ssb   2048R/A67F8410 2010-04-04&lt;/span&gt;&lt;span class=line id=LC18&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC19&gt;&lt;br/&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/355213/24574e3bcfc37c64269215e9c8326a2d1c35d029/list.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/355213#file_list.txt" style="float:right;margin-right:10px;color:#666"&gt;list.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/355213"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;The two IDs we're interested in are &lt;strong&gt;5FD0100F&lt;/strong&gt; (encryption key) and &lt;strong&gt;7F73FA36&lt;/strong&gt; (signature key).&lt;/p&gt;
      
      &lt;div class="figure box left no_margin_top"&gt;&lt;img src="/images/posts/2010-04-07-securely-backup-of-vps-with-duplicity-and-gpg/2291896028_e54336ab04_m.jpg" width="160" height="240"&gt;&lt;p&gt;&lt;img class="cc" src="/images/darkness/creative_commons.png" width="16" height="16" title="Creative Commons image" alt="CC"&gt; &lt;a href="http://www.flickr.com/photos/anonymouscollective/2291896028/"&gt;anonymouscollective&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
      
      
      &lt;h2&gt;Backup process&lt;/h2&gt;
      
      &lt;p&gt;I run my backups as root with the scripts running from the root home directory and only readable by root - chmod'ed with 700 (rwx------). I do this for two reasons: one, you need to be able to read all the directories on the server and two, the passphrase needs to be stored in the script.&lt;/p&gt;
      
      &lt;p&gt;Before we begin the backups we need to create an exclusion list to ignore certain directories that we don't want to backup. You may include your own directories, or alter the list to better suit your Linux distro.&lt;/p&gt;
      
      &lt;pre&gt;$ vim /root/backups/excludelist&lt;br&gt;&lt;br&gt;# Add the following and save&lt;br&gt;- /sys&lt;br&gt;- /dev&lt;br&gt;- /proc&lt;br&gt;- /tmp&lt;br&gt;- /mnt&lt;/pre&gt;
      
      
      &lt;p&gt;I suggest running the initial backup manually so you can catch any potential errors before automating the process; the initial backup needs to copy everything so expect it to take a while!&lt;/p&gt;
      
      &lt;p&gt;Run the following command, changing the sign and encrypt keys for yours! Time to grab a beer maybe?&lt;/p&gt;
      
      &lt;pre&gt;$ duplicity --sign-key '7F73FA36' --encrypt-key '5FD0100F' --exclude-filelist=/root/backups/excludelist / scp://rich@backup_server//mnt/backups/edge/main&lt;/pre&gt;
      
      
      &lt;p&gt;After that has finished confirm the backup ran successfully:&lt;/p&gt;
      
      &lt;pre&gt;duplicity collection-status scp://rich@backup_server//mnt/backups/edge/main&lt;/pre&gt;
      
      
      &lt;p&gt;It should list a load of statistics and say something like: &lt;em&gt;"No orphaned or incomplete backup sets found."&lt;/em&gt;&lt;/p&gt;
      
      &lt;p&gt;When you're happy it's all running you can automate the process via a cronjob. Below is the script I use to backup my VPS, note that I dump all the mySQL databases before doing the backup, relying on backups of /var/lib/mysql isn't advised.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC3&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PASSPHRASE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;SomeMagiclySecurePassphrase&lt;/span&gt;&lt;span class=line id=LC4&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SSH_AUTH_SOCK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/ssh-agent&lt;/span&gt;&lt;span class=line id=LC5&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;&lt;span class="c"&gt;# Dump mySQL databases, relying on backup of /var/lib/mysql isn&amp;#39;t advised.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC8&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;mysqldump --all-databases -uroot -pTEHPAZZ | bzip2 -c &amp;gt; /root/backups/db/all_databases_&lt;span class="k"&gt;$(&lt;/span&gt;date +%Y_%m_%d&lt;span class="k"&gt;)&lt;/span&gt;.sql.bz2&lt;/span&gt;&lt;span class=line id=LC10&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC11&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC12&gt;&lt;span class="c"&gt;# Main backup.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC13&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC14&gt;duplicity --sign-key &lt;span class="s1"&gt;&amp;#39;7F73FA36&amp;#39;&lt;/span&gt; --encrypt-key &lt;span class="s1"&gt;&amp;#39;5FD0100F&amp;#39;&lt;/span&gt; --exclude-filelist&lt;span class="o"&gt;=&lt;/span&gt;/root/scripts/backups/ignorelist / scp://rich@backup_server//mnt/backups/edge/main&lt;/span&gt;&lt;span class=line id=LC15&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC16&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC17&gt;&lt;span class="c"&gt;# Clean up.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC18&gt;&lt;span class="c"&gt;#&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC19&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC20&gt;&lt;span class="c"&gt;# Remove the temp database dump.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC21&gt;rm /root/backups/db/all_databases_&lt;span class="k"&gt;$(&lt;/span&gt;date +%Y_%m_%d&lt;span class="k"&gt;)&lt;/span&gt;.sql.bz2&lt;/span&gt;&lt;span class=line id=LC22&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC23&gt;&lt;span class="c"&gt;# Delete duplicity backups older than 30 days.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC24&gt;duplicity remove-older-than 30D scp://rich@backup_server//mnt/backups/edge/main&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/355213/2694d42a61f6f93d6c93334220c4bbbfb2d67f09/backup.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/355213#file_backup.sh" style="float:right;margin-right:10px;color:#666"&gt;backup.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/355213"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                              &lt;/div&gt;
      
      
      &lt;p&gt;That's it! You should now have secure, fully automated backups of your server. Just make sure you keep your GPG keys safe, I keep mine on a USB pen drive I carry with me.&lt;/p&gt;
      
      &lt;p&gt;If you spot any mistakes or want to ask any questions then please, leave a comment.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2010/04/07/securely-backup-of-vps-with-duplicity-and-gpg</feedburner:origLink></entry>
  <entry>
    <title>Guide to buying petrol (a rant of sorts about slow petrol buyers)</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/vDQsU0O3pN4/top-tips-to-buying-petrol" />
    <updated>2010-03-12T00:00:00+00:00</updated>
    <id>tag:27smiles.com,2010-03-12:/2010/03/12/top-tips-to-buying-petrol</id>
    <content type="html">
      &lt;p&gt;If there is one thing that annoys me about having to fill the car up with petrol it's other people! Their inefficiency, down right slowness and stupidity all add to this already laborious task. I have written down some top tips for these idiots.&lt;/p&gt;
      
      &lt;h2&gt;Tip one: Use the right damn pump!&lt;/h2&gt;
      
      &lt;p&gt;There are a select few (quite a small minority have this level of idiocy) who,
      instead of waiting maybe a minute or two in a queue for the correct pump. Where the pump is positioned the same side as
      &lt;img src="/images/posts/2010-03-12-top-tips-to-buying-petrol/busy_petrol_station.jpg" class="right pad" width="300" height="169"&gt;
      their fuel cap, they will of course, without a moments hesitation use the pump that is on the &lt;strong&gt;wrong&lt;/strong&gt; side for their fuel cap. I mean christ, how stupid! Yes clever you! By pushing into another queue and using the pump the other side of the forecourt you have saved yourself minutes of waiting in a queue, genius. Except you're wrong! It's not genius at all it's in fact A grade weak-mindedness and very rude to boot.&lt;/p&gt;
      &lt;p&gt;Those precious minutes you saved in the queue you now spend looking like a total knob trying to stretch the hose around your vehicle wasting, yes you guessed it, minutes! The only thing we get out of this? Laughing at you because, lets face it, you're an idiot. When you do finally manage to get the nozzle into your fuel tank you then realise how far you are from the meter and  the fact you're going to have to squint to see the digits. This again is the source of amusement for the people in the queue (of course not the same people for they have already fuelled).&lt;/p&gt;
      
      &lt;p&gt;So please, choose a queue and STICK TO IT.&lt;/p&gt;
      
      &lt;h2&gt;Tip number 2: Prepare yourself for fuelling&lt;/h2&gt;
      
      &lt;p&gt;&lt;img src="/images/posts/2010-03-12-top-tips-to-buying-petrol/petrol276.jpg" class="left pad" width="238" height="143"&gt;
      A little bit of preparation can go a long way it allows you to be ready for the situation saving you and others frustration. One classic example of lacking preparation when fuelling is to not prepare the payment method. How many times have you been sat waiting in a queue while some imbecile attempts to find their wallet or purse. For god sake, prepare! If not before you get to the fuel station, then while you're sitting in the queue waiting for the unprepared tosser in front of you. So combined with tip one these are the things you need to prepare for.&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;Know your payment method before hand; for cash make sure you have enough.&lt;/li&gt;
      &lt;li&gt;Know the side of the car your fuel cap is located.&lt;/li&gt;
      &lt;li&gt;Know which fuel type you require.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;h2&gt;Tip number 3: Multitasking&lt;/h2&gt;
      
      &lt;p&gt;Multitasking is the act of undertaking more than one task at a time. This simple act can be applied to fuelling your vehicle. For example, while you're waiting for the meter to display the next menu option why don't you start opening your fuel cap? If you're going to be paying by cash then while you're fuelling why don't you get your wallet or purse out and have it ready to hand?&lt;/p&gt;
      
      &lt;p&gt;Multitasking allows you to utilise the wasted time normally spent just fuelling and means you're not holding up other motorists afterwards.&lt;/p&gt;
      
      &lt;h2&gt;Tip number 4: Process of fuelling a.k.a how to use the pump&lt;/h2&gt;
      
      &lt;p&gt;Using a petrol pump is a very simple task but for the simple people out there this simple task somehow becomes a slow and problematic. I will explain the simple steps needed for efficient fuelling  .&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;Step 1 - select the payment method, if this your first time using the pump the please read the instructions and memorise them. If you  are paying on card just insert your card into the slot (recommended method if not buying other goods), if you're paying by cash then press the button that reads something like "pay at the kiosk".&lt;/li&gt;
      &lt;li&gt;Step 2 - once you have chosen the payment method pick up the fuelling nozzle and insert it into your already opened fuel cap. However, do not press the leaver straight away! Listen for the machine to start and then wait 5 seconds! Only then should you begin.&lt;/li&gt;
      &lt;li&gt;Step 3 - hold the leaver down until you have reached the amount you wish to spend, or until the car is full the pump will stop functioning once it reaches the limit of the tank so please don't try and squeeze those extra few drops out of the pump it's pointless and gains you nothing; who bloody cares if you're under £20 by 3p, donate the change to fucking charity instead of worrying about it.=&lt;/li&gt;
      &lt;li&gt;Step 4 - Lift the nozzle out of the tank and just before it's fully out begin to tilt the end upwards as not to leak fuel down the body of your car! No one wants to wait while you clean your stupid mistake.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;h2&gt;Tip 5: Finishing up a.k.a paying (if cash) and driving away&lt;/h2&gt;
      
      &lt;p&gt;&lt;img src="/images/posts/2010-03-12-top-tips-to-buying-petrol/petrol_station.jpg" class="left pad" width="250" height="232"&gt;
      This is the step where preparation comes most into play! For now you are prepared, you have correct amount of cash you need and you have your wallet or purse at hand. If you're paying by cash and for fuel only  then you can simply walk straight to the till, leaving your car briefly at the pump - this is acceptable. However, if you plan to buy other goods, or shop around in the garage then please, if provided, use the fucking parking bays and do not leave your car next to the pump. People who leave their car at the pump while they read the magazines should have their license revoked.&lt;/p&gt;
      
      &lt;p&gt;On a side note, if you're not buying other goods from the station then why don't you just pay on card? Nearly all petrol stations have card pay points; they're secure, faster and you have an electronic record on your statement for the fuel transaction.&lt;/p&gt;
      
      &lt;p&gt;So, that wraps up some top tips I have for the stupid bastards out there who slow the rest of us efficient fuelers down with their simpleton actions. I hope they can learn from these tips and make fuelling a much quicker experience for all of us.&lt;/p&gt;
      
      &lt;p&gt;The rant is now over, so happy driving folks!&lt;/p&gt;
      
      &lt;h3&gt;Image credit&lt;/h3&gt;
      
      &lt;ol&gt;
      &lt;li&gt;&lt;a href="http://www.dailymail.co.uk/news/article-560964/Last-minute-talks-avert-48-hour-oil-refinery-strike-threaten-UKs-petrol-supplies.html"&gt;Dailymail&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://www.guardian.co.uk/business/2008/jun/18/oil.tradeunions"&gt;Guardian&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://www.electricscotland.com/thomson/images/20.27%20petrol%20station.jpg"&gt;Electric Scotland&lt;/a&gt;&lt;/li&gt;
      &lt;/ol&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2010/03/12/top-tips-to-buying-petrol</feedburner:origLink></entry>
  <entry>
    <title>Dr. Jekyll man and this is my hyde side!</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/3S2NbOayhXo/dr-Jekyll-man-and-this-is-my-hyde-side" />
    <updated>2010-03-03T00:00:00+00:00</updated>
    <id>tag:27smiles.com,2010-03-03:/2010/03/03/dr-Jekyll-man-and-this-is-my-hyde-side</id>
    <content type="html">
      &lt;p&gt;It's that time of year again! The time of year where I decide to revive the blog - which seems to becoming common practice for me! &lt;img src="http://farm4.static.flickr.com/3349/3423669462_cf844811c6_m.jpg" alt="" class="right pad" title="I remember taking this picture last March! Spring, yeah?" /&gt; According to the posting history it has been over a year since I showed this place any love! So, with the start of spring, I'm giving the blog new life and much needed TLC.&lt;/p&gt;
      
      &lt;p&gt;Well the major change in the revision is that I've ditched Wordpress - nice! The blog is now running, or should I say generated by &lt;a href="http://github.com/mojombo/jekyll"&gt;Jekyll&lt;/a&gt; - which is a static site generator written in Ruby.&lt;/p&gt;
      
      &lt;p&gt;For some reason, unbeknown to me, I grew to dislike writing any blogs in Wordpress, hell logging in even became painful for some reason! Especially when I forgot my password, twice :(, bloody idiot. I think one of the reasons I grew to dislike Wordpress was the flaky-ness you get from the WYSIWYG, seems more much logical to be writing my posts in markdown with the odd bit of HTML, as after all I should know HTML - right? :) Wordpress also felt bloated, slow and just plain old eugh! Furthermore anyone who thinks using tabs (instead of spaces) in their code base is a good idea ought to be taken out and shot in the head with a bolt gun, preferably nailed to the floor (wow where did that come from?).&lt;/p&gt;
      &lt;h2&gt;Jekyll&lt;/h2&gt;
      
      &lt;p&gt;There were several things I wanted when moving the blog to Jekyll.&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;Maintain the support for comments.&lt;/li&gt;
      &lt;li&gt;Gist for inserting code snippets.&lt;/li&gt;
      &lt;li&gt;Maintain the archive and category listings.&lt;/li&gt;
      &lt;li&gt;Integrate twitter, flickr and last.fm, like I had with Wordpress.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;For comments I went with &lt;a href="http://disqus.com"&gt;Disqus&lt;/a&gt; which uses JavaScript to display comments for each post, this was the simplest solution and a popular one also. For the rest of the implementations I wanted it was time to create a fork!&lt;/p&gt;
      
      &lt;h2&gt;The inevitable fork&lt;/h2&gt;
      
      &lt;p&gt;It doesn't take long before you begin forking Jekyll and filling it with customisations for your situation, in fact this seems to be common practice evident by the number of forks - it is one of the most forked projects on github.&lt;/p&gt;
      
      &lt;p&gt;Before reinventing the wheel I decided to check out several other forks to see if they had the features I required - they did! I found the features spread over several repositories from the following github users &lt;a href="github.com/newbamboo/jekyll"&gt;newbamboo&lt;/a&gt;, &lt;a href="http://github.com/cantorrodista/jekyll"&gt;cantorrodista&lt;/a&gt; and &lt;a href="github.com/henrik/jekyll"&gt;henrik&lt;/a&gt;.&lt;/p&gt;
      
      &lt;p&gt;The newbamboo fork offered support for embedding gists at compile time instead of via JavaScript. I wanted to embed the gists HTML rather than using JavaScript because I'm likely to be having several gists per coding post and didn't want the page bogged down with several JavaScript calls in the middle of the document. I cherry-picked the needed commit from the repo and also made some additions that allowed me to cache the downloaded gists (save fetching them whenever I regenerate the site) and also support for specifying a snippet file to use, mainly for use in multi-file gists.&lt;/p&gt;
      
      &lt;p&gt;cantorrodista's fork allowed me to generate archive index pages for each year and month, similar to how wordpress does. I implemented category index generation using the same method as cantorrodista was using to generate the archive stuff.&lt;/p&gt;
      
      &lt;p&gt;Finally I decided I wanted HAML support for Jekyll, I'm a hardcore HAML fan and it hurts to be without it! I tried initially to get along with Jekyll's choice of templating, &lt;a href="http://www.liquidmarkup.org"&gt;Liquid&lt;/a&gt; but I found it horrendous and limiting - often filling the template with kak because of the way looping works. I understand why it was chosen because it means you can display the data without being able to execute ruby code, as Jekyll is used on github pages. However, there should be an option to choose whatever you want and github can just limit it to Liquid on their servers!&lt;/p&gt;
      
      &lt;p&gt;I had problems trying to merge in Henrik's changes, lots of conflicts that I was unsure of the correct output so I decided to lift out the needed bits of code manually and implement them in my fork. Along the way I also fixed a few issues and made it a bit more flexible (for example you can now supply HAML options in the _config.yml file).&lt;/p&gt;
      
      &lt;h3&gt;My fork&lt;/h3&gt;
      
      &lt;p&gt;&lt;a href="http://github.com/RichGuk/jekyll"&gt;My fork&lt;/a&gt; is on my github account the &lt;a href="http://github.com/RichGuk/27smiles"&gt;source code&lt;/a&gt; for this blog is also on there which will have examples of the different features added to Jekyll in the fork.&lt;/p&gt;
      
      &lt;h3&gt;Twitter, Flickr, Last.fm integration&lt;/h3&gt;
      
      &lt;p&gt;To integrate the services I wrote some ruby scripts which pull the relevant data down from each service and format it into presentable HTML before saving this to a file for the server which could then be included into the layout.&lt;/p&gt;
      
      &lt;p&gt;The scripts and the jekyll command (to regenerate the site) are called via a cronjob every 5 minutes at the moment, if this becomes a problem I'll increase the time, or split the scripts up (for example call flickr every day not 5 minutes).&lt;/p&gt;
      
      &lt;p&gt;Here is the script used to get my twitter feed, the others can be found on the source code for this blog (on my github).&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="vg"&gt;$:&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unshift&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;__FILE__&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC3&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC4&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;open-uri&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC5&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;&lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;date_helpers&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC8&gt;&lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;DateHelpers&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC10&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;http://twitter.com/statuses/user_timeline/14274164.rss&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC11&gt;&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;__FILE__&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;..&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;_includes&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;twitter.html&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC12&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC13&gt;&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Nokogiri&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;XML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC14&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC15&gt;&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC16&gt;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;ul class="twitter_feed"&amp;gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC17&gt;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;.//item&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC18&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;description&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC19&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/(.+): /&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC20&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC21&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;link&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC22&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at_xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;pubDate&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC23&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC24&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="c1"&gt;# Skip items that start with @ don&amp;#39;t need those on the site =)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC25&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="k"&gt;unless&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="sr"&gt;/^@/&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC26&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="c1"&gt;# Link up @username&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC27&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/(?!\\s+)@([A-Za-z0-9_]+)/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;a class="user" href="http://twitter.com/\\1"&amp;gt;@\\1&amp;lt;/a&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC28&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="c1"&gt;# Link up hashtags.&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC29&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/#([A-Za-z0-9_]+)/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC30&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="s1"&gt;&amp;#39;&amp;lt;a class="hash" href="http://twitter.com/#search?q=%23\\1"&amp;gt;#\\1&amp;lt;/a&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC31&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="c1"&gt;# Finally convert new lines to br&amp;#39;s&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC32&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gsub!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/\/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;br /&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC33&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="sx"&gt;%Q{&lt;/span&gt;&lt;span class="se"&gt;\\t&lt;/span&gt;&lt;span class="sx"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sx"&gt; &amp;lt;a href="&lt;/span&gt;&lt;span%20class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sx"&gt;"&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;time_ago_in_words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sx"&gt; ago&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC34&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="k"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC35&gt;&amp;nbsp;&amp;nbsp;&lt;span class="k"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC36&gt;&amp;nbsp;&amp;nbsp;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;/ul&amp;gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC37&gt;&lt;span class="k"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/320150/ee2f2c2b9cbf6529821b56d11d2b7e32172342b5/twitter.rb" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/320150#file_twitter.rb" style="float:right;margin-right:10px;color:#666"&gt;twitter.rb&lt;/a&gt;          &lt;a href="http://gist.github.com/320150"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;h3&gt;Pingomatic&lt;/h3&gt;
      
      &lt;p&gt;I also wrote a script which can be called when publishing the blog which tells &lt;a href="http://pingomatic.com/"&gt;pingomatic&lt;/a&gt; of new content. Pingomatic should then tell the subscribed services that new content has been published!&lt;/p&gt;
      
      &lt;h2&gt;Migration of posts&lt;/h2&gt;
      
      &lt;p&gt;Importing went fairly smooth and I used the provided wordpress important script in Jekyll to do the bulk of the importing, I did have to edit most of the posts though as they had several errors - a lot were due to several plugins I used in wordpress.&lt;/p&gt;
      
      &lt;h2&gt;Nginx setup&lt;/h2&gt;
      
      &lt;p&gt;I use Nginx to serve all my sites and along with the move of the blog I decided to cleanup the 'vhost' file for the blog, so for anyone interested here it is.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;server {&lt;/span&gt;&lt;span class=line id=LC2&gt;&amp;nbsp;&amp;nbsp;listen 80;&lt;/span&gt;&lt;span class=line id=LC3&gt;&amp;nbsp;&amp;nbsp;server_name .27smiles.co.uk www.27smiles.com;&lt;/span&gt;&lt;span class=line id=LC4&gt;&amp;nbsp;&amp;nbsp;rewrite ^/(.*) http://27smiles.com/$1 permanent;&lt;/span&gt;&lt;span class=line id=LC5&gt;}&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;server {&lt;/span&gt;&lt;span class=line id=LC8&gt;&amp;nbsp;&amp;nbsp;listen 80;&lt;/span&gt;&lt;span class=line id=LC9&gt;&amp;nbsp;&amp;nbsp;server_name 27smiles.com;&lt;/span&gt;&lt;span class=line id=LC10&gt;&amp;nbsp;&amp;nbsp;root /home/rich/apps/27smiles/_site;&lt;/span&gt;&lt;span class=line id=LC11&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC12&gt;&amp;nbsp;&amp;nbsp;access_log /home/rich/apps/27smiles/log/access.log combined;&lt;/span&gt;&lt;span class=line id=LC13&gt;&amp;nbsp;&amp;nbsp;error_log /home/rich/apps/27smiles/log/error.log;&lt;/span&gt;&lt;span class=line id=LC14&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC15&gt;&amp;nbsp;&amp;nbsp;index index.html;&lt;/span&gt;&lt;span class=line id=LC16&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC17&gt;&amp;nbsp;&amp;nbsp;# Set expires for static content.&lt;/span&gt;&lt;span class=line id=LC18&gt;&amp;nbsp;&amp;nbsp;location ~ ^/(images|stylesheets|javascript|favicon\\.ico|atom\\.xml)/ {&lt;/span&gt;&lt;span class=line id=LC19&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;expires 30d;&lt;/span&gt;&lt;span class=line id=LC20&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/span&gt;&lt;span class=line id=LC21&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span class=line id=LC22&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC23&gt;&amp;nbsp;&amp;nbsp;# Rewrite rules for Rails blog.&lt;/span&gt;&lt;span class=line id=LC24&gt;&amp;nbsp;&amp;nbsp;rewrite ^/categories/(.*+)$ /category/$1 permanent; # /categories/meh -&amp;gt; /category/meh&lt;/span&gt;&lt;span class=line id=LC25&gt;&amp;nbsp;&amp;nbsp;# Rewrite rules from Wordpress -&amp;gt; Jekyll move.&lt;/span&gt;&lt;span class=line id=LC26&gt;&amp;nbsp;&amp;nbsp;rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.+)/comment(.*)$" /$1/$2/$3/$4/ permanent;&lt;/span&gt;&lt;span class=line id=LC27&gt;&amp;nbsp;&amp;nbsp;rewrite "^/([0-9]{4})/([0-9]{1})/([0-9]{1})/(.+)/(.*)$" /$1/0$2/0$3/$4/ permanent;&lt;/span&gt;&lt;span class=line id=LC28&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/320150/3e34fc94f09738f8fc5b209b1c8b261066680433/27smiles.nginx" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/320150#file_27smiles.nginx" style="float:right;margin-right:10px;color:#666"&gt;27smiles.nginx&lt;/a&gt;          &lt;a href="http://gist.github.com/320150"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                      &lt;/div&gt;
      
      
      &lt;h2&gt;Deployment / Semi-public git!&lt;/h2&gt;
      
      &lt;p&gt;The entire blog is hosted in a git repository and is publicly accessible on my github account. I came across with one issue however, when I'm writing a blog post and it's in draft form I ideally don't want to make this public yet but I wanted to be able to share the progress between home and work. I first tried (as I have with this post) to bump the posts into a '_drafts' folder and make commits with the progression and only push to the repository on my fileserver (which is private) and then push to the github one when the post is made live. However upon reflection I've since decided that this would be messy and fill the commit history with minor changes so I have decided that I will create a branch for each post, share this between work and home then, when ready, merge it back into master and delete the branch.&lt;/p&gt;
      
      &lt;p&gt;To make deployment as simple as possible I wanted to make use of git's hooks. A &lt;a href="http://github.com/namelessjon"&gt;friend&lt;/a&gt; was kind enough to give me the post-receive hook code he uses for one of his webby sites. I adapted it a little to suite the project at hand:&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;Wrapped the entire code in a check to make sure it was the master branch; I don't need the site generating for all the 'post' branches I'll be creating.&lt;/li&gt;
      &lt;li&gt;Calls the twitter, flickr, last.fm and pingomatic scripts before generating the site.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;Here is my post-receive hook.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;#!/bin/sh&lt;/span&gt;&lt;span class=line id=LC2&gt;while read oldrev newrev refname&lt;/span&gt;&lt;span class=line id=LC3&gt;do&lt;/span&gt;&lt;span class=line id=LC4&gt;&amp;nbsp;&amp;nbsp;if [ "$refname" == "refs/heads/master" ]; then&lt;/span&gt;&lt;span class=line id=LC5&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WORKDIR=/home/rich/apps/27smiles&lt;/span&gt;&lt;span class=line id=LC6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;export GIT_DIR=$WORKDIR/.git&lt;/span&gt;&lt;span class=line id=LC7&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pushd $WORKDIR &amp;gt;/dev/null&lt;/span&gt;&lt;span class=line id=LC8&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;git pull --quiet &amp;gt;/dev/null&lt;/span&gt;&lt;span class=line id=LC9&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/opt/rubyee/bin/ruby -S _scripts/twitter.rb&lt;/span&gt;&lt;span class=line id=LC10&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/opt/rubyee/bin/ruby -S _scripts/flickr.rb&lt;/span&gt;&lt;span class=line id=LC11&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/opt/rubyee/bin/ruby -S _scripts/lastfm.rb&lt;/span&gt;&lt;span class=line id=LC12&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/opt/rubyee/bin/jekyll&lt;/span&gt;&lt;span class=line id=LC13&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Finally update blogging services of new content.&lt;/span&gt;&lt;span class=line id=LC14&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/opt/rubyee/bin/ruby -S _scripts/pingomatic.rb&lt;/span&gt;&lt;span class=line id=LC15&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;popd &amp;gt;/dev/null&lt;/span&gt;&lt;span class=line id=LC16&gt;&amp;nbsp;&amp;nbsp;fi&lt;/span&gt;&lt;span class=line id=LC17&gt;done&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/320150/f3b7a5e4dbf4fc18a103fdbe2ded674f65ed1ba4/post-receive" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/320150#file_post_receive" style="float:right;margin-right:10px;color:#666"&gt;post-receive&lt;/a&gt;          &lt;a href="http://gist.github.com/320150"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                  &lt;/div&gt;
      
      
      &lt;p&gt;Now to publish a blog entry it's simply a matter of pushing to the git repository which should give you something like this.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;Configuration from ./_config.yml&lt;/span&gt;&lt;span class=line id=LC2&gt;Building site: . -&amp;gt; ./_site&lt;/span&gt;&lt;span class=line id=LC3&gt;Successfully generated site: . -&amp;gt; ./_site&lt;/span&gt;&lt;span class=line id=LC4&gt;Blo.gs: Ping sent.&lt;/span&gt;&lt;span class=line id=LC5&gt;Technorati: Ping sent.&lt;/span&gt;&lt;span class=line id=LC6&gt;Feed Burner: Ping sent.&lt;/span&gt;&lt;span class=line id=LC7&gt;Google Blog Search: Ping sent.&lt;/span&gt;&lt;span class=line id=LC8&gt;Bloglines: Ping sent.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/320150/b37cd02f6e1d7c6fe676c446d972d72af9da091a/Output%20from%20post-update" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/320150#file_output%20from%20post_update" style="float:right;margin-right:10px;color:#666"&gt;Output from post-update&lt;/a&gt;          &lt;a href="http://gist.github.com/320150"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                          &lt;/div&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2010/03/03/dr-Jekyll-man-and-this-is-my-hyde-side</feedburner:origLink></entry>
  <entry>
    <title>Moved over to Linode from Slicehost</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/DB-99e_o660/moved-over-to-linode-from-slicehost" />
    <updated>2008-12-21T00:00:00+00:00</updated>
    <id>tag:27smiles.com,2008-12-21:/2008/12/21/moved-over-to-linode-from-slicehost</id>
    <content type="html">
      &lt;p&gt;Last night and the night before I went though the simple process of moving my websites over from slicehost to Linode. The moved went smoothly and I'm happy with the new provider.&lt;/p&gt;
      
      &lt;p&gt;I had been with slicehost for over a year now and they've provided a fantastic service, only ever had my VPS go down once due to a faulty server box I was on. Slicehost have a really nice clean control panel too which was very easy on the eye and simple to manage.&lt;/p&gt;
      
      &lt;p&gt;However, all of slicehost's packages are for 64bit systems - no 32bit option offered. I've been looking to head back to 32bit to cut down on the memory consumption in a couple of Merb applications (as you know pointers are 64bit on a 64bit OS and Ruby makes use of pointers quite often). Linode allow you to choose 32bit and because of this I have managed to take my total memory usage of around 420mb down to 218mb with room to breath which has allowed me to drop down to a cheaper package, at least for now.&lt;/p&gt;
      
      &lt;p&gt;Linode so far have also been fantastic. The Linode control is a little more 'full' than the Slicehost one but after a few minutes of getting to know your way round it's soon manageable and dare I say nicer, in the way it makes you feel like you're in 'more control' over your server. Linode servers also felt a fair bit quicker, installing stuff seemed snappier and it feels like I get less delay when connecting via SSH - this could be down to the fact I was given a choice of data center and opted for one on the east coast.&lt;/p&gt;
      
      &lt;p&gt;On a side note, Linode also offer slighty higher memory, bandwidth and disc space for the same price that slicehost do. For example on the base package of $20 gets you 256mb ram, 100GB monthly bandwidth and 10GB of disc storage with Slicehost compared to the 360mb ram, 200GB bandwidth and 12GB storage you get with Linode.&lt;/p&gt;
      
      &lt;h2&gt;Conclusion&lt;/h2&gt;
      
      &lt;p&gt;So in conclusion I would highly recommend both hosts, I can't comment on Linode up-time wise but so far they've been amazing had my slice within minutes of buying, the server seem quick lots of configuration options right down to which data center you wish to be placed into. Slicehost have been fantastic up-time wise the control is sleek and the packages reasonable.&lt;/p&gt;
      
      &lt;p&gt;I would personally recommend Linode if you're trying to save a bit of cash and would like the 32bit option to get that little bit extra memory saving.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/12/21/moved-over-to-linode-from-slicehost</feedburner:origLink></entry>
  <entry>
    <title>Simple backup script written in Ruby</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/AHjW0puiZk0/simple-backup-script-written-in-ruby" />
    <updated>2008-08-18T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-08-18:/2008/08/18/simple-backup-script-written-in-ruby</id>
    <content type="html">
      &lt;p&gt;I've written a simple backup script in Ruby that utilises Rsync I've made it public so feel free to fork, change and contribute!&lt;/p&gt;
      
      &lt;p&gt;The backups are structured as such:&lt;/p&gt;
      
      &lt;p&gt;/remote/location/current - The current folder contains the the latest clone of the intended backup folder.
      /remote/location/backup_dir - The backup directory, which by default is the current day (monday, tuesday, etc) contains
      the difference to current since it was last run. So it will contain any new files and any files that were deleted.&lt;/p&gt;
      
      &lt;p&gt;I need to add a few examples of the settings and how to use it via cron on Linux and Launchd on OS X but the basic script should be working fine.&lt;/p&gt;
      
      &lt;p&gt;The script can be found on my &lt;a href="http://github.com/RichGuk"&gt;github account&lt;/a&gt;, &lt;a href="http://github.com/RichGuk/rrsync/tree/master"&gt;http://github.com/RichGuk/rrsync/tree/master&lt;/a&gt;&lt;/p&gt;
      
      &lt;p&gt;You can simply clone it with the following command:
      &lt;strong&gt;git clone git://github.com/RichGuk/rrsync.git&lt;/strong&gt;&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/08/18/simple-backup-script-written-in-ruby</feedburner:origLink></entry>
  <entry>
    <title>Setting up Xen on Debian etch (64bit)</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/ETwHqf2wCQI/setting-up-xen-on-debian-etch-64bit" />
    <updated>2008-08-08T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-08-08:/2008/08/08/setting-up-xen-on-debian-etch-64bit</id>
    <content type="html">
      &lt;p&gt;Today I decided to setup &lt;a href="http://xen.org"&gt;Xen&lt;/a&gt; (not the Half-Life world) on a clean Debian installation so I could have a few &lt;a href="http://en.wikipedia.org/wiki/Virtual_private_server"&gt;VPSes&lt;/a&gt; to play around with load balancing mySQL, FastCGI and Mongrel. I thought I’d break down the steps I went though to get the basic Xen setup working.&lt;/p&gt;
      
      &lt;p&gt;Note: This is by no means a perfect setup, it’s more of a quick way to play around with Xen using a spare PC in the home. If you want more of a production level setup I suggest checking out the Xen website, or Google.&lt;/p&gt;
      
      &lt;h2&gt;Step 1. Install Debian (Etch)&lt;/h2&gt;
      
      &lt;p&gt;Here you just need to setup a standard Debian system, I’m using the 64bit edition of Etch but the process is the same for most Debian releases. I won’t go into detail on how to setup Debian as there are plenty of how-tos out there, for me the normal setup was fine. During the installation I gave the machine &lt;strong&gt;judgement&lt;/strong&gt; as the hostname and &lt;strong&gt;gnet.foo&lt;/strong&gt; as the domain (you can use whatever) I also unchecked &lt;strong&gt;desktop&lt;/strong&gt; from the selectable software menu as I didn’t need/or want a GUI.&lt;/p&gt;
      
      &lt;h2&gt;Step 2. Configure Debian ready for Xen&lt;/h2&gt;
      
      &lt;p&gt;Once you’ve booted and logged into your system you need to install a few applications, but before we do that I tend to remove the CD source from apt-get’s sources.list:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;vim /etc/apt/sources.list&lt;/code&gt;&lt;/p&gt;
      
      &lt;br /&gt;
      
      
      &lt;br /&gt;
      
      
      &lt;p&gt;&lt;code&gt;#comment out the CD line
        #deb cdrom:[Debian...........&lt;/code&gt;&lt;/p&gt;
      
      &lt;br /&gt;
      
      
      &lt;br /&gt;
      
      
      &lt;p&gt;&lt;code&gt;apt-get update&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Now install the packages (remove &lt;strong&gt;vim-full&lt;/strong&gt; if you're not using vim):&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;apt-get install ssh build-essential vim-full&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Next we need to configure the server to use a static IP (if you didn't during the installation). I gave my box (&lt;strong&gt;judgement&lt;/strong&gt;) a static IP of &lt;strong&gt;192.168.1.10&lt;/strong&gt;. Open up the interfaces file:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;vim /etc/network/interfaces&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Now if you selected DHCP during the installation your file should look similar to this by default (eth2 was my interface, yours might be different):&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;allow-hotplug eth2
      iface eth2 inet dhcp&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Change yours to match this (of course change eth2 to match yours and whatever IP you wish to use):&lt;/p&gt;
      
      &lt;pre&gt;auto eth
      iface eth2 inet static
      address 192.168.1.10
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255
      gateway 192.168.1.1&lt;/pre&gt;
      
      
      &lt;p&gt;Once you've done that you need to restart the networking:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;/etc/init.d/networking restart&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;If all is working then you should be able to ping other computers on your network and they should be able to ping your machine.&lt;/p&gt;
      
      &lt;p&gt;If you wish you can continue the rest of the setup via SSH (on windows you can use &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/"&gt;Putty&lt;/a&gt;).&lt;/p&gt;
      
      &lt;p&gt;Finally just make sure your system is up-to-date before giving it a reboot:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;apt-get upgrade
      shutdown -r now&lt;/code&gt;&lt;/p&gt;
      
      &lt;h2&gt;Step 3. Installing Xen&lt;/h2&gt;
      
      &lt;p&gt;There are two main options when it comes to installing Xen. You can compile it from the source code or simply use apt-get, the latter worked fine for me and is dead simple...to install via apt-get use the following command (bridge-utils is used to setup the network for the virtual machines):&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;apt-get install xen-linux-system-2.6.18-6-xen-amd64 bridge-utils&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;The version of Xen kernel might of changed since writing this, try this command to see what's there:&lt;/p&gt;
      
      &lt;p&gt;apt-cache search xen-linux
      When that has finished installing give the machine a reboot and select Xen kernel from the GRUB menu (for me it became the default option):&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;shudown -r now&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Once the system is back up and logged in (your previous credentials should work) check that you've booted the correct kernel:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;uname -r&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;It should read something like 2.6.18-6-xen-amd64 if not then you've most likely booted the wrong kernel from GRUB.&lt;/p&gt;
      
      &lt;h2&gt;Step 4. Creating virtual images or DomU's (the VPSes)&lt;/h2&gt;
      
      &lt;p&gt;To help with creating, starting, stopping, etc... you need to install xen-tools:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;apt-get install xen-tools&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Next we need to create the place we want to store the domains (virtual servers), I put mine in /home/xen (xen requires a folder called domains within this folder) so run this command:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;mkdir -p /home/xen/domains&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Once you've created the location to store the domains you need to edit a few options in Xen's configuration. Start by opening up xend-config.sxp:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;vim /etc/xen/xend-config.sxp&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;and look this for line (around line 70 for me):&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;##&lt;/span&gt;&lt;span class=line id=LC2&gt;# To bridge network traffic, like this:&lt;/span&gt;&lt;span class=line id=LC3&gt;#&lt;/span&gt;&lt;span class=line id=LC4&gt;# dom0: fake eth0 -&amp;gt; vif0.0 -+&lt;/span&gt;&lt;span class=line id=LC5&gt;#                            |&lt;/span&gt;&lt;span class=line id=LC6&gt;#                          bridge -&amp;gt; real eth0 -&amp;gt; the network&lt;/span&gt;&lt;span class=line id=LC7&gt;#                            |&lt;/span&gt;&lt;span class=line id=LC8&gt;# domU: fake eth0 -&amp;gt; vifN.0 -+&lt;/span&gt;&lt;span class=line id=LC9&gt;#&lt;/span&gt;&lt;span class=line id=LC10&gt;# use&lt;/span&gt;&lt;span class=line id=LC11&gt;#&lt;/span&gt;&lt;span class=line id=LC12&gt;# (network-script network-bridge)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318975/b7da257ad63ad0193ee462c7ba253678c520e20a/gistfile1.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318975#file_gistfile1.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile1.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318975"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                          &lt;/div&gt;
      
      
      &lt;p&gt;and uncomment the &lt;strong&gt;network-script network-bridge&lt;/strong&gt; part so it looks like this:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;##&lt;/span&gt;&lt;span class=line id=LC2&gt;# To bridge network traffic, like this:&lt;/span&gt;&lt;span class=line id=LC3&gt;#&lt;/span&gt;&lt;span class=line id=LC4&gt;# dom0: fake eth0 -&amp;gt; vif0.0 -+&lt;/span&gt;&lt;span class=line id=LC5&gt;#                            |&lt;/span&gt;&lt;span class=line id=LC6&gt;#                          bridge -&amp;gt; real eth0 -&amp;gt; the network&lt;/span&gt;&lt;span class=line id=LC7&gt;#                            |&lt;/span&gt;&lt;span class=line id=LC8&gt;# domU: fake eth0 -&amp;gt; vifN.0 -+&lt;/span&gt;&lt;span class=line id=LC9&gt;#&lt;/span&gt;&lt;span class=line id=LC10&gt;# use&lt;/span&gt;&lt;span class=line id=LC11&gt;#&lt;/span&gt;&lt;span class=line id=LC12&gt;(network-script network-bridge)&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318975/6525a2660d10cf51fb93fc5b91c1a5920c5aa4b3/gistfile2.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318975#file_gistfile2.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile2.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318975"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                              &lt;/div&gt;
      
      
      &lt;p&gt;Now we need to setup some defaults as well as the location to store the domains by opening up &lt;strong&gt;xen-tools.conf&lt;/strong&gt;:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;vim /etc/xen-tools/xen-tools.conf&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;There are several things to comment out and change here so I'll just list the values I changed in mine:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;...&lt;/span&gt;&lt;span class=line id=LC2&gt;dir = /home/xen&lt;/span&gt;&lt;span class=line id=LC3&gt;...&lt;/span&gt;&lt;span class=line id=LC4&gt;debootstrap = 1&lt;/span&gt;&lt;span class=line id=LC5&gt;...&lt;/span&gt;&lt;span class=line id=LC6&gt;dist = etch&lt;/span&gt;&lt;span class=line id=LC7&gt;#If you want to give your domains static IP&amp;#39;s rather than use DHCP (which I did then you can setup the default gateway/netmask)&lt;/span&gt;&lt;span class=line id=LC8&gt;gateway = 192.168.1.1&lt;/span&gt;&lt;span class=line id=LC9&gt;netmask = 255.255.255.0&lt;/span&gt;&lt;span class=line id=LC10&gt;...&lt;/span&gt;&lt;span class=line id=LC11&gt;#This bit is important, as mine differed to the default you need to change kernel and initrd to point to the right ones (ls /boot/* - to find out)&lt;/span&gt;&lt;span class=line id=LC12&gt;kernel = /boot/vmlinuz-2.6.18-6-xen-amd64&lt;/span&gt;&lt;span class=line id=LC13&gt;initrd = /boot/initrd.img-2.6.18-6-xen-amd64&lt;/span&gt;&lt;span class=line id=LC14&gt;...&lt;/span&gt;&lt;span class=line id=LC15&gt;#Change this to your prefered mirror (for me that&amp;#39;s the UK):&lt;/span&gt;&lt;span class=line id=LC16&gt;mirror = http://ftp.uk.debian.org/debian/&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318975/0ff6756b696554c9923a8fab90279fc548f121d4/gistfile3.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318975#file_gistfile3.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile3.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318975"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                  &lt;/div&gt;
      
      
      &lt;p&gt;Restart Xen to make sure the configuration loads correctly:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;/etc/init.d/xend restart&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;You should now be ready to create your first domain. If you're happy with the defaults in the xen-tools.conf file then you can leave a lot of the options out or you can of course put them as arguments of the command, check the man pages for &lt;strong&gt;xen-create-image&lt;/strong&gt; for more information:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;xen-create-image --hostname=i-am-webial --ip=192.168.1.11 --netmask=255.255.255.0 --gateway=192.168.1.1 --passwd&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;You should see output of something like this:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;General Infomation&lt;/span&gt;&lt;span class=line id=LC2&gt;--------------------&lt;/span&gt;&lt;span class=line id=LC3&gt;Hostname       :  i-am-webial&lt;/span&gt;&lt;span class=line id=LC4&gt;Distribution   :  etch&lt;/span&gt;&lt;span class=line id=LC5&gt;Fileystem Type :  ext3&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;Size Information&lt;/span&gt;&lt;span class=line id=LC8&gt;----------------&lt;/span&gt;&lt;span class=line id=LC9&gt;Image size     :  4Gb&lt;/span&gt;&lt;span class=line id=LC10&gt;Swap size      :  128Mb&lt;/span&gt;&lt;span class=line id=LC11&gt;Image type     :  sparse&lt;/span&gt;&lt;span class=line id=LC12&gt;Memory size    :  128Mb&lt;/span&gt;&lt;span class=line id=LC13&gt;Kernel path    :  /boot/vmlinuz-2.6.18-6-xen-amd64&lt;/span&gt;&lt;span class=line id=LC14&gt;Initrd path    :  /boot/initrd.img-2.6.18-6-xen-amd64&lt;/span&gt;&lt;span class=line id=LC15&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC16&gt;Networking Information&lt;/span&gt;&lt;span class=line id=LC17&gt;----------------------&lt;/span&gt;&lt;span class=line id=LC18&gt;IP Address 1   : 192.168.1.11&lt;/span&gt;&lt;span class=line id=LC19&gt;Netmask        : 255.255.255.0&lt;/span&gt;&lt;span class=line id=LC20&gt;Gateway        : 192.168.1.1&lt;/span&gt;&lt;span class=line id=LC21&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC22&gt;Creating swap image: /home/xen/domains/i-am-webial/swap.img&lt;/span&gt;&lt;span class=line id=LC23&gt;Done&lt;/span&gt;&lt;span class=line id=LC24&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC25&gt;Creating disk image: /home/xen/domains/i-am-webial/disk.img&lt;/span&gt;&lt;span class=line id=LC26&gt;Done&lt;/span&gt;&lt;span class=line id=LC27&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC28&gt;Creating ext3 filesystem on /home/xen/domains/i-am-webial/disk.img&lt;/span&gt;&lt;span class=line id=LC29&gt;Done&lt;/span&gt;&lt;span class=line id=LC30&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC31&gt;Installing your system with debootstrap mirror http://ftp.uk.debian.org/debian/&lt;/span&gt;&lt;span class=line id=LC32&gt;....&lt;/span&gt;&lt;span class=line id=LC33&gt;....&lt;/span&gt;&lt;span class=line id=LC34&gt;....&lt;/span&gt;&lt;span class=line id=LC35&gt;&lt;br/&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318975/4e042944ae82a23bf6af9667cfb86b331064c570/gistfile4.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318975#file_gistfile4.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile4.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318975"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;Once it's finished you can start your domain by using the following command:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;xm create /etc/xen/i-am-webial.cfg&lt;/code&gt;&lt;/p&gt;
      
      &lt;h2&gt;Extra Stuff&lt;/h2&gt;
      
      &lt;p&gt;Open a console for the domain:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;xm console i-am-webial&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;you can exit the console by doing &lt;strong&gt;Ctrl + ]&lt;/strong&gt;.&lt;/p&gt;
      
      &lt;p&gt;To shutdown a domain:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;xm shutdown i-am-webial&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Increase the RAM of the domain:&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;vim /etc/xen/i-am-webial.cfg&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;find and edit memory&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;memory  = '512' 512&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Resize the swap to 1GB (Resize Xen DomU swap):&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;cd /home/xen/domains/i-am-webial
      dd if=/dev/zero of=swap.img bs=1024k count=1024
      mkswap swap.img
      &lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Expand the file system by 4 GB (Resize Xen DomU disk)&lt;/p&gt;
      
      &lt;p&gt;&lt;code&gt;dd if=/dev/zero bs=1GB count=4 &gt;&gt; disk.img
      resize2fs -f disk.img&lt;/code&gt;&lt;/p&gt;
      
      &lt;p&gt;Hopefully you should now all be setup with basic VPSes, if you need any help with problems please feel free to contact me. You may also leave any feedback/comments you wish below.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/08/08/setting-up-xen-on-debian-etch-64bit</feedburner:origLink></entry>
  <entry>
    <title>Setting up Nginx with Rails</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/V5LGXpLZ0sI/setting-up-nginx-with-rails" />
    <updated>2008-05-22T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-05-22:/2008/05/22/setting-up-nginx-with-rails</id>
    <content type="html">
      &lt;p&gt;So the other day I decided to switch from using Apache to &lt;a href="http://nginx.net/"&gt;Nginx&lt;/a&gt; not because apache isn't any good, far from it. Nginx just uses much less ram and when you're on a fairly small slice, using up more ram just isn't good. I was going to benchmark speed and things between apache and nginx but I forgot to take some readings before stopping the apache service and installing nginx so we'll skip over that idea like the thought never came into my head.&lt;/p&gt;
      
      &lt;p&gt;I'll mention a few things I like about nginx first:&lt;/p&gt;
      
      &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;It's Russian&lt;/strong&gt; - Being Russian means it's build to take some shit.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;It uses a lot less memory&lt;/strong&gt; - As I said before, not really done much benchmarks so these were some quick figures from 'top' but I had apache running with about 5 instances each using 2-3% of ram even at 2% each that's still 10% of ram being used just for apache... with nginx I appear to have 2 instances running both using 0.2% of ram, so 0.4% in total - which is a nice difference.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Faster page serving&lt;/strong&gt; - Nginx is meant to be better at serving static content fast and I've certainly noticed a speed up some with things.&lt;/li&gt;
      &lt;/ol&gt;
      
      
      &lt;h2&gt;Installing nginx&lt;/h2&gt;
      
      &lt;p&gt;I follow pretty much most of these from &lt;a href="http://articles.slicehost.com"&gt;slicehost's articles&lt;/a&gt; but I didn't find an article on how to setup the sites-available and sites-enabled type directories for Debian (if you compile from source), so I'll cover that here.&lt;/p&gt;
      
      &lt;p&gt;On Debian the package manager contains a rather outdated version of nginx so I'd recommend installing it from the latest source. we'll start by making sure you have all the required library's:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo apt-get install build-essential libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-de&lt;/span&gt;&lt;span class=line id=LC2&gt;sudo apt-get build-dep nginx&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/42dbbea170b411b07f11fe4490ab50119773c31b/gistfile1.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile1.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile1.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                                                                  &lt;/div&gt;
      
      
      &lt;p&gt;When you're ready you need to obtain the latest source from the nginx website, the latest stable when writing this was 0.6.31.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~&lt;/span&gt;&lt;span class=line id=LC2&gt;mkdir sources&lt;/span&gt;&lt;span class=line id=LC3&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;sources&lt;/span&gt;&lt;span class=line id=LC4&gt;wget http://sysoev.ru/nginx/nginx-0.6.31.tar.gz&lt;/span&gt;&lt;span class=line id=LC5&gt;tar xvzf nginx-0.6.31.tar.gz&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;nginx-0.6.31&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/92400969639e1b99a36998a8122c5f6cdf60b71c/gistfile3.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile3.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile3.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                              &lt;/div&gt;
      
      
      &lt;p&gt;There are a few options we need to set when compiling from source. I wanted my nginx configuration files in &lt;strong&gt;/etc/nginx&lt;/strong&gt; instead of the default, so you may ignore this option (--conf-path) if you prefer the defaults.&lt;/p&gt;
      
      &lt;p&gt;We also need to change the location of where nginx puts it's binary files using the &lt;strong&gt;--sbin-path&lt;/strong&gt; option because by default this path is set to &lt;strong&gt;/usr/local/nginx&lt;/strong&gt; meaning the binary files would be in &lt;strong&gt;/usr/local/nginx/sbin/nginx&lt;/strong&gt;
      which won't be in our PATH setting, this option will allow the binary files
      to be placed where it can be found.&lt;/p&gt;
      
      &lt;p&gt;The last option will compile nginx
      with the ssl module, so we can have ssl conections.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo mkdir /etc/nginx&lt;/span&gt;&lt;span class=line id=LC2&gt;./configure --sbin-path&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/sbin --conf-path&lt;span class="o"&gt;=&lt;/span&gt;/etc/nginx/nginx.conf --with-http_ssl_module&lt;/span&gt;&lt;span class=line id=LC3&gt;make&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/d3da47613f8be59f05178c856a9a6930bd5a37ce/gistfile4.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile4.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile4.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                  &lt;/div&gt;
      
      
      &lt;p&gt;When the configuration has finish you can compile and install it using make:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo make install&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/13d907290cb2fb3be34309344fbd3ad752521f00/gistfile5.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile5.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile5.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                      &lt;/div&gt;
      
      
      &lt;p&gt;This should hopefully of installed nginx into &lt;strong&gt;/usr/local/nginx&lt;/strong&gt; and the configuration files into &lt;strong&gt;/etc/nginx&lt;/strong&gt;.&lt;/p&gt;
      
      &lt;p&gt;When compiling from source we need to make the &lt;strong&gt;/etc/init.d&lt;/strong&gt; script ourselves otherwise we'll have no way of starting, stopping and restarting nginx. Slicehost have a script on one of their articles that should be suitable here, so we'll download it and move it to the right directory.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~&lt;/span&gt;&lt;span class=line id=LC2&gt;wget http://articles.slicehost.com/assets/2007/10/19/nginx&lt;/span&gt;&lt;span class=line id=LC3&gt;chmod +x nginx&lt;/span&gt;&lt;span class=line id=LC4&gt;sudo mv nginx /etc/init.d/nginx&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/a57aceb16fb5482779765af48e79e178e24c4ed7/gistfile6.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile6.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile6.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                          &lt;/div&gt;
      
      
      &lt;p&gt;Then finally add it to all the default run levels.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo /usr/sbin/update-rc.d -f nginx defaults&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/c5cecbf72df9b193e223ef35f2cce51f884c3b7a/gistfile7.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile7.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile7.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                              &lt;/div&gt;
      
      
      &lt;p&gt;You should now be able to start nginx and browse to it &lt;strong&gt;http://127.0.0.1&lt;/strong&gt; (change with your servers IP). If all is working OK you should see a message that says "Welcome to nginx".&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo /etc/init.d/nginx start&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/45917892d2abfd67f30b2be869f8125b828d3f94/gistfile8.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile8.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile8.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                  &lt;/div&gt;
      
      
      
      
      &lt;h2&gt;Configuration for Nginx&lt;/h2&gt;
      
      
      &lt;p&gt;The compiled version of nginx doesn't quite have the structure you would have if you'd installed it from apt-get, the package manager sets up a familiar structure to Apache having the &lt;strong&gt;/etc/nginx/sites-available&lt;/strong&gt; and &lt;strong&gt;/etc/nginx/sites-enabled &lt;/strong&gt;directories, I find this to be a good way of organising all your virtual hosts so lets add that feature.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo mkdir /etc/nginx/sites-available&lt;/span&gt;&lt;span class=line id=LC2&gt;sudo mkdir /etc/nginx/sites-enabled&lt;/span&gt;&lt;span class=line id=LC3&gt;sudo vim /etc/nginx/nginx.conf&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/d401cf8dbb99a442c15d8379914cf11cb4bcb06c/gistfile9.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile9.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile9.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;After we've created the two directories we'll open the nginx.conf file so we can add the following line which will include our virtual host files.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;include /etc/nginx/sites-enabled/*;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/f79e47609c1bf3cbd7b88496a9a25e3f0c7f457f/gistfile10.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile10.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile10.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                                                      &lt;/div&gt;
      
      
      &lt;p&gt;I was unsure the best place to put this so I placed mine after the server {} block, like this.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;http {&lt;/span&gt;&lt;span class=line id=LC2&gt;&amp;nbsp;......&lt;/span&gt;&lt;span class=line id=LC3&gt;&amp;nbsp;server {&lt;/span&gt;&lt;span class=line id=LC4&gt;&amp;nbsp;......&lt;/span&gt;&lt;span class=line id=LC5&gt;&amp;nbsp;}&lt;/span&gt;&lt;span class=line id=LC6&gt;&amp;nbsp;include /etc/nginx/sites-enabled/*;&lt;/span&gt;&lt;span class=line id=LC7&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318944/80d1a2f3461ed25a408ce7aeea3d6649c1e1ca58/gistfile2.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318944#file_gistfile2.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile2.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318944"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                                          &lt;/div&gt;
      
      
      &lt;p&gt;Once you have done that we are ready to setup our virtual host, for this well proxy all the dynamic content to mongrel and serve all static content using nginx.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo vim /etc/nginx/sites-available/site_name&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/f3e27eb81b18d1cd30ffe0ac63cceb7eebc71c3d/gistfile1.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile1.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile1.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                                          &lt;/div&gt;
      
      
      &lt;p&gt;You'll want to replace the &lt;strong&gt;site_name&lt;/strong&gt; with the name of your site. Into this file paste the following:&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;#Setup the location of your mongrel servers.&lt;/span&gt;&lt;span class=line id=LC2&gt;upstream give_proxy_a_name {&lt;/span&gt;&lt;span class=line id=LC3&gt;server 127.0.0.1:8000;&lt;/span&gt;&lt;span class=line id=LC4&gt;server 127.0.0.1:8001;&lt;/span&gt;&lt;span class=line id=LC5&gt;}&lt;/span&gt;&lt;span class=line id=LC6&gt;#Rename www.site_name.com to site_domain.com&lt;/span&gt;&lt;span class=line id=LC7&gt;#Remove this if this is something you don&amp;#39;t want.&lt;/span&gt;&lt;span class=line id=LC8&gt;server {&lt;/span&gt;&lt;span class=line id=LC9&gt;listen   80;&lt;/span&gt;&lt;span class=line id=LC10&gt;server_name  www.site_name.com;&lt;/span&gt;&lt;span class=line id=LC11&gt;rewrite ^/(.*) http://site_name.com/$1 permanent;&lt;/span&gt;&lt;span class=line id=LC12&gt;}&lt;/span&gt;&lt;span class=line id=LC13&gt;server {&lt;/span&gt;&lt;span class=line id=LC14&gt;listen   80;&lt;/span&gt;&lt;span class=line id=LC15&gt;server_name site_name.com;&lt;/span&gt;&lt;span class=line id=LC16&gt;#Setup nginx logs.&lt;/span&gt;&lt;span class=line id=LC17&gt;access_log /path/to/rails/project/log/access.log;&lt;/span&gt;&lt;span class=line id=LC18&gt;error_log /path/to/rails/project/log/error.log;&lt;/span&gt;&lt;span class=line id=LC19&gt;root   /path/to/rails/project/public/;&lt;/span&gt;&lt;span class=line id=LC20&gt;index  index.html;&lt;/span&gt;&lt;span class=line id=LC21&gt;location / {&lt;/span&gt;&lt;span class=line id=LC22&gt;proxy_set_header  X-Real-IP  $remote_addr;&lt;/span&gt;&lt;span class=line id=LC23&gt;proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;&lt;/span&gt;&lt;span class=line id=LC24&gt;proxy_set_header Host $http_host;&lt;/span&gt;&lt;span class=line id=LC25&gt;proxy_redirect false;&lt;/span&gt;&lt;span class=line id=LC26&gt;if (-f $request_filename/index.html) {&lt;/span&gt;&lt;span class=line id=LC27&gt;rewrite (.*) $1/index.html break;&lt;/span&gt;&lt;span class=line id=LC28&gt;}&lt;/span&gt;&lt;span class=line id=LC29&gt;if (-f $request_filename.html) {&lt;/span&gt;&lt;span class=line id=LC30&gt;rewrite (.*) $1.html break;&lt;/span&gt;&lt;span class=line id=LC31&gt;}&lt;/span&gt;&lt;span class=line id=LC32&gt;if (!-f $request_filename) {&lt;/span&gt;&lt;span class=line id=LC33&gt;proxy_pass http://give_proxy_a_name;&lt;/span&gt;&lt;span class=line id=LC34&gt;break;&lt;/span&gt;&lt;span class=line id=LC35&gt;}&lt;/span&gt;&lt;span class=line id=LC36&gt;}&lt;/span&gt;&lt;span class=line id=LC37&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/8795eb1dcfba04379ef24520a935c7e324e82482/gistfile2.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile2.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile2.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                              &lt;/div&gt;
      
      
      &lt;p&gt;Replace &lt;strong&gt;site_name.com&lt;/strong&gt; with your domain. You can also rename &lt;strong&gt;give_proxy_a_name&lt;/strong&gt; to something else, the name of your site (e.g. 27smiles) should be fine here.&lt;/p&gt;
      
      &lt;p&gt;So what does some of that mean? Well the &lt;strong&gt;log&lt;/strong&gt; and &lt;strong&gt;root&lt;/strong&gt; stuff are pretty straight forward, they define where to put the logs and the what the root folder for the domain is, which in the case of rails will be the public folder within the rails project.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;upstream give_proxy_a_name {&lt;/span&gt;&lt;span class=line id=LC2&gt;server 127.0.0.1:8000;&lt;/span&gt;&lt;span class=line id=LC3&gt;server 127.0.0.1:8001;&lt;/span&gt;&lt;span class=line id=LC4&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/06d382b4051404f5db51b4d2cdf0af1f25e478c7/gistfile3.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile3.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile3.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                                  &lt;/div&gt;
      
      
      
      
      &lt;p style="padding-left: 30px;"&gt;This is where you setup the mongrel cluster, for each mongrel server you have running you will need to put a server directive here nginx will then load balance between the servers.&lt;/p&gt;
      
      
      
      
      &lt;div class="gist"&gt;                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;location / {&lt;/span&gt;&lt;span class=line id=LC2&gt;proxy_set_header  X-Real-IP  $remote_addr;&lt;/span&gt;&lt;span class=line id=LC3&gt;proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;&lt;/span&gt;&lt;span class=line id=LC4&gt;proxy_set_header Host $http_host;&lt;/span&gt;&lt;span class=line id=LC5&gt;proxy_redirect false;&lt;/span&gt;&lt;span class=line id=LC6&gt;if (-f $request_filename/index.html) {&lt;/span&gt;&lt;span class=line id=LC7&gt;rewrite (.*) $1/index.html break;&lt;/span&gt;&lt;span class=line id=LC8&gt;}&lt;/span&gt;&lt;span class=line id=LC9&gt;if (-f $request_filename.html) {&lt;/span&gt;&lt;span class=line id=LC10&gt;rewrite (.*) $1.html break;&lt;/span&gt;&lt;span class=line id=LC11&gt;}&lt;/span&gt;&lt;span class=line id=LC12&gt;if (!-f $request_filename) {&lt;/span&gt;&lt;span class=line id=LC13&gt;proxy_pass http://give_proxy_a_name;&lt;/span&gt;&lt;span class=line id=LC14&gt;break;&lt;/span&gt;&lt;span class=line id=LC15&gt;}&lt;/span&gt;&lt;span class=line id=LC16&gt;} &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/6c712c0f28c9c4ba397746f7f32999ae0eb7b0ee/gistfile4.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile4.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile4.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                                      &lt;/div&gt;
      
      
      &lt;p&gt;There are 3 IF statements to this bit, the first checks to see if an index.html file exists and if it does then nginx will serve it rather than passing it onto mongrel.&lt;/p&gt;
      
      &lt;p&gt;The 2nd IF does pretty much the same but it looks for a html file with the same name as the request. So say you requested &lt;strong&gt;site_name.com/about&lt;/strong&gt; it will attempt to find a file called &lt;strong&gt;about.html&lt;/strong&gt; in the public folder of the rails project and serve it rather than passing it onto mongrel. This means that if you're using page caching in rails you can skip mongrel for cached pages - very good on performance.&lt;/p&gt;
      
      &lt;p&gt;The 3rd IF makes sure the file doesn't exist before passing the request onto mongrel. For example say you requested &lt;strong&gt;site_name.com/images/logo.png&lt;/strong&gt; nginx would attempt to locate the file and serve it rather than passing the request on to mongrel, this means you can serve all your static content using nginx instead of mongrel which is much much quicker.&lt;/p&gt;
      
      &lt;p&gt;When you've setup your virtual host you need to create a symlink to the sites-enabled folder in order for it to work.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo ln -s /etc/nginx/sites-available/site_name /etc/nginx/sites-enabled/site_name&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/95a0474eacd46e5f9a03e171bbc120e43231effe/gistfile5.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile5.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile5.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                                          &lt;/div&gt;
      
      
      &lt;p&gt;And then finally restart the nginx server.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                      &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;sudo /etc/init.d/nginx restart&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/5940a35c3bd86173125661aadbd2370462d71c47/gistfile6.sh" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile6.sh" style="float:right;margin-right:10px;color:#666"&gt;gistfile6.sh&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                              &lt;/div&gt;
      
      
      &lt;p&gt;If all went OK you should be able to browse to your domain name and see your rails project. If not then make sure you created the link to the sites-enabled folder and also that you actually have some mongrel instances running on the IP's you defined (I think you'll get bad gateway messages if it can't find mongrel).&lt;/p&gt;
      
      &lt;p&gt;If you need help setting up mongrel head over to &lt;a href="http://articles.slicehost.com"&gt;slicehost's article&lt;/a&gt; page they have some good articles on how to do it.&lt;/p&gt;
      
      &lt;h2&gt;Extra configuration options&lt;/h2&gt;
      
      
      &lt;p&gt;There are a few extra configuration options in nginx that I use on 27smiles; gzip, expiry headers, on another site I also use HTTP authentication. I thought I'd list them here for some people.&lt;/p&gt;
      
      &lt;p&gt;If you're looking to setup gzip compression on nginx then add the following.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                  &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;gzip on;&lt;/span&gt;&lt;span class=line id=LC2&gt;gzip_min_length 1100;&lt;/span&gt;&lt;span class=line id=LC3&gt;gzip_buffers 4 8k;&lt;/span&gt;&lt;span class=line id=LC4&gt;gzip_proxied any;&lt;/span&gt;&lt;span class=line id=LC5&gt;gzip_types      text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;[/code]&lt;/span&gt;&lt;span class=line id=LC6&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;If you&amp;#39;re looking to set some expiry headers to images, etc in nginx try this.&lt;/span&gt;&lt;span class=line id=LC8&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;[code]location ~* ^.+\\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {&lt;/span&gt;&lt;span class=line id=LC10&gt;expires 30d;&lt;/span&gt;&lt;span class=line id=LC11&gt;break;&lt;/span&gt;&lt;span class=line id=LC12&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class=line id=LC13&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/20fa15840632a4e79fb8c51f36e4e3e55d8effbd/gistfile7.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile7.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile7.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;                  &lt;/div&gt;
      
      
      &lt;p&gt;And finally if you want to password protect domain try this.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                                                                                                              &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;auth_basic "Restricted";&lt;/span&gt;&lt;span class=line id=LC2&gt;auth_basic_user_file /path/to/htpasswd/file;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318945/b864b4b6b6addf0832f381434748ba24151ec4d1/gistfile8.txt" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318945#file_gistfile8.txt" style="float:right;margin-right:10px;color:#666"&gt;gistfile8.txt&lt;/a&gt;          &lt;a href="http://gist.github.com/318945"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;If you need any help or have any questions feel free to &lt;a href="http://27smiles.com/contact"&gt;contact me&lt;/a&gt;.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/05/22/setting-up-nginx-with-rails</feedburner:origLink></entry>
  <entry>
    <title>Come back in focus again</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/bR2qdXlpuds/come-back-in-focus-again" />
    <updated>2008-05-15T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-05-15:/2008/05/15/come-back-in-focus-again</id>
    <content type="html">
      &lt;p&gt;Off to see Kerry at Aber this weekend so thought I'd pump out a quick youtube Friday before I head off.&lt;/p&gt;
      
      &lt;p&gt;First off I thought I'd start with the Floyd, this is from division bell, which is one of my &lt;em&gt;favourite&lt;/em&gt; Pink Floyd album.&lt;/p&gt;
      
      &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/nVxnNNGjubg&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/nVxnNNGjubg&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
      
      &lt;p&gt;Next up a bit of Thom, not to sure if I've posted this before - I have yet to import posts from the old blog. I'm sure you can survive having to watch it again.....after all it is Thom :)&lt;/p&gt;
      
      &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Z1nFB-R-_gI&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Z1nFB-R-_gI&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
      
      &lt;p&gt;Finally I thought I'd post this video I found, I was orginally going to find Bob's version, and then the one thats playing at the end of the last season of Battlestar Galactica but instead I found this insane child playing it like a pro. Enjoy (All along the watch tower btw).&lt;/p&gt;
      
      &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_YEXMU711y0&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/_YEXMU711y0&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/05/15/come-back-in-focus-again</feedburner:origLink></entry>
  <entry>
    <title>Tinymce Syntaxhighlighter Plugin</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/9Ez_CBbcBCE/tinymce-syntaxhighlighter-plugin" />
    <updated>2008-04-07T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-04-07:/2008/04/07/tinymce-syntaxhighlighter-plugin</id>
    <content type="html">
      &lt;p&gt;I went to integrate &lt;a href="http://code.google.com/p/syntaxhighlighter/"&gt;Syntaxhighlighter&lt;/a&gt; into the site tonight, something I'd forgotten to do in the redesign and I thought it would be nice if I could just click a button in &lt;a href="http://tinymce.moxiecode.com/"&gt;tinymce&lt;/a&gt; and paste in the code, select a few options and click insert. Which of course is entirely possible so I've written a tinymce plugin to do just that.&lt;/p&gt;
      
      &lt;p&gt;I did encounter one little bug writing the plugin. When inserting the pasted code it kept repeating itself if there was currently no content in the body of the textarea (tinymce). I finally managed to fix it by putting a space at the end of the variable I was trying to insert (and with the power of highlighting here's what that looked like).&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nx"&gt;textarea_output&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;/textarea&amp;gt; &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cm"&gt;/* Note space */&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&lt;span class="nx"&gt;tinyMCEPopup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;editor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;mceInsertContent&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;textarea_output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;                  &lt;/span&gt;        &lt;span class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318869/9ba8cad21b020ff4acd1181f42e06e1cc86b985a/gistfile1.js" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318869#file_gistfile1.js" style="float:right;margin-right:10px;color:#666"&gt;gistfile1.js&lt;/a&gt;          &lt;a href="http://gist.github.com/318869"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/span&gt;      &lt;/span&gt;                      &lt;span class="gist-file"&gt;        &lt;span class="gist-data gist-syntax"&gt;                                          &lt;span class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nx"&gt;tinyMCE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"advanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC3&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"syntaxhl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC4&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code, syntaxhl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC5&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC6&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons3&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;remove_linebreaks&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC8&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;extended_valid_elements&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"textarea[cols|rows|disabled|name|readonly|class]"&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;&lt;span class="p"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318869/845080f10a25e2dd76cf7f6a82c8b45728650819/gistfile2.js" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318869#file_gistfile2.js" style="float:right;margin-right:10px;color:#666"&gt;gistfile2.js&lt;/a&gt;          &lt;a href="http://gist.github.com/318869"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;You can download the plugin from my &lt;a href="http://github.com/RichGuk/syntaxhl/tree/master"&gt;github account&lt;/a&gt;&lt;/p&gt;
      
      &lt;h2&gt;Getting it to work&lt;/h2&gt;
      
      &lt;p&gt;First you need to download &lt;a href="http://code.google.com/p/syntaxhighlighter/"&gt;Syntaxhighlighter&lt;/a&gt; and get that working by including the CSS file and Javascript files.&lt;/p&gt;
      
      &lt;h3&gt;Extract the plugin&lt;/h3&gt;
      
      &lt;p&gt;Next you need to extract the plugin to your tinymce plugin directory. When extracted it should be something like this:
      &lt;strong&gt;/path/to/tinymce/plugins/syntaxhl&lt;/strong&gt;&lt;/p&gt;
      
      &lt;h3&gt;Configure tinymce&lt;/h3&gt;
      
      &lt;p&gt;Finally we need to configure tinymce to use our plugin we also need to stop tinymce from stripping out &amp;lt;textarea&amp;gt;&amp;lt;/textarea&amp;gt; html tags as this is needed for Syntaxhighlighter.&lt;/p&gt;
      
      &lt;div class="gist"&gt;                          &lt;div class="gist-file"&gt;        &lt;div class="gist-data gist-syntax"&gt;                                          &lt;div class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nx"&gt;textarea_output&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;/textarea&amp;gt; &amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="cm"&gt;/* Note space */&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&lt;span class="nx"&gt;tinyMCEPopup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;editor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;mceInsertContent&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;textarea_output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;                  &lt;/span&gt;        &lt;span class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318869/9ba8cad21b020ff4acd1181f42e06e1cc86b985a/gistfile1.js" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318869#file_gistfile1.js" style="float:right;margin-right:10px;color:#666"&gt;gistfile1.js&lt;/a&gt;          &lt;a href="http://gist.github.com/318869"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/span&gt;      &lt;/span&gt;                      &lt;span class="gist-file"&gt;        &lt;span class="gist-data gist-syntax"&gt;                                          &lt;span class="gist-highlight"&gt;&lt;pre&gt;&lt;span class=line id=LC1&gt;&lt;span class="nx"&gt;tinyMCE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC2&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"advanced"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC3&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"syntaxhl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC4&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code, syntaxhl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC5&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC6&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;theme_advanced_buttons3&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC7&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;remove_linebreaks&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC8&gt;&amp;nbsp;&amp;nbsp;&lt;span class="nx"&gt;extended_valid_elements&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"textarea[cols|rows|disabled|name|readonly|class]"&lt;/span&gt;&lt;/span&gt;&lt;span class=line id=LC9&gt;&lt;span class="p"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;                  &lt;/div&gt;        &lt;div class="gist-meta"&gt;          &lt;a href="http://gist.github.com/raw/318869/845080f10a25e2dd76cf7f6a82c8b45728650819/gistfile2.js" style="float:right;"&gt;view raw&lt;/a&gt;          &lt;a href="http://gist.github.com/318869#file_gistfile2.js" style="float:right;margin-right:10px;color:#666"&gt;gistfile2.js&lt;/a&gt;          &lt;a href="http://gist.github.com/318869"&gt;This Gist&lt;/a&gt; brought to you by &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt;.        &lt;/div&gt;      &lt;/div&gt;      &lt;/div&gt;
      
      
      &lt;p&gt;We tell tinymce to use our plugin by adding &lt;strong&gt;syntaxhl&lt;/strong&gt; to the plugins list and also adding the &lt;strong&gt;syntaxhl&lt;/strong&gt; button to the buttons list also note that extended_valid_elements contains the textarea tag this tells tinymce to not remove it.&lt;/p&gt;
      
      &lt;p&gt;If all went well you should see a new highlighter icon button in tinymce and when you click it you should get a dialog popup allowing you to insert code into your content.&lt;/p&gt;
      
      &lt;p&gt;If you encounter any bugs then please create an issue on the &lt;a href="http://github.com/RichGuk/syntaxhl/tree/master"&gt;github account&lt;/a&gt; and any forks/patches are welcome!&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/04/07/tinymce-syntaxhighlighter-plugin</feedburner:origLink></entry>
  <entry>
    <title>Return of the Youtube Friday</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/Q5SwO92oaU4/return-of-the-youtube-friday" />
    <updated>2008-04-04T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-04-04:/2008/04/04/return-of-the-youtube-friday</id>
    <content type="html">
      &lt;p&gt;Wow, is what you're thinking eh? A final return of the &lt;a href="http://youtube.com/"&gt;youtube&lt;/a&gt; Friday, my weekly collection of music video's that I've listened to/watched throughout the week? Well yes... but I've decided to open the weekly event to more than just music...I've decided folks to open it up to any youtube video (what you're crazy!), that's right any video. Now before you all go shouting and all the craziness makes me want to become &lt;a href="http://en.wikipedia.org/wiki/Amish"&gt;Amish&lt;/a&gt; let me tell you this tonight's videos are of a music nature.&lt;/p&gt;
      
      &lt;h2&gt;Sleeping is the only love&lt;/h2&gt;
      
      &lt;p&gt;How fucking creepy are his eyes in this video? The first video tonight is from one of my favrioute musical bands. &lt;a href="http://en.wikipedia.org/wiki/Silver_Jews"&gt;Silver Jews&lt;/a&gt;. This song is off their 2005 album Tanglewood numbers (track number 6).&lt;/p&gt;
      
      &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/UVwamE7t_YQ&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/UVwamE7t_YQ&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
      
      &lt;h2&gt;Radiohead - 15 Steps (Seven)&lt;/h2&gt;
      
      &lt;p&gt;This video is funny with Thom in a box, yay. 15 Steps is from their latest album In Rainbows and this video was on one of their webcasts. You can checkout &lt;a href="http://greenplastic.com"&gt;greenplastic.com&lt;/a&gt; or &lt;a href="http://ateaseweb.com"&gt;ateaseweb.com&lt;/a&gt; for some Radiohead fan sites.&lt;/p&gt;
      
      &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/W1ASzwriBOw&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/W1ASzwriBOw&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/04/04/return-of-the-youtube-friday</feedburner:origLink></entry>
  <entry>
    <title>New Site and the holiday</title>
    <link href="http://feedproxy.google.com/~r/27smiles/~3/xbworH075qc/new-site-and-the-holiday" />
    <updated>2008-04-02T00:00:00+01:00</updated>
    <id>tag:27smiles.com,2008-04-02:/2008/04/02/new-site-and-the-holiday</id>
    <content type="html">
      &lt;h2&gt;New website&lt;/h2&gt;
      
      &lt;p&gt;I've finally fixed the website, from that file I deleted. True it wouldn't of required that much effort to fix but I thought I'd give the site a re-code/design while I was at it - I seem to have a habit of that but anyhow since I've improved on my &lt;a href="http://rubyonrails.org/" title="Ruby on Rails"&gt;Rails&lt;/a&gt; skills since the last code this build went much smoother which leads nicely into the next change. The layout.&lt;/p&gt;
      
      &lt;p&gt;I'm sure you have noticed the new layout but I bet you did know that it in fact changes between a night theme and a day theme at 6AM or 6PM.... but if you prefer one theme over the other why not click one of those little icons in the top right? They change the theme to whatever one you choose for that session (while the browser is open) you can even switch back to the time based theme if you prefer that.&lt;/p&gt;
      
      &lt;p&gt;You'll also notice the &lt;a href="http://flickr.com" title="Flickr"&gt;flickr&lt;/a&gt;, &lt;a href="http://twitter.com" title="Twitter"&gt;Twitter&lt;/a&gt; and &lt;a href="http://last.fm" title="Last.fm"&gt;last.fm&lt;/a&gt; integration on the right of the page. Apart from twitter they are all pulled in from an RSS feed and then using fragment caching with memcache in rails to do some time based caching so the flickr feed is updated every hour and the last.fm one every 5 minutes. I will talk more about how I did this in a later post.&lt;/p&gt;
      
      &lt;p&gt;The twitter feed is updated/imported using their javascript code so that should be real time. Oh and about twitter I've finally decided I'd get one after months of thinking hmmm is there much point in telling people what I'm doing all the time? Well I thought meh why not? People don't have to read it and its something all the 'cool' kids are doing.&lt;/p&gt;
      
      &lt;h2&gt;Holiday&lt;/h2&gt;
      
      &lt;p&gt;So for the past two week I've had some time off work and was lucky enough to spend 5 days in Edinburgh and 3 days in London with my girl friend (Kerry). Both trips went smoothly and a I thoroughly enjoyed both (I even enjoyed London :o).&lt;/p&gt;
      
      &lt;p&gt;&lt;a href="http://flickr.com/photos/richguk/sets/72157604336233579/"&gt;&lt;img style="float: left; border: 1px solid black; margin: 5px;" src="http://farm4.static.flickr.com/3201/2378743948_a590f79f15_m.jpg" alt="National Portrait Gallary (Edinburgh)" width="240" height="180" /&gt;&lt;/a&gt;&lt;/p&gt;
      
      &lt;p&gt;Edinburgh is both amazing and beautiful me and Kerry had a fantastic time here looking around both the city, art galleries and museums of which there are lots! We took a &lt;a href="http://flybe.com"&gt;Flybe&lt;/a&gt; flight up to Edinburgh from Birmingham on a small plane which was nice. When we arrived in Edinburgh they had a very handy and excellent bus service from the airport which took us all the way into the centre, the buses run every 10 minutes - I really did think this was excellent. We stopped in the &lt;a href="http://www.royal-garden.co.uk"&gt;Royal Garden Apartments&lt;/a&gt; which was a very nice apartment. The apartment was but 5 minute walk from Prince's Street and any shops we needed also being close to most of the attractions. Oh and the &lt;a href="http://www.nationalgalleries.org/visit/page/2:298:3"&gt;national portrait gallery&lt;/a&gt; was right opposite the apartment so of course we went there first =) (left image was view from the window).&lt;/p&gt;
      
      &lt;p&gt;On the second day we went to &lt;a href="http://en.wikipedia.org/wiki/Edinburgh_Castle"&gt;Edinburgh castle&lt;/a&gt;, although I'd been before I was quite young so I only remembered bits so going again was a very fun day out, it also meant I got to take lots of pictures and blend in with all the cute Japanese tourists taking all their pictures. The castle was quite busy as you expect though there were a lot of school trips there with all these Scottish kids, I love the Scottish accent its cute.
      &lt;a title="Part of Edinburgh Castle" href="http://flickr.com/photos/richguk/2377941991/in/set-72157604336233579/"&gt;&lt;img style="float: right; border: 1px solid black; margin: 5px;" src="http://farm4.static.flickr.com/3163/2377941991_0ef3a9cd05_m.jpg" alt="Part of Edinburgh Castle" width="240" height="240" /&gt;&lt;/a&gt;&lt;/p&gt;
      
      &lt;p&gt;On the third day we decided to visit all the galleries - &lt;a href="http://www.nationalgalleries.org/visit/page/2:114:2"&gt;national&lt;/a&gt;, &lt;a href="http://www.nationalgalleries.org/visit/page/2:118:4/"&gt;modern&lt;/a&gt;, etc... these were spread all over the city so it took all day to get around. They were quite interesting but I'm sure Kerry enjoyed/appreciated them more so than I.&lt;/p&gt;
      
      &lt;p&gt;On the fourth day we went to the &lt;a href="http://www.nms.ac.uk/"&gt;Museum of Scotland&lt;/a&gt; and the &lt;a href="http://www.nms.ac.uk/royal_museum_project.aspx"&gt;Royal Museum&lt;/a&gt;, which are attached, these were both very interesting and fun :), while being quite big and hard to navigate around at the same time.&lt;/p&gt;
      
      &lt;p style="text-align: center;"&gt;&lt;a href="http://flickr.com/photos/richguk/sets/72157604336233579/"&gt;&lt;img style="border: 1px solid black; margin: 5px;" src="http://farm3.static.flickr.com/2219/2377948369_e7c9db3d99.jpg" alt="Edinburgh" width="500" height="375" /&gt;&lt;/a&gt;&lt;/p&gt;
      
      
      &lt;p&gt;&lt;a href="http://flickr.com/photos/richguk/sets/72157604336891673/"&gt;&lt;img style="float: left; border: 1px solid black; margin: 5px;" src="http://farm3.static.flickr.com/2098/2378049683_8fda0299ce_m.jpg" alt="London Art Gallary" width="240" height="180" /&gt;&lt;/a&gt;
      The 3 days we spent in London were very fun too, again we visited the &lt;a href="http://www.nationalgallery.org.uk"&gt;art gallery&lt;/a&gt; and the &lt;a href="www.nhm.ac.uk"&gt;natural history museum&lt;/a&gt; which were both very big and full of interesting paintings and animals the real excitement of course for me was the &lt;a href="http://www.sciencemuseum.org.uk/"&gt;science museum&lt;/a&gt; :D getting to play with all the interactive stuff like a little child, amazing amounts fun indeed. Although we did get evacuated from the building for some reason, and I'd love to know why lucky for us though we were in the last room.&lt;/p&gt;
      
      &lt;p&gt;&lt;a href="http://flickr.com/photos/richguk/sets/72157604336891673/"&gt;&lt;img style="float: right; border: 1px solid black; margin: 5px;" src="http://farm3.static.flickr.com/2218/2378917524_3c90a0d87c_m.jpg" alt="London Natural History" width="180" height="240" /&gt;&lt;/a&gt;
      The tube was not to bad at all, we found our way around with ease and although it got a little busy now and then majority of the time it was pretty empty. Also for some strange reason unbeknown to me I like the smell at the tube station, must be all that unclean air plus the tube kinda reminds me of the 60's, maybe its because the icon looks all retro.&lt;/p&gt;
      
      &lt;p&gt;So all in all the holiday's went very well and I enjoyed both lots and lots, although going back to work was a shock to the system.&lt;/p&gt;
    </content>
  <feedburner:origLink>http://27smiles.com//2008/04/02/new-site-and-the-holiday</feedburner:origLink></entry>
</feed>
