<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Matt Fawcett</title>
    <link>http://matthewfawcett.co.uk</link>
    <atom:link type="application/rss+xml" href="http://matthewfawcett.co.uk/articles.rss" rel="self"/>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Playing with Node.js</title>
      <description>&lt;p&gt;Today I decided to have a look at &lt;a href="http://nodejs.org/"&gt;Node.js&lt;/a&gt;. I have heard quite a lot about it but have avoided looking at it for a while. Node.js provides a way of building server side network programs, written in Javascript. I took a look at a tutorial over at &lt;a href="http://simonwillison.net/2009/Nov/23/node/"&gt;http://simonwillison.net/2009/Nov/23/node/&lt;/a&gt; for installing Node and building a simple Hello World web service. I ran an apache benchmark test and was suprised with the results. I managed to get 6075 requests per second on my Macbook Pro!&lt;/p&gt;

&lt;p&gt;To compare it with something that I'm used to, I wrote the same Hello World script service Sinatra and served it up using the thin webserver, which gave me 1606 requests per second which is quite a difference.&lt;/p&gt;

&lt;p&gt;The 2 scripts and apache benchmark outputs are below:&lt;/p&gt;

&lt;script src="http://gist.github.com/309322.js"&gt;&lt;/script&gt;


</description>
      <pubDate>Fri, 19 Feb 2010 22:47:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c59ed839-e749-418b-ac71-a1a213773546</guid>
      <comments>http://matthewfawcett.co.uk/2010/02/19/playing-with-node-js#comments</comments>
      <category>node.js</category>
      <category>sinatra</category>
      <link>http://matthewfawcett.co.uk/2010/02/19/playing-with-node-js</link>
    </item>
    <item>
      <title>Installing Prey on snow leapord</title>
      <description>&lt;p&gt;Today I decided to install &lt;a href="http://preyproject.com"&gt;Prey&lt;/a&gt; on my mac book. &lt;a href="http://preyproject.com"&gt;Prey&lt;/a&gt; is basically a bash script that runs from a cron job every 10 minutes or so. It contacts a remote server to ask if the computer is stolen or not and if so can send a screenshot of the desktop and also a photo from the webcam as well as providing the IP address of the thief.&lt;/p&gt;

&lt;p&gt;Prey does have the ability to have the data sent to their website but I decided to handle this myself and have the script email the data if a webpage I have set up on my domain gets deleted. I ran into a few problems getting the script to email me, it uses a perl script called &lt;a href="http://caspian.dotconf.net/menu/Software/SendEmail/"&gt;sendEmail&lt;/a&gt;. I banged my head against a wall getting errors from Google like &amp;#8220;Username and Password not accepted.&amp;#8221; even though everything was correct. The solution was do download the latest version of SendEmail from http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz, extract and replace the file called sendEmail in /usr/share/prey/lib/ with the new one.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Nov 2009 21:48:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e3a7cdbf-1c8a-43ce-9cd8-dd7e7c98a8bd</guid>
      <comments>http://matthewfawcett.co.uk/2009/11/05/installing-prey-on-snow-leapord#comments</comments>
      <link>http://matthewfawcett.co.uk/2009/11/05/installing-prey-on-snow-leapord</link>
    </item>
    <item>
      <title>Use a PHPBB forum to handle user authentication in your rails app</title>
      <description>&lt;p&gt;Im currently in the process of rebuilding &lt;a href="http://www.realalehunter.co.uk"&gt;www.realalehunter.co.uk&lt;/a&gt; in rails. Its currently uses PHPBB to handle logging in and authentication so to make the rebuild simpler I thought keep it working in the same way instead of trying to migrate all the users/passwords to a separate system.&lt;/p&gt;


&lt;p&gt;So I wrote a rails gem / plugin to make this a bit easier. It currently works on Rails &amp;gt; 2.3.3. I decided that I still wanted to have a users table in my applications database to make relationships easier but I would just store the stuff that&amp;#8217;s important to the app itself (not passwords etc). So if you visit the rails site and are logged in to the forum a user will also be created in your rails app database if one does not exist.&lt;/p&gt;


&lt;p&gt;So here is how to get started:&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;# install the gem
gem install mattfawcett-phpbb-auth&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;p&gt;Tell rails that you want to use the gem it by adding the following to your environment.rb&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;config.gem &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;mattfawcett-phpbb-auth&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:lib&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;phpbb_auth&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:source&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;http://gems.github.com&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;br/&gt;


&lt;p&gt;Add an entries to database.yml for phpbb_database_development, phpbb_database_production and  phpbb_database_development.&lt;/p&gt;


&lt;p&gt;In your config directory create a file called phpbb_auth_settings.rb, copy whats below into the file and change to  match your setup.&lt;/p&gt;


&lt;p&gt;
&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;&lt;span class="co"&gt;PHPBB_AUTH_FORUM_DATABASE_TABLE_PREFIX&lt;/span&gt; = &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;phpbb_&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class="co"&gt;PHPBB_AUTH_COOKIE_NAME&lt;/span&gt; = &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;phpbb3_7uah4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;; 
&lt;span class="co"&gt;PHPBB_AUTH_LOCAL_USER_MODEL_NAME&lt;/span&gt; =&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;User&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class="c"&gt;#this is the name of the model that you will use to store information about  users in your rails app &lt;/span&gt;
&lt;span class="co"&gt;PHPBB_AUTH_REMOTE_REMOTE_IDENTIFIER&lt;/span&gt; = &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;user_email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class="c"&gt;#I use email to identify somebody, you may want to use the username  instead &lt;/span&gt;
&lt;span class="co"&gt;PHPBB_AUTH_REMOTE_LOCAL_IDENTIFIER&lt;/span&gt; = &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class="c"&gt;#this is the name of a field on your local user model that will be used to  lookup the value of remote identifier.&lt;/span&gt;
&lt;span class="co"&gt;PHPBB_AUTH_COLUMNS_TO_DUPLICATE&lt;/span&gt; = {&lt;span class="sy"&gt;:user_website&lt;/span&gt; =&amp;gt; &lt;span class="sy"&gt;:website&lt;/span&gt;} &lt;span class="c"&gt;#specify any additional fields that you would like copying  to your local user model &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;




&lt;p&gt;In application_controller.rb, include the module&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;include &lt;span class="co"&gt;PhpbbAuth&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;




&lt;p&gt;How you handle the rest is up to you but here&amp;#8217;s what I did. Create a method called set_current_user.&lt;p&gt;
&lt;p&gt;
&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;&lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;set_current_user&lt;/span&gt;   
  &lt;span class="iv"&gt;@current_user&lt;/span&gt; = current_user 
&lt;span class="r"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;Add a before filter to the controller to run the method.&lt;/p&gt;
&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;before_filter &lt;span class="sy"&gt;:set_current_user&lt;/span&gt; &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You will then have access to the @current_user variable in your controllers and views. This will be either nil if the  user is not logged in, or an instance of your local User.&lt;/p&gt;
&lt;p&gt;The source is up on &lt;a href="http://github.com/mattfawcett/phpbb-auth/tree/master"&gt;Github&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Mon, 31 Aug 2009 12:12:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b41b76c2-51b4-43a4-9995-2801fe3616a6</guid>
      <comments>http://matthewfawcett.co.uk/2009/08/31/use-a-phpbb-forum-to-handle-users-authentication-in-your-rails-app#comments</comments>
      <category>ruby</category>
      <category>rails</category>
      <category>phpbb</category>
      <category>authentication</category>
      <category>auth</category>
      <category>users</category>
      <link>http://matthewfawcett.co.uk/2009/08/31/use-a-phpbb-forum-to-handle-users-authentication-in-your-rails-app</link>
    </item>
    <item>
      <title>Monit Aggregator - A Sinatra interface for Monit</title>
      <description>&lt;p&gt;I use Monit to keep an eye on server processes and restart them if they go down. It comes with a useful web interface that gives you an overview of your servers health, and what processes are up/down. If you have a lot of servers then it can be a bit of a pain because you have to access each web Interface with a different URL.&lt;/p&gt;


&lt;p&gt;This weekened I wrote a Sinatra app that aggregates the data from each web interface and displays it all on one page. The source is on &lt;a href="http://github.com/mattfawcett/monit-aggregator/tree/master"&gt;Github&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;It currently does not support HTTPS, and it only currently displays the overall system and individual processes. &lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;To get going, install the dependant gems&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;gem install sinatra nokogiri haml&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;Now clone the repo&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;git clone git://github.com/mattfawcett/monit-aggregator.git&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;Then edit the monit_installations.yml file to include the details of each of your Monit web servers. To start the app running just type&lt;/p&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;ruby app.rb&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;Open your browser to http://yourdomain.com:4567&lt;/p&gt;


&lt;p&gt;Alternatively you could run with Passenger.&lt;/p&gt;


&lt;p&gt;There is also a free hosted version available on my server monitoring site &lt;a href="http://runslikeclockwork.com"&gt;Runs Like Clockwork&lt;/a&gt;&lt;/p&gt;


</description>
      <pubDate>Sun, 05 Jul 2009 16:41:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ad7683d1-1118-4d60-869d-c157ba19a17c</guid>
      <comments>http://matthewfawcett.co.uk/2009/07/05/monit-aggregator-a-sinatra-interface-for-monit#comments</comments>
      <category>monit</category>
      <category>aggregator</category>
      <category>sinatra</category>
      <category>ruby</category>
      <trackback:ping>http://matthewfawcett.co.uk/trackbacks?article_id=10</trackback:ping>
      <link>http://matthewfawcett.co.uk/2009/07/05/monit-aggregator-a-sinatra-interface-for-monit</link>
    </item>
    <item>
      <title>s3ify gem - put the assets for a HTML email online</title>
      <description>&lt;p&gt;I often have to deal with setting up email sends, which usually involves getting a zip file from a designer containing a html file and some images. I usually unzip, convert all the image references to point to an S3 path, upload the whole folder to S3 using S3fox, and change the permissions to be publicly readable.&lt;/p&gt;

&lt;p&gt;This is a bit repetitive and manual for my liking so I wrote a small ruby gem to make it a bit simpler. It uses &lt;a href="http://github.com/tenderlove/nokogiri/tree/master"&gt;Nokogiri&lt;/a&gt; to parse the HTML (so you will need a recent version of libxml) and the &lt;a href="http://amazon.rubyforge.org/"&gt;aws-s3 gem&lt;/a&gt;  to upload everything to S3. I used the &lt;a href="http://github.com/visionmedia/commander/tree/master"&gt;commander gem&lt;/a&gt; to create a command line interface to use it.&lt;/p&gt;

&lt;p&gt;So first, get it installed&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;sudo gem install mattfawcett-s3ify&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;You will need to have your Amazon web services access information set in your path, if you don&amp;#8217;t have this already, your best bet is to create a hidden file in your home directory called .amazon_keys with the contents&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;export AMAZON_ACCESS_KEY_ID='abcdefghijklmnop'
export AMAZON_SECRET_ACCESS_KEY='1234567891012345'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;then add the following to your shell&amp;#8217;s rc file (usually .bashrc)&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;if [[ -f &amp;quot;$HOME/.amazon_keys&amp;quot; ]]; then
    source &amp;quot;$HOME/.amazon_keys&amp;quot;;
fi&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;Then to use it simply open up a shell and type&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;s3ify -b my_bucket -p my_folder_in_bucket ~/Desktop/my-email/ &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The -b flag is the bucket you wish to upload to, the -p flag is the path in the bucket that you want to upload to and finally you declare the path to the folder where your HTML email is on the file system. For each HTML file, the gem will create an additional file with the prefix of &amp;#8220;_s3&amp;#8221; which will have the image references pointing to S3.&lt;/p&gt;

&lt;p&gt;The code is on &lt;a href="http://github.com/mattfawcett/s3ify/tree/master"&gt;Github&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 27 Jun 2009 12:35:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c260bf98-fcba-48d9-b24c-5c49819a2018</guid>
      <comments>http://matthewfawcett.co.uk/2009/06/27/s3ify-gem-put-the-assets-for-a-html-email-online#comments</comments>
      <category>s3ify</category>
      <category>ryby</category>
      <category>gems</category>
      <category>rubygems</category>
      <category>html</category>
      <category>email</category>
      <trackback:ping>http://matthewfawcett.co.uk/trackbacks?article_id=9</trackback:ping>
      <link>http://matthewfawcett.co.uk/2009/06/27/s3ify-gem-put-the-assets-for-a-html-email-online</link>
    </item>
    <item>
      <title>Server Monitoring with SMS alerts</title>
      <description>&lt;p&gt;
For the last few weeks Iv been working on a new website in my spare time. Its now live and is at &lt;a href="http://runslikeclockwork.com"&gt;runslikeclockwork.com&lt;/a&gt;. Its a server monitoring tool where you add your sites and you will get an SMS alert when a site goes down / comes back up again. 
&lt;/p&gt;




&lt;p&gt;
Its slightly different from most other services because it checks the rendered HTML of a page for a keyword or phrase specific to that site. This covers you when you misconfigure an Apache/Nginx Virtualhost which can sometimes leave you with the wrong site being served on a domain, but of course the server is still giving out 200 status headers.
&lt;/p&gt;




&lt;p&gt;
At the moment its very simple but I am planning on adding some more features over the next few weeks.
&lt;/p&gt;


</description>
      <pubDate>Sun, 07 Jun 2009 17:02:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7593ab61-a9ef-4bea-aa6b-d1263fd93620</guid>
      <comments>http://matthewfawcett.co.uk/2009/06/07/server-monitoring-with-sms-alerts#comments</comments>
      <category>sms</category>
      <category>server</category>
      <category>monitoring</category>
      <link>http://matthewfawcett.co.uk/2009/06/07/server-monitoring-with-sms-alerts</link>
    </item>
    <item>
      <title>spree-phpbb-auth - Use an existing phpbb forum for users/authentication with a Spree shopping cart</title>
      <description>&lt;p&gt;Im in the process of setting up a Spree shopping cart on an existing site which uses a phpbb forum for storing all users and logging in etc. I wanted the existing users of the site to be able to purchase from the shopping cart area without having to go through another sign up process and have 2 sets of usernames and passwords so iv created a Spree extension called &lt;a href="http://github.com/mattfawcett/spree-phpbb-auth"&gt;spree-phpbb-auth&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;The extension looks for the phpbb session cookie and looks it up in the forum database, if the user is unknkown to the spree application, a user will be created within Spree in the background. The standard Spree authentication system is then used to set that users session up to declare them as being logged in. It overwrites the existing login /logout/register/edit my account actions so that they redirect to the phpbb equivalents.&lt;/p&gt;


&lt;p&gt;Its not being used in Production yet but it all seems to work ok locally. There are a few issues that I can think of&lt;/p&gt;


&lt;ol&gt;
    &lt;li&gt;Won&amp;#8217;t work accross different domains (should work on subdomains if you set the cookie domain to be &amp;quot;.site.com&amp;quot; instead of &amp;quot;forum.site.com&amp;quot;)&lt;/li&gt;
    &lt;li&gt;All users that get automatically added to the Spree users table get assigned to the group &amp;quot;users&amp;quot; so it doesn&amp;#8217;t look at the phpbb permissions at all.&lt;/li&gt;
    &lt;li&gt;If you allow your phpbb user to change email addressess then when they hit the cart after a change, they will be registed as a new user.&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;Installing&lt;/h3&gt;


&lt;ul&gt;
    &lt;li&gt;script/extension install git://github.com/mattfawcett/spree-phpbb-auth.git&lt;/li&gt;
    &lt;li&gt;Change the contents of config/phpbb_auth_settings.rb&lt;/li&gt;
    &lt;li&gt;Add an entry to your database.yml file for &amp;quot;phpbb_database_production&amp;quot;&lt;/li&gt;
&lt;/ul&gt;


</description>
      <pubDate>Sun, 22 Mar 2009 13:58:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7d7cce36-edc3-4550-9465-140d77b27e7e</guid>
      <comments>http://matthewfawcett.co.uk/2009/03/22/spree-phpbb-auth-use-an-existing-phpbb-forum-for-users-authentication-with-a-spree-shopping-cart#comments</comments>
      <category>spree</category>
      <category>ruby</category>
      <category>rails</category>
      <category>phpbb</category>
      <link>http://matthewfawcett.co.uk/2009/03/22/spree-phpbb-auth-use-an-existing-phpbb-forum-for-users-authentication-with-a-spree-shopping-cart</link>
    </item>
    <item>
      <title>Sync your rails development environment data with production or staging</title>
      <description>&lt;p&gt;When your developing a web app, you usually end up with lots of duff data both in your database and file system from when you have been testing inserting data and uploading files when things have been half implemented. Usually its a good idea to take a fresh database dump from your production server and download the assets (or whatever you call the directory where user uploads go) so that you actually have some real data.&lt;/p&gt;


&lt;p&gt;This is usually a bit of a pain to do as you need to ssh in to dump the database, SCP the assets. It also forces you to develop using a MySQL database if thats what your production server uses.&lt;/p&gt;


&lt;p&gt;Adam Wiggins has released a plugin called &lt;a href="http://github.com/adamwiggins/yaml_db/tree/master"&gt;yaml_db&lt;/a&gt; that allows you to dump and import your database into/from YAML format. Today I wrote a quick rake task that connects to your production or staging over SSH, runs the task to dump the YAML file (rake db:data:dump) and then downloads it locally with SFTP. It then runs the rake task to import the data (rake db:data:load). It also uses Rsync to sync any asset or other folders on your remote server that are installation specific to your local development environment.&lt;/p&gt;


&lt;p&gt;At the moment the only downside to the script is that it calls rsync from the shell which asks you to type your password. It would be good to have it all inclusive within the script, but that doesn&amp;#8217;t seem possible with rsync. The &lt;a href="http://gist.github.com/72340"&gt;script is a gist on Github&lt;/a&gt;&lt;/p&gt;


&lt;script src="http://gist.github.com/72340.js"&gt;&lt;/script&gt;


</description>
      <pubDate>Sun, 01 Mar 2009 14:51:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a903f0f1-1213-4cfc-b54d-93d33bc4f179</guid>
      <comments>http://matthewfawcett.co.uk/2009/03/01/sync-your-rails-development-environment-data-with-production-or-staging#comments</comments>
      <link>http://matthewfawcett.co.uk/2009/03/01/sync-your-rails-development-environment-data-with-production-or-staging</link>
    </item>
    <item>
      <title>Hoptoad notifier for PHP applications</title>
      <description>&lt;p&gt;I recently started using &lt;a href="http://www.hoptoadapp.com"&gt;Hoptoad&lt;/a&gt; to in my ruby/rails projects that notifies you of any exceptions that your app throws. Unlike other solutions such as the exception notifier plugin, if an error occurs hundreds of times you just get 1 email to let you know. You can then login to Hoptoad and set it to resolved.&lt;/p&gt;


&lt;p&gt;I thought this would be also good to use in PHP applications as well and they do provide an API for you to use. I found a project on Github called &lt;a href="http://github.com/rich/php-hoptoad-notifier/tree/master"&gt;php-hoptoad-notifier&lt;/a&gt; by Rich Cavanaugh. I gave it a go but it relied on a couple of PEAR packages being installed and as I don&amp;#8217;t fancy installing them on lots of servers. Iv forked and modified it to be its own standalone code base. It now just relies on the PHP curl module. &lt;/p&gt;


&lt;p&gt;Here it is:&lt;a href="http://github.com/mattfawcett/php-hoptoad-notifier/tree/master"&gt; http://github.com/mattfawcett/php-hoptoad-notifier/tree/master&lt;/a&gt;&lt;/p&gt;


</description>
      <pubDate>Tue, 03 Feb 2009 08:07:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:667cb0a7-3d74-46ea-a793-83417d5a2b61</guid>
      <comments>http://matthewfawcett.co.uk/2009/02/03/hoptoad-notifier-for-php-applications#comments</comments>
      <link>http://matthewfawcett.co.uk/2009/02/03/hoptoad-notifier-for-php-applications</link>
    </item>
    <item>
      <title>My first Ruby gem - ruby-reads-php</title>
      <description>&lt;p&gt;Iv being meaning to experiment with building my own Ruby Gems for a while now but have been too busy to actually give it ago. This weekend I took the plunge and wrote a gem called &lt;a href="https://github.com/mattfawcett/ruby-reads-php/tree"&gt;ruby-reads-php&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Iv got quite a lot of applications and websites online that are written in PHP and most of them have some kind of configuration file to define things like database settings to keep everything in one place. I occasionally want to bolt an extra temporary feature onto an app (eg for the next month send a CSV file of people registered to somebody by email).&lt;/p&gt;


&lt;p&gt;As Ruby is now my language of choice for most things and due to the fact that I could do something like this faster in Ruby than PHP it makes sense for me to do so. The problem I have is that I need to replicate my database configurations into a Ruby file which isn&amp;#8217;t very &lt;a href="http://www.artima.com/intv/dry.html"&gt;DRY&lt;/a&gt;. I could convert into a more standardised format such as &lt;a href="http://www.yaml.org"&gt;YAML&lt;/a&gt; but this would mean changing the PHP code that I know currently works.&lt;/p&gt;


&lt;p&gt;So this gives me an ideal oppertunity to write a Ruby Gem. I wrote some Rspec tests for what I wanted to do and then wrote the code. I used TechnicalPickles &lt;a href="http://github.com/technicalpickles/jeweler/tree/master"&gt;Jeweler&lt;/a&gt; gem to manage my Gem Spec and publish to &lt;a href="http://github.com/mattfawcett"&gt;Github&lt;/a&gt;. Within 15 minutes my Gem is available to download&lt;/p&gt;


&lt;h3&gt;To install it&lt;/h3&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt; 
#First add Github to your gem sources 
gem sources -a http://gems.github.com 
#Now install the Gem 
gem install mattfawcett-ruby-reads-php &lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;h3&gt;To use it&lt;/h3&gt;


&lt;p&gt;&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;   
&lt;span class="c"&gt;#require rubygems and the ruby_reads_php gem   &lt;/span&gt;
require &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;rubygems&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;   
require &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;ruby_reads_php&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;      

&lt;span class="c"&gt;#load and parse your PHP configuration file   &lt;/span&gt;
config = &lt;span class="co"&gt;RubyReadsPHP&lt;/span&gt;.read(&lt;span class="co"&gt;File&lt;/span&gt;.dirname(&lt;span class="pc"&gt;__FILE__&lt;/span&gt;) + &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;/config.php&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)  
my_database_hostname = config.constants[&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;DB_HOST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;] &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


&lt;br/&gt;&lt;br/&gt;


&lt;h3&gt;
Example PHP configuration file (config.php)
&lt;/h3&gt;


&lt;p&gt;
&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt; 
&lt;span class="idl"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="pd"&gt;define&lt;/span&gt;(&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;DB_HOST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; ,&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;localhost&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;);
&lt;span class="pd"&gt;define&lt;/span&gt;(&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;DB_USER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; ,&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;web&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;);
&lt;span class="pd"&gt;define&lt;/span&gt;(&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;DB_USER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; ,&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;my_password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;);
&lt;span class="idl"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/p&gt;




&lt;p&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;At the moment it only supports constants but could be built on to handle arrays etc. Please feel free to fork, hack, send pull request.&lt;/p&gt;


</description>
      <pubDate>Sat, 24 Jan 2009 23:52:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:9a39e877-89da-4dca-9d9c-35415c285aa4</guid>
      <comments>http://matthewfawcett.co.uk/2009/01/24/my-first-ruby-gem-ruby-reads-php#comments</comments>
      <link>http://matthewfawcett.co.uk/2009/01/24/my-first-ruby-gem-ruby-reads-php</link>
    </item>
  </channel>
</rss>
