<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DavidCraddock.net</title>
	<atom:link href="http://www.davidcraddock.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidcraddock.net</link>
	<description>My Technology Site</description>
	<lastBuildDate>Wed, 10 Mar 2010 07:21:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Changing the default &#8220;From:&#8221; email address for emails sent via PHP on Linux</title>
		<link>http://www.davidcraddock.net/2010/03/10/changing-the-default-from-email-address-for-php/</link>
		<comments>http://www.davidcraddock.net/2010/03/10/changing-the-default-from-email-address-for-php/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 06:36:26 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=475</guid>
		<description><![CDATA[I&#8217;ve had to solve this problem a couple of times at least, and it&#8217;s quite a common task, so I thought I&#8217;d document it here.
When you send emails to users of your site through using the PHP mail() function, they will sometimes turn up in the mailbox of customers of your site with the following [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had to solve this problem a couple of times at least, and it&#8217;s quite a common task, so I thought I&#8217;d document it here.</p>
<p>When you send emails to users of your site through using the PHP mail() function, they will sometimes turn up in the mailbox of customers of your site with the following from address:</p>
<pre>From: Root &lt;root@apache.ecommercecompany.com&gt;</pre>
<p>This makes absolutely no sense to your customers, and often they will think it is spam and delete it. Often, the decision will be made for them by their web mail host, such as hotmail.com or googlemail.com, and they will never even see the email. You don&#8217;t want this to happen.</p>
<p>Writing email templates that appear &#8220;trustworthy&#8221; and have a low chance of being mislabled as spam by the webmail companies, is quite a difficult task, and there&#8217;s quite a bit to know about it. However it is quite easy to change the default &#8220;From:&#8221; email address that PHP sends your emails on as, and that will definitely help.</p>
<p>Assuming you&#8217;re running a linux server using sendmail, all you have to do is this.</p>
<p>First create an email address that you would want the customers to see, through editing the /etc/aliases files and running the command newaliases. I created an email address called <b>customer-emails@ecommercecompany.com</b>.</p>
<p>Then change the following sendmail_path line in your php.ini file to something like this:</p>
<p>/etc/php.ini<br />
<code>...<br />
sendmail_path = /usr/sbin/sendmail -t -i -F 'customer-emails' -f 'Customer Emails &lt;customer-emails@ecommercecompany.com&gt;'<br />
...<br />
</code></p>
<p>Broken down, those extra options are:<br />
<code>-F 'customer-emails' # the from email address, which has to be valid<br />
-f 'Customer Emails &lt;customer-emails@ecommercecompany.com&gt;' # the email From header, which should have the name matching the email address, and it should be the same email address as above<br />
</code></p>
<p>Then restart apache, and it should load the php.ini file changes. Test it by sending a couple of emails to your email address, and you should see emails sent out like this:</p>
<pre>From: Customer Emails &lt;customer-emails@ecommercecompany.com&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/03/10/changing-the-default-from-email-address-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell scripts for converting between Unix and Windows text file formats</title>
		<link>http://www.davidcraddock.net/2010/03/09/shell-scripts-for-converting-between-unix-and-windows-text-file-formats/</link>
		<comments>http://www.davidcraddock.net/2010/03/09/shell-scripts-for-converting-between-unix-and-windows-text-file-formats/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 00:04:40 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=461</guid>
		<description><![CDATA[I&#8217;ve been using these shell scripts I wrote to convert between unix and windows text file formats. They seem to work well without any problems. If you put them in the /usr/sbin/ directory, they will be accessible on the path of the linux admin account root.
/usr/sbin/unix2win
#!/bin/bash
# Converts a unix text file to a windows text [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using these shell scripts I wrote to convert between unix and windows text file formats. They seem to work well without any problems. If you put them in the /usr/sbin/ directory, they will be accessible on the path of the linux admin account root.</p>
<p>/usr/sbin/unix2win<br />
<code>#!/bin/bash<br />
# Converts a unix text file to a windows text file.<br />
# usage: unix2win &lt;text file to convert&gt;<br />
# requirements: sed version 4.2 or later, check with sed --version<br />
sed -i -e 's/$/\r/' $1<br />
</code> </p>
<p>/usr/sbin/win2unix<br />
<code>#!/bin/bash<br />
# Converts a windows text file to a unix text file.<br />
# usage: win2unix &lt;text file to convert&gt;<br />
cat $1 | tr -d '\015' | tee $1 >/dev/null<br />
</code> </p>
<p>I use these scripts with the combination of find and xargs to convert lots of log files into windows format with the following command. However this type of command can be dangerous, so don&#8217;t use it if you don&#8217;t know what you&#8217;re doing:<br />
<code><br />
find sync-logs/ -name '*.log' -type f | xargs -n1 unix2win<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/03/09/shell-scripts-for-converting-between-unix-and-windows-text-file-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Redesign</title>
		<link>http://www.davidcraddock.net/2010/01/14/site-redesign/</link>
		<comments>http://www.davidcraddock.net/2010/01/14/site-redesign/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 07:58:03 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>
		<category><![CDATA[redesign]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=433</guid>
		<description><![CDATA[I&#8217;ve just updated the design of this blog, re-enabled comments and added a contact tab. I&#8217;ve installed a strong anti-spam comment filter, but you should now be able to comment on entries. I&#8217;ve also changed the layout of things slightly, and made it easier to read.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just updated the design of this blog, re-enabled comments and added a contact tab. I&#8217;ve installed a strong anti-spam comment filter, but you should now be able to comment on entries. I&#8217;ve also changed the layout of things slightly, and made it easier to read.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/01/14/site-redesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Sample &#8211; HTML Page Fetcher and Parser</title>
		<link>http://www.davidcraddock.net/2010/01/14/php-sample-html-page-fetcher-and-parser/</link>
		<comments>http://www.davidcraddock.net/2010/01/14/php-sample-html-page-fetcher-and-parser/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 05:53:47 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=383</guid>
		<description><![CDATA[Back in 2008, I wrote a PHP class that fetched an arbitary URL, parsed it, and coverted it into an PHP object with different attributes for the different elements of the page. I recently updated it and sent it along to a company that wanted a programming example to show I could code in PHP.
I [...]]]></description>
			<content:encoded><![CDATA[<p>Back in 2008, I wrote a PHP class that fetched an arbitary URL, parsed it, and coverted it into an PHP object with different attributes for the different elements of the page. I recently updated it and sent it along to a company that wanted a programming example to show I could code in PHP.</p>
<p>I thought someone may well find a use for it &#8211; I&#8217;ve used the class in several different web scraping applications, and I found it handy. From the readme:</p>
<pre>
This is a class I wrote back in 2008 to help me pull down and parse HTML pages I updated it on
14/01/10 to print the results in a nicer way to the commandline.

- David Craddock (contact@davidcraddock.net)

/// WHAT IT DOES

It uses CURL to pull down a page from a URL, and sorts it into a 'Page' object
which has different attributes for the different HTML properties of the page
structure. By default it will also print the page object's properties neatly
onto the commandline as part of its unit test.

/// FILES

* README.txt - this file
* page.php - The PHP Class
* LIB_http.php - a lightweight external library that I used. It is just a very light wrapper around CURL's HTTP functions.
* expected-result.txt - output of the unit tests on my development machine
* curl-cookie-jar.txt - this file will be created when you run the page.php's unit test

/// SETUP

You will need CURL installed, PHP's DOMXPATH functions available, and the PHP
command line interface. It was tested on PHP5 on OSX.

/// RUNNING

Use the php commandline executable to run the page.php unit tests. IE:
$ php page.php

You should see a bunch of information being printed out, you can use:
$ php page.php > result.txt

That will output the info to result.txt so you can read it at will.
</pre>
<p>Here&#8217;s an example of one of the unit tests, which fetches this frontpage and parses it:</p>
<pre>
**++++
*** Page Print of http://www.davidcraddock.net ***
**++++

** Transfer Status
+ URL Retrieved:

http://www.davidcraddock.net

+ CURL Fetch Status:
Array
(
    [url] => http://www.davidcraddock.net
    [content_type] => text/html; charset=UTF-8
    [http_code] => 200
    [header_size] => 237
    [request_size] => 175
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 1.490972
    [namelookup_time] => 5.3E-5
    [connect_time] => 0.175803
    [pretransfer_time] => 0.175812
    [size_upload] => 0
    [size_download] => 30416
    [speed_download] => 20400
    [speed_upload] => 0
    [download_content_length] => 30416
    [upload_content_length] => 0
    [starttransfer_time] => 0.714943
    [redirect_time] => 0
)

** Header
+ Title: Random Eye Movement
+ Meta Desc:
Not Set
+ Meta Keywords:
Not Set
+ Meta Robots:
Not Set
** Flags
+ Has Frames?:
FALSE
+ Has body content been parsed?:
TRUE

** Non Html Tags
+ Tags scanned for:
Tag Type: script tags processed: 4
Tag Type: embed tags processed: 1
Tag Type: style tags processed: 0

+ Tag contents:
Array
(
    [ script ] => Array
        (
            [0] => Array
                (
                    [src] => http://www.davidcraddock.net/wp-content/themes/this-just-in/js/ThemeJS.js
                    [type] =>
                    [isinline] =>
                    [content] =>
                )

            [1] => Array
                (
                    [src] => http://www.davidcraddock.net/wp-content/plugins/lifestream/lifestream.js
                    [type] => text/javascript
                    [isinline] =>
                    [content] =>
                )

            [2] => Array
                (
                    [src] =>
                    [type] =>
                    [isinline] => 1
                    [content] =>
                 var odesk_widgets_width = 340;
                var odesk_widgets_height = 230;

                )

            [3] => Array
                (
                    [src] => http://www.odesk.com/widgets/v1/providers/large/~~8f250a5e32c8d3fa.js
                    [type] =>
                    [isinline] =>
                    [content] =>
                )

            [count] => 4
        )

    [ embed ] => Array
        (
            [0] => Array
                (
                    [src] => http://www.youtube-nocookie.com/v/Fpm0m6bVfrM&#038;hl=en&#038;fs=1&#038;rel=0
                    [type] => application/x-shockwave-flash
                    [isinline] =>
                    [content] =>
                )

            [count] => 1
        )

    [ style ] => Array
        (
            [count] => 0
        )

)

**----
*** Page Print of http://www.davidcraddock.net Finished ***
**----
</pre>
<p>If you want to download a copy, the file is below. If you find it useful for you, a pingback would be appreciated.<br />
<center><a href="http://www.davidcraddock.net/uploads/code-sample.tar.gz">code-sample.tar.gz</a></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/01/14/php-sample-html-page-fetcher-and-parser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Passed the W3Schools PHP Certification</title>
		<link>http://www.davidcraddock.net/2010/01/14/passed-the-w3schools-php-certification/</link>
		<comments>http://www.davidcraddock.net/2010/01/14/passed-the-w3schools-php-certification/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 01:19:57 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=377</guid>
		<description><![CDATA[
As a break from my contract work, I took the W3Schools PHP Certification. I didn&#8217;t do any revision, which probably wasn&#8217;t wise. It was a bit more difficult than I thought, but I passed still.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.refsnesdata.no/certification/w3certified.asp?email=contact@davidcraddock.net"><img src="http://www.davidcraddock.net/wp-content/uploads/2010/01/w3cert.png" alt="" title="w3cert" width="200" height="68" class="aligncenter size-full wp-image-376" /></a></p>
<p>As a break from my contract work, I took the W3Schools PHP Certification. I didn&#8217;t do any revision, which probably wasn&#8217;t wise. It was a bit more difficult than I thought, but I passed still.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/01/14/passed-the-w3schools-php-certification/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Config files for the Windows version of VIM</title>
		<link>http://www.davidcraddock.net/2010/01/10/config-files-for-the-windows-version-of-vim/</link>
		<comments>http://www.davidcraddock.net/2010/01/10/config-files-for-the-windows-version-of-vim/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 23:06:06 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=331</guid>
		<description><![CDATA[Today I encountered problems configuring the windows version of the popular text editor VIM, so I thought I&#8217;d write up a quick post talk about configuration files under the Windows version, if anyone becomes stuck like I did. I use Linux, OSX and Windows on a day-to-day basis, and VIM as a text editor for [...]]]></description>
			<content:encoded><![CDATA[<p>Today I encountered problems configuring the windows version of the popular text editor <a href="http://www.vim.org">VIM</a>, so I thought I&#8217;d write up a quick post talk about configuration files under the Windows version, if anyone becomes stuck like I did. I use Linux, OSX and Windows on a day-to-day basis, and VIM as a text editor for a lot of quick edits on all three platforms. Here&#8217;s a quick comparison:</p>
<h3>Linux</h3>
<p>Linux is easy because that&#8217;s what most people who use VIM run, and so it is very well tested.</p>
<p><b>~/.vimrc</b> &#8211; Configuration file for command line vim.<br />
<b>~/.gvimrc</b> &#8211; Configuration file for gui vim.</p>
<h3>OSX</h3>
<p>OSX is simple also, as it&#8217;s based on unix:</p>
<p><b>~/.vimrc</b> &#8211; Configuration file for command line vim.<br />
<b>~/.gvimrc</b> &#8211; Configuration file for gui vim.</p>
<h3>Windows</h3>
<p>Windows is not easy at all.. it doesn&#8217;t have a unix file structure, and doesn&#8217;t have support for the unix hidden file names, that start with a &#8216;.&#8217;, ie: &#8216;.vimrc&#8217;, &#8216;.bashrc&#8217;, and so  on. Most open-source programs like VIM that require these hidden configuration files, and have been ported over to windows, seem to adopt this naming convention: &#8216;_vimrc&#8217;, &#8216;_bashrc&#8217;.. and so forth. So:</p>
<p><b>_vimrc</b> &#8211; Configuration file for command line vim.<br />
<b>_gvimrc</b> &#8211; Configuration file for gui vim.</p>
<p>Renaming configuration files from &#8220;.&#8221; to &#8220;_&#8221; wouldn&#8217;t make much difference on its own. You&#8217;d have to rename your files, but.. big deal. It&#8217;s not much of a problem.</p>
<p>Another, more tricky, problem you may encounter however, is that there&#8217;s no clear <b>home</b> directory on windows systems. Each major incarnation of windows seems to have a slightly different way of dealing with user&#8217;s files.. from 2000 to XP, a change, from XP to Vista, there is a change. I haven&#8217;t tried VIM on W7 yet, but it seems similar to Vista in structure, so this information may actually be consistent to W7.</p>
<p>The Vista 64 version of VIM I have, looks in another place for configuration files. For a global configuration file, it looks in &#8220;C:\Program Files&#8221;. Yes..  &#8220;C:\Program Files&#8221;. According to Vista 64&#8217;s version of VIM.. that&#8217;s the exact directory where I installed VIM. This is clearly not right. What&#8217;s happening is that the file system on windows is different to the unix-type file systems, and the VIM port is having problems adapting. The real VIM install directory is <b>C:\Program Files\vim72</b>. Because VIM is looking for a global configuration file in &#8220;C:\Program Files\_vimrc&#8221;, it&#8217;ll never find it. </p>
<p>Now you could override this with a batch file that sets the right environmental variables on startup, or you could change the environmental variables exported in windows, but I prefer to have a user-specified configuration file in my personal files directory, as it&#8217;s easier to backup and manage. If you wanted to specify the environmental variables yourself, which I&#8217;m guessing many will, the two environmental variables to override are:</p>
<p>$VIM = the VIM install directory, not always set properly, as I mentioned.<br />
$HOME = the logged in user&#8217;s documents and settings directory, in windows speak this is also where the &#8216;user profile&#8217; is stored, which is a collection of settings and configurations for the user. The exact directory will depend on which version of Windows you&#8217;re running, and if you override the HOME folder, you may have problems with other programs that rely on it being static.</p>
<p>On my Windows Vista 64 install:</p>
<p><b>$VIM = &#8220;C:\Program Files&#8221;</b><br />
<b>$HOME = &#8220;C:\Users\Dave&#8221;</b></p>
<p>You can see what files VIM includes by running the handy command
<pre>vim -V</pre>
<p> at a command prompt; it will go through the different settings and output something similar to this:</p>
<pre>
Searching for "C:\Users\Dave/vimfiles\filetype.vim"
Searching for "C:\Program Files/vimfiles\filetype.vim"
Searching for "C:\Program Files\vim72\filetype.vim"
line 49: sourcing "C:\Program Files\vim72\filetype.vim"
finished sourcing C:\Program Files\vim72\filetype.vim
continuing in C:\Users\Dave\_vimrc
Searching for "C:\Program Files/vimfiles/after\filetype.vim"
Searching for "C:\Users\Dave/vimfiles/after\filetype.vim"
Searching for "ftplugin.vim" in "C:\Users\Dave/vimfiles,C:\Program Files/vimfiles,C:\Program Files\vim72,C:\Program Files/vimfiles/after,C:\Users\Dave/vimfiles/after"
Searching for "C:\Users\Dave/vimfiles\ftplugin.vim"
Searching for "C:\Program Files/vimfiles\ftplugin.vim"
Searching for "C:\Program Files\vim72\ftplugin.vim"
line 49: sourcing "C:\Program Files\vim72\ftplugin.vim"
finished sourcing C:\Program Files\vim72\ftplugin.vim
continuing in C:\Users\Dave\_vimrc
Searching for "C:\Program Files/vimfiles/after\ftplugin.vim"
Searching for "C:\Users\Dave/vimfiles/after\ftplugin.vim"
finished sourcing $HOME\_vimrc
Searching for "plugin/**/*.vim" in "C:\Users\Dave/vimfiles,C:\Program Files/vimfiles,C:\Program Files\vim72,C:\Program Files/vimfiles/after,C:\Users\Dave/vimfiles/after"
Searching for "C:\Users\Dave/vimfiles\plugin/**/*.vim"
Searching for "C:\Program Files/vimfiles\plugin/**/*.vim"
Searching for "C:\Program Files\vim72\plugin/**/*.vim"
sourcing "C:\Program Files\vim72\plugin\getscriptPlugin.vim"
finished sourcing C:\Program Files\vim72\plugin\getscriptPlugin.vim
sourcing "C:\Program Files\vim72\plugin\gzip.vim"
finished sourcing C:\Program Files\vim72\plugin\gzip.vim
sourcing "C:\Program Files\vim72\plugin\matchparen.vim"
finished sourcing C:\Program Files\vim72\plugin\matchparen.vim
sourcing "C:\Program Files\vim72\plugin\netrwPlugin.vim"
finished sourcing C:\Program Files\vim72\plugin\netrwPlugin.vim
sourcing "C:\Program Files\vim72\plugin\rrhelper.vim"
finished sourcing C:\Program Files\vim72\plugin\rrhelper.vim
sourcing "C:\Program Files\vim72\plugin\spellfile.vim"
finished sourcing C:\Program Files\vim72\plugin\spellfile.vim
sourcing "C:\Program Files\vim72\plugin\tarPlugin.vim"
finished sourcing C:\Program Files\vim72\plugin\tarPlugin.vim
sourcing "C:\Program Files\vim72\plugin\tohtml.vim"
finished sourcing C:\Program Files\vim72\plugin\tohtml.vim
sourcing "C:\Program Files\vim72\plugin\vimballPlugin.vim"
finished sourcing C:\Program Files\vim72\plugin\vimballPlugin.vim
sourcing "C:\Program Files\vim72\plugin\zipPlugin.vim"
finished sourcing C:\Program Files\vim72\plugin\zipPlugin.vim
Searching for "C:\Program Files/vimfiles/after\plugin/**/*.vim"
Searching for "C:\Users\Dave/vimfiles/after\plugin/**/*.vim"
Reading viminfo file "C:\Users\Dave\_viminfo" info
Press ENTER or type command to continue
</pre>
<p>Notice how it does pull in all the syntax highlighting macros and other extension files correctly, which are specified in the <b>.vim</b> files above.. but it doesn&#8217;t pull in the global configuration files that I&#8217;ve copied also to <b>C:\Program Files\vim72\_gvimrc</b> and <b>C:\Program Files\vim72\_vimrc</b>. However, it does pickup the files I copied to <b>C:\Users\Dave</b>.. both the <b> C:\Users\Dave\_vimrc</b> and <b>C:\Users\Dave\_gvimrc</b> are picked up, although VIM will normally read &#8216;_gvimrc&#8217; when the gui version of VIM is run (called gvim). </p>
<p>To see exactly what those environmental variables are being set to, when you&#8217;re inside the editor, issue these two commands, and their values will be show in the editor:</p>
<pre>:echo $HOME
:echo $VIM</pre>
<p>It seems to make sense for me &#8211; and perhaps you, if you&#8217;re working with VIM on windows &#8211; to place my _vimrc and _gvimrc files configuration files in $HOME in Vista. They are then picked up without having to worry about explicitly defining any environmental variables, creating a batch file, or any other hassle.</p>
<p>You can do this easily by the following two commands:</p>
<pre>:ed $HOME\_vimrc
:sp $HOME\_gvimrc</pre>
<p>That will open the two new configuration files, side by side, and you can paste in your existing configuration that you&#8217;ve used in Linux, and windows will pick them up the next time you start VIM.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/01/10/config-files-for-the-windows-version-of-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>oDesk and Work</title>
		<link>http://www.davidcraddock.net/2010/01/03/odesk-and-work/</link>
		<comments>http://www.davidcraddock.net/2010/01/03/odesk-and-work/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 03:44:44 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=319</guid>
		<description><![CDATA[I&#8217;ve been so busy working lately, I&#8217;ve hardly had time to update this website. On top of other things, I&#8217;ve just started freelancing as a contractor on oDesk &#8211; which actually seems quite a good way of getting paid for working on projects at home. Here is my current oDesk profile:
     [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been so busy working lately, I&#8217;ve hardly had time to update this website. On top of other things, I&#8217;ve just started freelancing as a contractor on oDesk &#8211; which actually seems quite a good way of getting paid for working on projects at home. Here is my current oDesk profile:<br />
     <!-- START Hire Me on oDesk Widget --><br />
                <script language="JavaScript">
                var odesk_widgets_width = 340;
                var odesk_widgets_height = 230;
                </script><br />
                <script src="http://www.odesk.com/widgets/v1/providers/large/~~8f250a5e32c8d3fa.js"></script><br />
                <!-- END Hire Me on oDesk Widget --></p>
<p>It is a huge community, and I highly recommend the site to those who wish to work from home. You will become part of the global IT workforce, so you may have to lower your rates, but if you&#8217;re good at what you do, then you can easily earn a modest living from anywhere. Someone I know is working via oDesk while traveling around Asia, for example.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2010/01/03/odesk-and-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed Climbing</title>
		<link>http://www.davidcraddock.net/2009/10/17/speed-climbing/</link>
		<comments>http://www.davidcraddock.net/2009/10/17/speed-climbing/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 23:05:11 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=304</guid>
		<description><![CDATA[I&#8217;m going to take a break from the purely technical posts to get more people to see this video. Here the late Dan Osman speed-climbs a cliff without any safety equipment.

Risky? Just a bit. A few years later he lost his life during a similar attempt. But no-one can doubt the guts required, and the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to take a break from the purely technical posts to get more people to see this video. Here the late Dan Osman speed-climbs a cliff without any safety equipment.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube-nocookie.com/v/Fpm0m6bVfrM&#038;hl=en&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/Fpm0m6bVfrM&#038;hl=en&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>Risky? Just a bit. A few years later he lost his life during a similar attempt. But no-one can doubt the guts required, and the level of skill he achieved, in this type of climbing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2009/10/17/speed-climbing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex in VIM.. simple</title>
		<link>http://www.davidcraddock.net/2009/10/07/regex-in-vim-simple/</link>
		<comments>http://www.davidcraddock.net/2009/10/07/regex-in-vim-simple/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 06:40:02 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=137</guid>
		<description><![CDATA[There are more than a gazillion ways to use regexs. I am sure they are each very useful for their own subset of problems. The sheer variety can be highly confusing and scary for a lot of people though, and you only need to use a few approaches to accomplish most text-editing tasks.
Here is a [...]]]></description>
			<content:encoded><![CDATA[<p>There are <a href="http://www.geocities.com/volontir/" target="_blank">more than a gazillion ways</a> to use regexs. I am sure they are each very useful for their own subset of problems. The sheer variety can be highly confusing and scary</a> for <a href="http://www.google.co.uk/search?q=regex+difficult"  target="_blank">a lot of people</a> though, and you only need to use a few approaches to accomplish most text-editing tasks.</p>
<p>Here is a simple method for using regex in the powerful text editor <a href="http://www.vim.org"  target="_blank">VIM</a> that will work well for common use.</p>
<h2>Method</h2>
<p>We are going to take the &#8220;search and delete a word&#8221; problem for an example. We want to delete all instances of the singular noun &#8220;needle&#8221; in a text file. Let&#8217;s assume there are no instances of the pluralisation &#8220;needles&#8221; in our document.</p>
<ol>
<li><b><i>Debug on</i></b>.. turn some VIM options on</strong><br />
<code>:set hlsearch<br />
:set wrapscan<br />
</code> &#8211; this will make all regex expressions possible to debug by visually showing what they match in your document (first line) and make all searches wrap around instead of just search forward from your current position, which is the default. (second line)</li>
<li><b><i>Develop and Test</i></b>.. your regex attempts by using a simple search. Here we see three attempts at solving the problem:</strong> <code>:/needl<br />
:/needle<br />
:/\&lt;needle\&gt;</code> &#8211; our third try is correct, and highlights all words that spell &#8220;needle&#8221;. The <b>\&lt;</b> and <b>\&gt;</b> markers allow you to specify the beginning and the end of a word. Play with different regexs using the simple search and watching what is highlighted, until you discover one that works for you.</p>
<li><b><i>Run</i></b>&#8230; your regex<code>:%s/\&lt;needle\&gt;//g</code> &#8211; once you&#8217;ve figured out a regex, run the regex on your document.  This example will execute a search for the word &#8220;needle&#8221; and delete every one. If you wanted to substitute needle for another word, you would put the word in between the <b>/</b><b>/</b> marks. As we can see, there is nothing between the marks in this example, so it will replace instances of &#8220;needle&#8221; with nothing. This means it will serve to delete every instance of the word &#8220;needle&#8221;.
<li><b><i>Check things are OK</b></i>&#8230; with your document <code>:/\&lt;needle\&gt;<br />
:/needle<br />
:/needl</code> &#8211; has the regex done what you want? Use the search function to see if regex has done what you wanted it to do. The above examples show different searches through the document to see if different variations remain. Any matches of these searches will highlight any problems. You can use the lower-case <b>N</b>(next search result) and lower-case <b>P</b>(previous search result) commands to navigate through any found search results. You must remember to manually <u>look</u> through the document and see what the regex has changed, make sure there aren&#8217;t any unwanted surprises! </li>
<li><b><I>Recover</b></I>&#8230; from any mistakes </strong><code>u</code> &#8211; just press the <b>U</b> key (with no capslock or shift). This will <u>undo</u> the very last last change made to the document. </li>
<li><b><I>Redo</b></I>&#8230; any work that you need to <code>&lt;ctrl&gt;-r</code> &#8211; use the redo fuction; press the <b>CONTROL</b> and <b>R</b> keys together (with no capslock or shift). This will <u>redo</u> the last change made to the document.</li>
<li><b><I>Finish up and Write</b></I>&#8230; to file <code>:w</code> &#8211; write your work on the document to file. Even after you have written out to file, you can probably still use the undo function to get back to where you were, but it&#8217;s best practice to not rely on this, and only write once you&#8217;re <u>done</u>.</li>
<li><b><i>Debug off</i></b>.. turn some options off</strong><br />
<code>:set nohlsearch<br />
:set nowrapscan<br />
</code> &#8211; turn off the regular expression highlighting (line 1). turn off the wraparound searching (line 2). You can leave either or both options on if you want, they&#8217;re often useful. Up to you.</li>
</ol>
<p>Use a combination of these wonderful commands to test and improve your regex development skills in VIM.</p>
<h2>Examples</h2>
<p>Here I use the shorthand &#8220;<b>#&#8230;</b>&#8221; to denote comments on what I&#8217;m doing&#8230;  if you want to copy and paste the example as written, then you will have to remove those comments.</p>
<p>1. Remove ancient uppercase &lt;BLINK&gt; tags from a document.</p>
<pre>
:set wrapscan # debug on
:set hlsearch # debug on
:/&lt;BLINK&gt; # try 1.. bingo! first time.. selected all tags I want
:%s/&lt;BLINK&gt;//g # lets execute my regex remove
:/BLINK # check 1.. testing things are OK in my file by searching through..
:/blinked # check 2.. yep thats ok..
:/&lt;BLINK\&gt; # check 3.. yep looks ok... the problem tags are gone
# ...manual scroll through the document.. looks good!
:w # write out to file
:set nohlsearch # debug off
:set nowrapscan # debug off
</pre>
<p>2. Oh no! We missed some lower and mixedcase &lt;bLiNK&gt; tags that some sneaky person slipped in. Let&#8217;s take them out.</p>
<pre>
:set wrapscan # debug on
:set hlsearch # debug on
:/&lt;blink&gt; # try 1.. hm.. worked for many, but didnt match BlInK or blINK mixedcase
:/&lt;blink&gt;/i # try 2.. much better.. seems to have worked!
:%s/&lt;blink&gt;//i # lets execute my regex remove
:/BLINK # check 1.. testing things are OK in my file by searching through..
:/blinked # check 2.. yep thats ok..
:/&lt;blink&gt; # check 3.. yep thats fine.
:/&lt;blink&gt;/i # check 4.. looks good... problem solved
# ...manual scroll through the document.. looks much better!
:w # write out to file
:set nohlsearch # debug off
:set nowrapscan # debug off
</pre>
<p>3. Replacing uppercase or mixedcase &lt;BR&gt; tags with the more modern &lt;br&gt;.</p>
<pre>
:set wrapscan # debug on
:set hlsearch # debug on
:/&lt;BR&gt; # try 1.. hmm.. just uppercase.. not gonna work..
:/&lt;br&gt; # try 2.. hmm.. just lowercase..
:/&lt;BR&gt;/i # try 3.. ahh.. that'll be it then
:%s/&lt;BR&gt;/&lt;br&gt;/gi # lets execute my regex substitution
:/BR # check 1.. testing things are OK in my file by searching through..
:/br # check 2.. yep thats ok..
/bR # check 3 ..yup..
:/&lt;BR&gt;/i # check 4.. yep looks ok... the problem tags seem to be gone
# ...manual scroll through the document.. looks good!
:w # write out to file
:set nohlsearch # debug off
:set nowrapscan # debug off
</pre>
<h2>For More..</h2>
<p>Regexs are the gift that just keeps on giving. Here are some good resources on regexs in general, and regexs in VIM.</p>
<ul>
<li><a href="http://www.gskinner.com/RegExr/"  target="_blank">A great modern way to learn regexs.. try them online! interactive flash awesomeness.</a></li>
<li><a href="http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html"  target="_blank">A neat graphical VI/VIM cheat-sheet</a>.</li>
<li><a href="http://www.geocities.com/volontir/"  target="_blank">An advanced VIM/regex tutorial.</a>.</li>
<li><a href="http://briancarper.net/blog/vim-regexes-are-awesome"  target="_blank">More VIM/regex ninja skills.</li>
<li><a href="http://stackoverflow.com/questions/825764/vim-regex-search-csv-string-and-paste-matches"  target="_blank">Stackoverflow is a good place to find practical ways to solve regex problems with VIM.</li>
<li><a href="http://www.regular-expressions.info/"  target="_blank">Probably the most definitive regex site on the &#8216;net</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2009/10/07/regex-in-vim-simple/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Heart rate monitor now available for the XO Laptop</title>
		<link>http://www.davidcraddock.net/2009/04/07/heart-rate-monitor-now-available-for-the-xo-laptop/</link>
		<comments>http://www.davidcraddock.net/2009/04/07/heart-rate-monitor-now-available-for-the-xo-laptop/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 17:17:31 +0000</pubDate>
		<dc:creator>David Craddock</dc:creator>
				<category><![CDATA[Content]]></category>

		<guid isPermaLink="false">http://www.davidcraddock.net/?p=108</guid>
		<description><![CDATA[
Volunteers on the OLPC project have developed a low-cost heart rate monitor that can be plugged into the XO laptop, making steps towards an affordable monitoring system for hospitals in developing countries.
For more information on the development, see the: OLPC Goldenstate project. People in the US can currently buy the sensor here; unfortunately there is [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://www.davidcraddock.net/images/heartratexo.jpg" title="Heart rate on XO" class="alignnone" /></p>
<p>Volunteers on the <a href="http://en.wikipedia.org/wiki/One_Laptop_per_Child">OLPC project</a> have developed a low-cost heart rate monitor that can be plugged into the <a href="http://en.wikipedia.org/wiki/OLPC_XO-1">XO laptop</a>, making steps towards an affordable monitoring system for hospitals in developing countries.</p>
<p>For more information on the development, see the: <a href="http://olpcgoldenstate.blogspot.com/2009/04/new-pcb-revision-and-low-cost-proto.html">OLPC Goldenstate</a> project. People in the US can currently buy the <a href="http://xoexplosion.com/index.php?main_page=product_info&#038;cPath=1_34&#038;products_id=158">sensor here</a>; unfortunately there is no international shipping yet in place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidcraddock.net/2009/04/07/heart-rate-monitor-now-available-for-the-xo-laptop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
