<?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>The Code Train &#187; scratching an itch</title>
	<atom:link href="http://thecodetrain.co.uk/tag/scratching-an-itch/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecodetrain.co.uk</link>
	<description>Where Neil Crosby talks about coding on the train...</description>
	<lastBuildDate>Wed, 18 Aug 2010 18:22:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding a vCard to your iPhone Address Book from a web page</title>
		<link>http://thecodetrain.co.uk/2009/11/adding-a-vcard-to-your-iphone-address-book-from-a-web-page/</link>
		<comments>http://thecodetrain.co.uk/2009/11/adding-a-vcard-to-your-iphone-address-book-from-a-web-page/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 00:43:52 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[addressbook]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobilesafari]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scratching an itch]]></category>
		<category><![CDATA[vcard]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=334</guid>
		<description><![CDATA[<p>It can&#8217;t be done. Well, not obviously anyway.</p>

<p>A couple of weeks ago, I realised that <a href="http://neilcrosby.com/vcard">my public vCard</a> was less useful than it might be.  One of the specific reasons that I created it was to make it easy for people to add a bunch of my contact information to their address books when I met them, rather than them having to manually type in a whole load of stuff that was on a business card.  It turns out that this is great when that person&#8217;s sat at their own computer, but if they&#8217;re (for example) using an iPhone then things become a little more difficult.</p>

<p>You see, the iPhone doesn&#8217;t like to use MobileSafari to download files.  That&#8217;s fine in general &#8211; you don&#8217;t get a filesystem to peruse on the iPhone, so the only way that downloads would be useful is if the iPhone already knows what to do with them.  That&#8217;s why applications are allowed to register their own custom URL schemes. </p>

<p>Unfortunately, by default the iPhone only registers <a href="http://developer.apple.com/safari/library/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html">a few URL schemes</a> for use within web pages &#8211; <code>mailto:</code>, <code>tel:</code> and <code>sms:</code> as pseudo protocols, as well as specific URL structures for Google Maps, YouTube and iTunes links.  This makes it impossible to do things like adding an address to the Address Book or an event to the Calendar with a single click on a link in a webpage &#8211; you just get a message that reads &#8220;Download failed. Safari cannot download this file&#8221;.</p>

<p>This is clearly a pain. As a phone, it seems reasonable that you should be able to easily add contacts to your Address Book. Unfortunately, either Apple thinks you shouldn&#8217;t be able to do this from a webpage or they just didn&#8217;t consider it as a usecase.</p>

<p>It turns out that they did consider that you might like to open email attachments though. If someone sends you an email that contains a VCF file then you <em>are</em> able to open it and see its contents. If you then scroll down to the bottom of the file you&#8217;re greeted with two options, allowing you to &#8220;Create New Contact&#8221; or &#8220;Add to Existing Contact&#8221;.  Suddenly a world full of contact adding goodness is opened up to you.</p>

<p>So, what I&#8217;ve decided to do with my vCard is a little bit of user agent sniffing in my PHP. Currently I assume that every other device in the world other than the iPhone will do something sensible with the normal VCF file (or the microformatted data that&#8217;s on the page itself), so I listen out for the iPhone&#8217;s user agent. If I see it then I swap out the link to download the VCF file with one that takes the user to a page containing a form allowing them to enter their email address. Once they do, the VCF file is immediately emailed to them and they can add my card to their address book.</p>

<p>Right now the look and feel of the <a href="http://neilcrosby.com/vcard/via-email/">the email form</a> that iPhone users are directed to could be described as rudimentary at best, but it works.  At some point in the future I&#8217;ll get round to making it look a bit more pretty.</p>

<p>As a solution, I&#8217;m fairly happy with this.  Whilst it&#8217;s nowhere near as nice as being able to simply click on a link and add a contact to your address book, it does at least mean that it becomes possible to add a contact from a web page.  Certainly it&#8217;s a better solution than not allowing users access to the content at all.  It&#8217;s also entirely possible that this solution would work for other filetypes, such as calendar events.</p>

<p>My only concern is that this problem may be in existence in other devices other than the iPhone as well.  It would almost certainly make sense to make the email option available to users of other devices as well.</p>

<p>So there you have it &#8211; to allow a user to add a contact to their Address Book from a webpage on the iPhone don&#8217;t try and get them to download it, let them receive it via email instead. </p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>It can&#8217;t be done. Well, not obviously anyway.</p>

<p>A couple of weeks ago, I realised that <a href="http://neilcrosby.com/vcard">my public vCard</a> was less useful than it might be.  One of the specific reasons that I created it was to make it easy for people to add a bunch of my contact information to their address books when I met them, rather than them having to manually type in a whole load of stuff that was on a business card.  It turns out that this is great when that person&#8217;s sat at their own computer, but if they&#8217;re (for example) using an iPhone then things become a little more difficult.</p>

<p>You see, the iPhone doesn&#8217;t like to use MobileSafari to download files.  That&#8217;s fine in general &#8211; you don&#8217;t get a filesystem to peruse on the iPhone, so the only way that downloads would be useful is if the iPhone already knows what to do with them.  That&#8217;s why applications are allowed to register their own custom URL schemes. </p>

<p>Unfortunately, by default the iPhone only registers <a href="http://developer.apple.com/safari/library/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html">a few URL schemes</a> for use within web pages &#8211; <code>mailto:</code>, <code>tel:</code> and <code>sms:</code> as pseudo protocols, as well as specific URL structures for Google Maps, YouTube and iTunes links.  This makes it impossible to do things like adding an address to the Address Book or an event to the Calendar with a single click on a link in a webpage &#8211; you just get a message that reads &#8220;Download failed. Safari cannot download this file&#8221;.</p>

<p>This is clearly a pain. As a phone, it seems reasonable that you should be able to easily add contacts to your Address Book. Unfortunately, either Apple thinks you shouldn&#8217;t be able to do this from a webpage or they just didn&#8217;t consider it as a usecase.</p>

<p>It turns out that they did consider that you might like to open email attachments though. If someone sends you an email that contains a VCF file then you <em>are</em> able to open it and see its contents. If you then scroll down to the bottom of the file you&#8217;re greeted with two options, allowing you to &#8220;Create New Contact&#8221; or &#8220;Add to Existing Contact&#8221;.  Suddenly a world full of contact adding goodness is opened up to you.</p>

<p>So, what I&#8217;ve decided to do with my vCard is a little bit of user agent sniffing in my PHP. Currently I assume that every other device in the world other than the iPhone will do something sensible with the normal VCF file (or the microformatted data that&#8217;s on the page itself), so I listen out for the iPhone&#8217;s user agent. If I see it then I swap out the link to download the VCF file with one that takes the user to a page containing a form allowing them to enter their email address. Once they do, the VCF file is immediately emailed to them and they can add my card to their address book.</p>

<p>Right now the look and feel of the <a href="http://neilcrosby.com/vcard/via-email/">the email form</a> that iPhone users are directed to could be described as rudimentary at best, but it works.  At some point in the future I&#8217;ll get round to making it look a bit more pretty.</p>

<p>As a solution, I&#8217;m fairly happy with this.  Whilst it&#8217;s nowhere near as nice as being able to simply click on a link and add a contact to your address book, it does at least mean that it becomes possible to add a contact from a web page.  Certainly it&#8217;s a better solution than not allowing users access to the content at all.  It&#8217;s also entirely possible that this solution would work for other filetypes, such as calendar events.</p>

<p>My only concern is that this problem may be in existence in other devices other than the iPhone as well.  It would almost certainly make sense to make the email option available to users of other devices as well.</p>

<p>So there you have it &#8211; to allow a user to add a contact to their Address Book from a webpage on the iPhone don&#8217;t try and get them to download it, let them receive it via email instead. </p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/11/adding-a-vcard-to-your-iphone-address-book-from-a-web-page/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Displaying your current remote iTunes Playlist on your local Mac&#8217;s Dashboard</title>
		<link>http://thecodetrain.co.uk/2009/11/displaying-your-current-remote-itunes-playlist-on-your-local-macs-dashboard/</link>
		<comments>http://thecodetrain.co.uk/2009/11/displaying-your-current-remote-itunes-playlist-on-your-local-macs-dashboard/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 12:16:33 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[dashboard]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[osascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scratching an itch]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=315</guid>
		<description><![CDATA[<p>In my last blog entry, I wrote about &#8220;<a href="http://thecodetrain.co.uk/2009/10/controlling-itunes-across-multiple-computers-with-the-keyboard/">Controlling iTunes across multiple computers with the keyboard</a>&#8221; (snappy title, huh?).  In it, I promised that the next step was to work out how to get the current playlist displaying on the dashboard.  So, here goes&#8230;</p>

<p><a class="sidenote" href="http://www.flickr.com/photos/thevoicewithin/4102944794/" title="Remote viewing the currently playing iTunes playlist by Neil Crosby, on Flickr"><img src="http://farm3.static.flickr.com/2475/4102944794_483cf765f4.jpg" width="500" height="313" alt="Remote viewing the currently playing iTunes playlist" /></a></p>

<p>The first thing to be aware of is that if Safari can display something on a webpage, then Dashboard can display it as well.  If you visit a page in Safari and right-click somewhere on the background of the page then you should see a menu item titled <code>Open in Dashboard...</code>. If you select this then you&#8217;ll be able to drag to select an area of the page to turn into a dashboard widget.  Click the <code>Add</code> button at the top of the window once you&#8217;re done, and you&#8217;ll magically have created a widget.  Now, any time you open up your Dashboard that widget will be reloaded and you&#8217;ll see fresh data.</p>

<p>So, that&#8217;s how we&#8217;ll display the playlist as a Dashboard Widget &#8211; we&#8217;ll create a webpage that contains the data and then use that as the widget.</p>

<p>If you read the last entry, you&#8217;ll know that I like to use AppleScript as a quick glue language on my Mac.  It&#8217;s pretty easy to use (once you know what you&#8217;re doing), and you can hook into many of the apps you use on a day to day basis and do interesting things with them.  So, it should be no surprise to hear that I&#8217;ll be using AppleScript to get the playlist data out of iTunes.  Given that I&#8217;ll be displaying this data on a webpage though I&#8217;ll be using PHP (because it&#8217;s what I know) to write a quick and dirty page that displays the data that the AppleScript provides.</p>

<p>The AppleScript is a little more involved than the one liners we used last time.  We need to grab the current playlist and then grab information about its UID, Title, Artist and Album, and before finally finding out what the currently playing track is.  Here&#8217;s how we do that.</p>

<pre><code>set tracks_list to {}

tell application "iTunes"
    tell current playlist
        tell tracks
            set tracks_list to get {persistent ID, name, artist, album}
        end tell
    end tell

    set tracks_list to tracks_list  {persistent ID of current track}
end tell

get tracks_list
</code></pre>

<p>In this script we first we create an empty list to put all our data in, then we add lists of track IDs, names, artists and albums to it, then we add a single item of the currently playing track&#8217;s ID.  It&#8217;s not the most elegant of data structures to use once we get to play with it in PHP, but it&#8217;ll do.  Running this from the commandline using <code>osascript -s s playlist.scpt</code> (the <code>-s s</code> means &#8220;print the output in a recompilable form&#8221;) gives us something like the following (respaced for clarity):</p>

<pre><code>{
    {
        "0D7D716D221B623B", 
        "688E193B9F7F7EE3", 
        "05BFA94137C9691F"
    }, 
    {
        "Fashion Is Danger", 
        "Fabulous", 
        "Never Gonna Give You Up"
    }, 
    {
        "Flight of the Conchords", 
        "High School Musical Cast", 
        "Rick Astley"
    }, 
    {
        "I Told You I Was Freaky", 
        "High School Musical 2", 
        "Fantastic 80s"
    }, 
    "688E193B9F7F7EE3"
}
</code></pre>

<p>Now that we have a data structure, we can actually do something with it in PHP.  Unfortunately, as far as I&#8217;m aware there&#8217;s nothing built into PHP that&#8217;ll read this structure. Fortunately though, this structure is pretty damn close to JSON.  If we were to replace the twiddly brackets with square ones then PHP&#8217;s <code>json_decode</code> would return a data structure and we could do something with the data.  Hooray. It&#8217;s a hack, but it works, and it&#8217;s what I did.  A simple <code>str_replace</code> later and I had data.  You can see the code, such as it is, in my <a href="http://github.com/NeilCrosby/itunes-helpers">github repository</a>.</p>

<p>The eagle eyed amongst you will notice that I&#8217;m not directly calling <code>osascript</code> from my PHP script though, and am instead going through an intermediary shell script that nukes <code>DYLD_LIBRARY_PATH</code> before running the AppleScript.  The reason for this is that on the machine I&#8217;m running the script on I&#8217;m using MAMP for my web stack, and that does funny things with <code>DYLD_LIBRARY_PATH</code> under Snow Leopard apparently.  So, I have to nuke it.</p>

<p>And that&#8217;s all there is to it.  Visit the webpage you&#8217;ve created to display the data, let it show you what&#8217;s playing and then turn it into a dashboard component using Safari.  I get to control iTunes on a remote machine and I don&#8217;t have to keep a VNC connection on it.  This makes me happy.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>In my last blog entry, I wrote about &#8220;<a href="http://thecodetrain.co.uk/2009/10/controlling-itunes-across-multiple-computers-with-the-keyboard/">Controlling iTunes across multiple computers with the keyboard</a>&#8221; (snappy title, huh?).  In it, I promised that the next step was to work out how to get the current playlist displaying on the dashboard.  So, here goes&#8230;</p>

<p><a class="sidenote" href="http://www.flickr.com/photos/thevoicewithin/4102944794/" title="Remote viewing the currently playing iTunes playlist by Neil Crosby, on Flickr"><img src="http://farm3.static.flickr.com/2475/4102944794_483cf765f4.jpg" width="500" height="313" alt="Remote viewing the currently playing iTunes playlist" /></a></p>

<p>The first thing to be aware of is that if Safari can display something on a webpage, then Dashboard can display it as well.  If you visit a page in Safari and right-click somewhere on the background of the page then you should see a menu item titled <code>Open in Dashboard...</code>. If you select this then you&#8217;ll be able to drag to select an area of the page to turn into a dashboard widget.  Click the <code>Add</code> button at the top of the window once you&#8217;re done, and you&#8217;ll magically have created a widget.  Now, any time you open up your Dashboard that widget will be reloaded and you&#8217;ll see fresh data.</p>

<p>So, that&#8217;s how we&#8217;ll display the playlist as a Dashboard Widget &#8211; we&#8217;ll create a webpage that contains the data and then use that as the widget.</p>

<p>If you read the last entry, you&#8217;ll know that I like to use AppleScript as a quick glue language on my Mac.  It&#8217;s pretty easy to use (once you know what you&#8217;re doing), and you can hook into many of the apps you use on a day to day basis and do interesting things with them.  So, it should be no surprise to hear that I&#8217;ll be using AppleScript to get the playlist data out of iTunes.  Given that I&#8217;ll be displaying this data on a webpage though I&#8217;ll be using PHP (because it&#8217;s what I know) to write a quick and dirty page that displays the data that the AppleScript provides.</p>

<p>The AppleScript is a little more involved than the one liners we used last time.  We need to grab the current playlist and then grab information about its UID, Title, Artist and Album, and before finally finding out what the currently playing track is.  Here&#8217;s how we do that.</p>

<pre><code>set tracks_list to {}

tell application "iTunes"
    tell current playlist
        tell tracks
            set tracks_list to get {persistent ID, name, artist, album}
        end tell
    end tell

    set tracks_list to tracks_list  {persistent ID of current track}
end tell

get tracks_list
</code></pre>

<p>In this script we first we create an empty list to put all our data in, then we add lists of track IDs, names, artists and albums to it, then we add a single item of the currently playing track&#8217;s ID.  It&#8217;s not the most elegant of data structures to use once we get to play with it in PHP, but it&#8217;ll do.  Running this from the commandline using <code>osascript -s s playlist.scpt</code> (the <code>-s s</code> means &#8220;print the output in a recompilable form&#8221;) gives us something like the following (respaced for clarity):</p>

<pre><code>{
    {
        "0D7D716D221B623B", 
        "688E193B9F7F7EE3", 
        "05BFA94137C9691F"
    }, 
    {
        "Fashion Is Danger", 
        "Fabulous", 
        "Never Gonna Give You Up"
    }, 
    {
        "Flight of the Conchords", 
        "High School Musical Cast", 
        "Rick Astley"
    }, 
    {
        "I Told You I Was Freaky", 
        "High School Musical 2", 
        "Fantastic 80s"
    }, 
    "688E193B9F7F7EE3"
}
</code></pre>

<p>Now that we have a data structure, we can actually do something with it in PHP.  Unfortunately, as far as I&#8217;m aware there&#8217;s nothing built into PHP that&#8217;ll read this structure. Fortunately though, this structure is pretty damn close to JSON.  If we were to replace the twiddly brackets with square ones then PHP&#8217;s <code>json_decode</code> would return a data structure and we could do something with the data.  Hooray. It&#8217;s a hack, but it works, and it&#8217;s what I did.  A simple <code>str_replace</code> later and I had data.  You can see the code, such as it is, in my <a href="http://github.com/NeilCrosby/itunes-helpers">github repository</a>.</p>

<p>The eagle eyed amongst you will notice that I&#8217;m not directly calling <code>osascript</code> from my PHP script though, and am instead going through an intermediary shell script that nukes <code>DYLD_LIBRARY_PATH</code> before running the AppleScript.  The reason for this is that on the machine I&#8217;m running the script on I&#8217;m using MAMP for my web stack, and that does funny things with <code>DYLD_LIBRARY_PATH</code> under Snow Leopard apparently.  So, I have to nuke it.</p>

<p>And that&#8217;s all there is to it.  Visit the webpage you&#8217;ve created to display the data, let it show you what&#8217;s playing and then turn it into a dashboard component using Safari.  I get to control iTunes on a remote machine and I don&#8217;t have to keep a VNC connection on it.  This makes me happy.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/11/displaying-your-current-remote-itunes-playlist-on-your-local-macs-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling iTunes across multiple computers with the keyboard</title>
		<link>http://thecodetrain.co.uk/2009/10/controlling-itunes-across-multiple-computers-with-the-keyboard/</link>
		<comments>http://thecodetrain.co.uk/2009/10/controlling-itunes-across-multiple-computers-with-the-keyboard/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 12:32:56 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[keyboard control]]></category>
		<category><![CDATA[scratching an itch]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=312</guid>
		<description><![CDATA[<p>Over the last few days on Twitter I&#8217;ve been talking about my peculiar iTunes setup, and a few people have been asking me if I&#8217;ll blog about it.  So, here goes&#8230;</p>

<p>My situation is that my iTunes music library is stored on my MacMini that lives in my living room (connected to and powering my TV experience). However, most of the time I spend using my MacBook Pro, which spends most of its time in the office upstairs a fair way away from the MacMini. Because I spend most of my time at the laptop, it&#8217;s nice to have music available for me to listen to on it.  Of course, if I just wanted to <em>listen</em> to music then this would be a very short blog post &#8211; I could use iTunes to share the library from the MacMini and listen to the music upstairs, or I could use Spotify or Last.fm. The problem with these as solutions are that I make heavy use of Smart and Genius Playlists in iTunes to generate playlists of music to listen to. Using iTunes&#8217; sharing feature doesn&#8217;t allow me to rate tracks in the originating library (even with iTunes 9&#8217;s &#8220;Home Sharing&#8221; feature), and it also doesn&#8217;t generate extra playcount in the originating library for the things I listen to. This means my Smart Playlists don&#8217;t update in the expected way, and I become a sad panda. Likewise, Genius Playlists don&#8217;t work in a usable way when using a shared library, so this doesn&#8217;t really work for me.</p>

<p>What I wanted was a way to play my music using the MacMini downstairs, but have the music erupt from the speakers connected to my MacBook Pro.  As it turns out, there&#8217;s an app for that &#8211; <a href="http://www.rogueamoeba.com/airfoil/mac/">Airfoil</a>. This lovely application hijacks audio from one device and sends it out across the network to multiple other devices of your choice, all in sync. So, immediately I was able to use OSX&#8217;s Screen Sharing app to connect to my MacMini, start some music playing in iTunes and then have Airfoil pipe it out to my MacBook Pro.  It was a solution that was sheer elegance in its simplicity. Yes, you have to wait a second or so after pressing play before you hear anything come out of your speakers, but that&#8217;s down to Airfoil making sure all your devices are in sync before it starts to do anything.  All in all, it&#8217;s brilliant. It costs $25, but that&#8217;s a small price to pay for this functionality for me.</p>

<p>The only problem is that in playing music on a different computer than the one you&#8217;re on, you&#8217;re playing music on a different computer than the one you&#8217;re on.  So various things, like media keys on your keyboard don&#8217;t work in the way you expect. So, whenever I was wanting to do simple things like pause my music I was having to go into Apple&#8217;s Screen Sharing app, log into the MacMini and then press the pause button in iTunes.  Not ideal.  So, I wrote a quick AppleScript in Apple&#8217;s Script Editor:</p>

<pre><code>tell application "iTunes" of machine "eppc://macmini-2.local" to playpause
</code></pre>

<p>Yup, that&#8217;s a really simple AppleScript.  Something I wasn&#8217;t aware of until a couple of days ago is that it&#8217;s possible to run AppleScript that runs AppleScript on a different machine.  All you have to do is go into <code>System Preferences</code>, open the <code>Sharing</code> panel, and enable <code>Remote Apple Events</code>. The first time you try to run an event on the remote machine you&#8217;ll be asked to enter your credentials on the local machine, which you can save to your keychain for auto-use in the future.  Now, if I run that AppleScript then iTunes on the remote machine will toggle its play state, and consequently on my local machine.  Awesome.</p>

<p>It&#8217;s just as easy to write other scripts as well. For example, to advance to the next track, just change <code>playpause</code> to <code>play (next track)</code>.</p>

<p>But we&#8217;re still not controlling iTunes on the remote machine with just a keypress.  If you&#8217;ve got something like Quicksilver installed on your machine then you should be able to simply hook the script up to a key combination of your choice. I don&#8217;t currently have Quicksilver installed on this machine (and wasn&#8217;t about to install it just for this), so I had to find another alternative. What I&#8217;m currently using is <a href="http://www.red-sweater.com/fastscripts/">FastScripts Lite</a>, a free app that adds an icon to your menubar that contains menu items for any AppleScripts you put in a certain directory. The nice thing about FastScripts is that it also allows you to enter a keypress combo for any of these scripts by going into its <code>Preferences</code> pane and double clicking on the Shortcut field next to the relevant script. I&#8217;ve got <code>playpause</code> bound to <code>ctrl-up</code>, <code>next track</code> to <code>ctrl-right</code> and <code>previous track</code> to (you guessed it) <code>ctrl-left</code>. Now I can easily change what I&#8217;m listening to with a quick keypress, and I&#8217;m happy.</p>

<p>Well, I&#8217;m almost happy.  I still need to have Screen Sharing open so that I can see what&#8217;s actually in the playlist that I&#8217;m listening to.  There&#8217;s a solution to that as well though.  All I needed do was create a script that calls some AppleScript on the MacMini, grabs the current playlist info and then outputs it into a web page. I could then use this page as the basis of a Dashboard widget and I&#8217;d only ever have to press F12 to see my current playlist.  And that&#8217;s what I did. To find out how I did it though, you&#8217;ll have to read the <a href="http://thecodetrain.co.uk/2009/11/displaying-your-current-remote-itunes-playlist-on-your-local-macs-dashboard/">next post</a>!</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>Over the last few days on Twitter I&#8217;ve been talking about my peculiar iTunes setup, and a few people have been asking me if I&#8217;ll blog about it.  So, here goes&#8230;</p>

<p>My situation is that my iTunes music library is stored on my MacMini that lives in my living room (connected to and powering my TV experience). However, most of the time I spend using my MacBook Pro, which spends most of its time in the office upstairs a fair way away from the MacMini. Because I spend most of my time at the laptop, it&#8217;s nice to have music available for me to listen to on it.  Of course, if I just wanted to <em>listen</em> to music then this would be a very short blog post &#8211; I could use iTunes to share the library from the MacMini and listen to the music upstairs, or I could use Spotify or Last.fm. The problem with these as solutions are that I make heavy use of Smart and Genius Playlists in iTunes to generate playlists of music to listen to. Using iTunes&#8217; sharing feature doesn&#8217;t allow me to rate tracks in the originating library (even with iTunes 9&#8217;s &#8220;Home Sharing&#8221; feature), and it also doesn&#8217;t generate extra playcount in the originating library for the things I listen to. This means my Smart Playlists don&#8217;t update in the expected way, and I become a sad panda. Likewise, Genius Playlists don&#8217;t work in a usable way when using a shared library, so this doesn&#8217;t really work for me.</p>

<p>What I wanted was a way to play my music using the MacMini downstairs, but have the music erupt from the speakers connected to my MacBook Pro.  As it turns out, there&#8217;s an app for that &#8211; <a href="http://www.rogueamoeba.com/airfoil/mac/">Airfoil</a>. This lovely application hijacks audio from one device and sends it out across the network to multiple other devices of your choice, all in sync. So, immediately I was able to use OSX&#8217;s Screen Sharing app to connect to my MacMini, start some music playing in iTunes and then have Airfoil pipe it out to my MacBook Pro.  It was a solution that was sheer elegance in its simplicity. Yes, you have to wait a second or so after pressing play before you hear anything come out of your speakers, but that&#8217;s down to Airfoil making sure all your devices are in sync before it starts to do anything.  All in all, it&#8217;s brilliant. It costs $25, but that&#8217;s a small price to pay for this functionality for me.</p>

<p>The only problem is that in playing music on a different computer than the one you&#8217;re on, you&#8217;re playing music on a different computer than the one you&#8217;re on.  So various things, like media keys on your keyboard don&#8217;t work in the way you expect. So, whenever I was wanting to do simple things like pause my music I was having to go into Apple&#8217;s Screen Sharing app, log into the MacMini and then press the pause button in iTunes.  Not ideal.  So, I wrote a quick AppleScript in Apple&#8217;s Script Editor:</p>

<pre><code>tell application "iTunes" of machine "eppc://macmini-2.local" to playpause
</code></pre>

<p>Yup, that&#8217;s a really simple AppleScript.  Something I wasn&#8217;t aware of until a couple of days ago is that it&#8217;s possible to run AppleScript that runs AppleScript on a different machine.  All you have to do is go into <code>System Preferences</code>, open the <code>Sharing</code> panel, and enable <code>Remote Apple Events</code>. The first time you try to run an event on the remote machine you&#8217;ll be asked to enter your credentials on the local machine, which you can save to your keychain for auto-use in the future.  Now, if I run that AppleScript then iTunes on the remote machine will toggle its play state, and consequently on my local machine.  Awesome.</p>

<p>It&#8217;s just as easy to write other scripts as well. For example, to advance to the next track, just change <code>playpause</code> to <code>play (next track)</code>.</p>

<p>But we&#8217;re still not controlling iTunes on the remote machine with just a keypress.  If you&#8217;ve got something like Quicksilver installed on your machine then you should be able to simply hook the script up to a key combination of your choice. I don&#8217;t currently have Quicksilver installed on this machine (and wasn&#8217;t about to install it just for this), so I had to find another alternative. What I&#8217;m currently using is <a href="http://www.red-sweater.com/fastscripts/">FastScripts Lite</a>, a free app that adds an icon to your menubar that contains menu items for any AppleScripts you put in a certain directory. The nice thing about FastScripts is that it also allows you to enter a keypress combo for any of these scripts by going into its <code>Preferences</code> pane and double clicking on the Shortcut field next to the relevant script. I&#8217;ve got <code>playpause</code> bound to <code>ctrl-up</code>, <code>next track</code> to <code>ctrl-right</code> and <code>previous track</code> to (you guessed it) <code>ctrl-left</code>. Now I can easily change what I&#8217;m listening to with a quick keypress, and I&#8217;m happy.</p>

<p>Well, I&#8217;m almost happy.  I still need to have Screen Sharing open so that I can see what&#8217;s actually in the playlist that I&#8217;m listening to.  There&#8217;s a solution to that as well though.  All I needed do was create a script that calls some AppleScript on the MacMini, grabs the current playlist info and then outputs it into a web page. I could then use this page as the basis of a Dashboard widget and I&#8217;d only ever have to press F12 to see my current playlist.  And that&#8217;s what I did. To find out how I did it though, you&#8217;ll have to read the <a href="http://thecodetrain.co.uk/2009/11/displaying-your-current-remote-itunes-playlist-on-your-local-macs-dashboard/">next post</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/10/controlling-itunes-across-multiple-computers-with-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Locking my Mac when I want to step away from it</title>
		<link>http://thecodetrain.co.uk/2009/07/locking-my-mac-when-i-want-to-step-away/</link>
		<comments>http://thecodetrain.co.uk/2009/07/locking-my-mac-when-i-want-to-step-away/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 08:40:34 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[scratching an itch]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=280</guid>
		<description><![CDATA[<p>I&#8217;ve noticed a few people asking recently &#8220;How do you lock your Mac desktop when you want to nip out?&#8221;.  It&#8217;s a reasonable question — after all, security of your machine and the data on it should be at the forefront of your mind if you decide to leave your machine whilst you go and do something else.</p>

<p>The way I do this is to use a &#8220;hot corner&#8221;. In OSX you can set up your Mac to perform different tasks when you move your mouse up to any one of the four corners.  If you open <code>System Preferences</code>, then <code>Exposé and Spaces</code> and make sure you&#8217;ve got the <code>Spaces</code> tab open you&#8217;ll see an <code>Active Screen Corners</code> section at the top of the window.  I have the bottom right hand corner set to <code>Start Screen Saver</code>.  Because I have set <code>Require password to wake this computer from sleep or screen saver</code> in the <code>Security</code> section of <code>System Preferences</code>, when I throw my mouse into the bottom right hand corner of the screen it automatically locks itself for me.  </p>

<p>It&#8217;s a simple solution that works well for me.</p>

<p>Another way you can lock your machine is to use the <code>Keychain Access</code> application (<code>/Applications/Utilities/Keychain Access.app</code>).  If you load this and then open <code>Preferences</code> you&#8217;ll see a <code>Show Status in Menu Bar</code> option on the <code>General</code> tab. If you tick this you&#8217;ll see an unlocked padlock appear in your menu bar. From now on if you want to lock your machine you can click on the padlock icon and then select <code>Lock Screen</code>.  I personally don&#8217;t use this solution because it requires more dexterity than just throwing the mouse into a corner of the screen, but it&#8217;s another option that you might lie to use.</p>

<p>So, there you have it — two different ways of locking your Mac&#8217;s screen under OSX.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed a few people asking recently &#8220;How do you lock your Mac desktop when you want to nip out?&#8221;.  It&#8217;s a reasonable question — after all, security of your machine and the data on it should be at the forefront of your mind if you decide to leave your machine whilst you go and do something else.</p>

<p>The way I do this is to use a &#8220;hot corner&#8221;. In OSX you can set up your Mac to perform different tasks when you move your mouse up to any one of the four corners.  If you open <code>System Preferences</code>, then <code>Exposé and Spaces</code> and make sure you&#8217;ve got the <code>Spaces</code> tab open you&#8217;ll see an <code>Active Screen Corners</code> section at the top of the window.  I have the bottom right hand corner set to <code>Start Screen Saver</code>.  Because I have set <code>Require password to wake this computer from sleep or screen saver</code> in the <code>Security</code> section of <code>System Preferences</code>, when I throw my mouse into the bottom right hand corner of the screen it automatically locks itself for me.  </p>

<p>It&#8217;s a simple solution that works well for me.</p>

<p>Another way you can lock your machine is to use the <code>Keychain Access</code> application (<code>/Applications/Utilities/Keychain Access.app</code>).  If you load this and then open <code>Preferences</code> you&#8217;ll see a <code>Show Status in Menu Bar</code> option on the <code>General</code> tab. If you tick this you&#8217;ll see an unlocked padlock appear in your menu bar. From now on if you want to lock your machine you can click on the padlock icon and then select <code>Lock Screen</code>.  I personally don&#8217;t use this solution because it requires more dexterity than just throwing the mouse into a corner of the screen, but it&#8217;s another option that you might lie to use.</p>

<p>So, there you have it — two different ways of locking your Mac&#8217;s screen under OSX.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/07/locking-my-mac-when-i-want-to-step-away/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>GitHub Inactive Repository Demoter, a GreaseMonkey Script</title>
		<link>http://thecodetrain.co.uk/2009/03/github-inactive-repository-demoter-a-greasemonkey-script/</link>
		<comments>http://thecodetrain.co.uk/2009/03/github-inactive-repository-demoter-a-greasemonkey-script/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 09:59:12 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[scratching an itch]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=217</guid>
		<description><![CDATA[<p>One of the things that&#8217;s been annoying me recently about <a href="http://github.com">GitHub</a> is the way that a user&#8217;s repositories are presented on their profile page.  Take <a href="http://github.com/NeilCrosby">my profile page</a> for example — I have 16 repositories, but only 5 of them have had any active development over the last month.  To my mind those ones are the most important on the page, and  as such should be given pride of place.  The others should be pushed down the page into their own section.</p>

<p>So, using the wonders of <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a>, that&#8217;s what I did with a spare half an hour yesterday evening.  The <a href="http://github.com/NeilCrosby/github-inactive-repository-demoter/tree">demoter script</a> I wrote is very simple — it looks for the first element on the page with a class of &#8220;projects&#8221;, then checks the last changed date of each of the projects contained within.  If any of them contain a date that&#8217;s more than a month old then a quick <code>appendChild</code> of the original node onto the new &#8220;demoted&#8221; list moves it across.  A heading is added before the new &#8220;demoted&#8221; list to explain what this new list contains, and we&#8217;re all done.</p>

<p>So far I&#8217;ve noticed one &#8220;bug&#8221; with this script.  Normally, when GitHub displays information about a project, it&#8217;s the last changed date of the project that&#8217;s displayed.  Unfortunately, if the user has forked a repository, it seems that the date displayed is when the repository was forked rather than the last time it was edited.  Even if the fork happened months ago, and since then the user has made many edits themselves it&#8217;s still the fork date that&#8217;s displayed.  You can see this in action on <a href="http://github.com/bradleywright">Brad&#8217;s profile page</a> on the &#8220;homedir&#8221; project.</p>

<p>Short of GitHub exposing the actual last edited date on the page itself there is one other possible possibility for getting hold of a last edited(ish) date.  For each of the project activity sparklines, GitHub makes a call back to the server to grab a chunk of parseable data.  It might be possible to grab hold of that data using GreaseMonkey, but that&#8217;s a problem I leave to the enterprising reader.  If you do solve the problem, please do fork my code and send a pull request — I&#8217;d love to have this solved in the script.</p>

<p>If you fancy having this &#8220;Inactive Repository Demotion&#8221; functionality on GitHub, all you have to do is <a href="http://github.com/NeilCrosby/github-inactive-repository-demoter/tree">download the script</a>.  Oh, and whilst you&#8217;re at it, don&#8217;t forget to follow the repository so you can be told of any updates or bugfixes.</p>

<p>EDIT:</p>

<p>As it turns out, I should probably be a little more explicit about how to install the script.  First, download the entire repository as a zip or tgz.  Open it up, and then open the script up in Firefox.  The GreaseMonkey script will then install.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>One of the things that&#8217;s been annoying me recently about <a href="http://github.com">GitHub</a> is the way that a user&#8217;s repositories are presented on their profile page.  Take <a href="http://github.com/NeilCrosby">my profile page</a> for example — I have 16 repositories, but only 5 of them have had any active development over the last month.  To my mind those ones are the most important on the page, and  as such should be given pride of place.  The others should be pushed down the page into their own section.</p>

<p>So, using the wonders of <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a>, that&#8217;s what I did with a spare half an hour yesterday evening.  The <a href="http://github.com/NeilCrosby/github-inactive-repository-demoter/tree">demoter script</a> I wrote is very simple — it looks for the first element on the page with a class of &#8220;projects&#8221;, then checks the last changed date of each of the projects contained within.  If any of them contain a date that&#8217;s more than a month old then a quick <code>appendChild</code> of the original node onto the new &#8220;demoted&#8221; list moves it across.  A heading is added before the new &#8220;demoted&#8221; list to explain what this new list contains, and we&#8217;re all done.</p>

<p>So far I&#8217;ve noticed one &#8220;bug&#8221; with this script.  Normally, when GitHub displays information about a project, it&#8217;s the last changed date of the project that&#8217;s displayed.  Unfortunately, if the user has forked a repository, it seems that the date displayed is when the repository was forked rather than the last time it was edited.  Even if the fork happened months ago, and since then the user has made many edits themselves it&#8217;s still the fork date that&#8217;s displayed.  You can see this in action on <a href="http://github.com/bradleywright">Brad&#8217;s profile page</a> on the &#8220;homedir&#8221; project.</p>

<p>Short of GitHub exposing the actual last edited date on the page itself there is one other possible possibility for getting hold of a last edited(ish) date.  For each of the project activity sparklines, GitHub makes a call back to the server to grab a chunk of parseable data.  It might be possible to grab hold of that data using GreaseMonkey, but that&#8217;s a problem I leave to the enterprising reader.  If you do solve the problem, please do fork my code and send a pull request — I&#8217;d love to have this solved in the script.</p>

<p>If you fancy having this &#8220;Inactive Repository Demotion&#8221; functionality on GitHub, all you have to do is <a href="http://github.com/NeilCrosby/github-inactive-repository-demoter/tree">download the script</a>.  Oh, and whilst you&#8217;re at it, don&#8217;t forget to follow the repository so you can be told of any updates or bugfixes.</p>

<p>EDIT:</p>

<p>As it turns out, I should probably be a little more explicit about how to install the script.  First, download the entire repository as a zip or tgz.  Open it up, and then open the script up in Firefox.  The GreaseMonkey script will then install.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2009/03/github-inactive-repository-demoter-a-greasemonkey-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to make a stop-motion video from automatically taken photos</title>
		<link>http://thecodetrain.co.uk/2008/12/how-to-make-a-stopmotion-video-from-automatically-taken-photos/</link>
		<comments>http://thecodetrain.co.uk/2008/12/how-to-make-a-stopmotion-video-from-automatically-taken-photos/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 13:35:04 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[autocamcapture]]></category>
		<category><![CDATA[quicktime]]></category>
		<category><![CDATA[scratching an itch]]></category>
		<category><![CDATA[stopmotion]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=170</guid>
		<description><![CDATA[<p>About a month ago now I showed you <a href="http://thecodetrain.co.uk/2008/11/how-to-automatically-take-photos-using-your-macs-webcam/">how to set up your Mac to automatically take photos</a>.  Hopefully by now you should have a good selection of photos, and you&#8217;ll be wondering what you can do with them.</p>

<p>The answer?  Make a video!</p>

<p><object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=63881" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=bf086a63dd&amp;photo_id=3079569593"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=63881"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=63881" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=bf086a63dd&amp;photo_id=3079569593" height="300" width="400"></embed></object></p>

<p>For this make you&#8217;ll need to have a copy of QuickTime Pro.  Yes, I know you have to pay for this, but it works quickly and makes good quality videos.  If you don&#8217;t want to use QuickTime Pro, there are other free alternatives available (I&#8217;ve had MEncoder mentioned to me), but I&#8217;ve not used them myself.</p>

<p>Making a video out of sequenced images is easy with Quicktime Pro &#8211; just make sure your images are all in one folder, select a photo from that folder using the <code>File/Open Image Sequence</code> menu option, choose a frame rate and wait.</p>

<p>Of course, things aren&#8217;t quite that easy.  For one thing, Quicktime Pro doesn&#8217;t actually work with full folders of images &#8211; instead it works with sequences of images within a folder.  So, if you selected <code>horse1.jpg</code> as the initial photo then only images matching <code>/horse\n+\.jpg/</code> would be sued to create the resultant video.  Likewise, if the images were named in the format <code>YYYMMDD-hhmmss.jpg</code> then the video created would only contain images for a certain day, due to that pesky dash.</p>

<p>Unfortunately, that was the original filename format <a href="http://github.com/NeilCrosby/autocamcapture/tree">autocamcapture</a> used.  It doesn&#8217;t use that format any more, but all you early adopters will need to rename your images.  Thankfully, that&#8217;s pretty damn easy to do.  Just enter the following:</p>

<pre><code>cd ~/Pictures/autocamcapture
for file in *.jpg; do mv $file `echo $file | sed 's/-//g'`; done
</code></pre>

<p>Your images will suddenly all be in the format <code>YYYYMMDDHHMMSS.jpg</code> and Quicktime Pro will happily register them as all one sequence.</p>

<p>So, that&#8217;s all there is to it.  Have you been using the autocamcapture script?  Yes?  Then go make a video and add it to the <a href="http://www.flickr.com/groups/autocamcapture/">autocamcapture pool on Flickr</a>.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>About a month ago now I showed you <a href="http://thecodetrain.co.uk/2008/11/how-to-automatically-take-photos-using-your-macs-webcam/">how to set up your Mac to automatically take photos</a>.  Hopefully by now you should have a good selection of photos, and you&#8217;ll be wondering what you can do with them.</p>

<p>The answer?  Make a video!</p>

<p><object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=63881" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=bf086a63dd&amp;photo_id=3079569593"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=63881"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=63881" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=bf086a63dd&amp;photo_id=3079569593" height="300" width="400"></embed></object></p>

<p>For this make you&#8217;ll need to have a copy of QuickTime Pro.  Yes, I know you have to pay for this, but it works quickly and makes good quality videos.  If you don&#8217;t want to use QuickTime Pro, there are other free alternatives available (I&#8217;ve had MEncoder mentioned to me), but I&#8217;ve not used them myself.</p>

<p>Making a video out of sequenced images is easy with Quicktime Pro &#8211; just make sure your images are all in one folder, select a photo from that folder using the <code>File/Open Image Sequence</code> menu option, choose a frame rate and wait.</p>

<p>Of course, things aren&#8217;t quite that easy.  For one thing, Quicktime Pro doesn&#8217;t actually work with full folders of images &#8211; instead it works with sequences of images within a folder.  So, if you selected <code>horse1.jpg</code> as the initial photo then only images matching <code>/horse\n+\.jpg/</code> would be sued to create the resultant video.  Likewise, if the images were named in the format <code>YYYMMDD-hhmmss.jpg</code> then the video created would only contain images for a certain day, due to that pesky dash.</p>

<p>Unfortunately, that was the original filename format <a href="http://github.com/NeilCrosby/autocamcapture/tree">autocamcapture</a> used.  It doesn&#8217;t use that format any more, but all you early adopters will need to rename your images.  Thankfully, that&#8217;s pretty damn easy to do.  Just enter the following:</p>

<pre><code>cd ~/Pictures/autocamcapture
for file in *.jpg; do mv $file `echo $file | sed 's/-//g'`; done
</code></pre>

<p>Your images will suddenly all be in the format <code>YYYYMMDDHHMMSS.jpg</code> and Quicktime Pro will happily register them as all one sequence.</p>

<p>So, that&#8217;s all there is to it.  Have you been using the autocamcapture script?  Yes?  Then go make a video and add it to the <a href="http://www.flickr.com/groups/autocamcapture/">autocamcapture pool on Flickr</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2008/12/how-to-make-a-stopmotion-video-from-automatically-taken-photos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get more than the last 10 Recently Played Tracks from last.fm</title>
		<link>http://thecodetrain.co.uk/2008/12/how-to-get-more-than-the-last-10-recently-played-tracks-from-lastfm/</link>
		<comments>http://thecodetrain.co.uk/2008/12/how-to-get-more-than-the-last-10-recently-played-tracks-from-lastfm/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 12:07:58 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[scratching an itch]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=168</guid>
		<description><![CDATA[<p>I don&#8217;t have time for a full entry today, so here&#8217;s a quick tip for <a href="http://last.fm">last.fm</a> users who are making use of their &#8220;Recently Played Tracks&#8221; RSS to do cool things.</p>

<p>It turns out that you can increase the number of tracks returned by the feed simply by adding a <code>limit=somenumber</code> parameter to the URL.  So, for me to grab the last 20 songs that I&#8217;ve scrobbled, I would ask for:</p>

<pre><code>http://ws.audioscrobbler.com/1.0/user/NeilCrosby/recenttracks.rss?limit=20
</code></pre>

<p>I use this as a way of getting a decent sampling of my recent tracks to use on <a href="http://NeilCrosby.com">NeilCrosby.com</a>, as I found the default 10 was too limiting since my &#8220;Stream of Consciousness&#8221; stream normally covers a few days worth of information, whereas my last 10 tracks would only cover an hour or so of data.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t have time for a full entry today, so here&#8217;s a quick tip for <a href="http://last.fm">last.fm</a> users who are making use of their &#8220;Recently Played Tracks&#8221; RSS to do cool things.</p>

<p>It turns out that you can increase the number of tracks returned by the feed simply by adding a <code>limit=somenumber</code> parameter to the URL.  So, for me to grab the last 20 songs that I&#8217;ve scrobbled, I would ask for:</p>

<pre><code>http://ws.audioscrobbler.com/1.0/user/NeilCrosby/recenttracks.rss?limit=20
</code></pre>

<p>I use this as a way of getting a decent sampling of my recent tracks to use on <a href="http://NeilCrosby.com">NeilCrosby.com</a>, as I found the default 10 was too limiting since my &#8220;Stream of Consciousness&#8221; stream normally covers a few days worth of information, whereas my last 10 tracks would only cover an hour or so of data.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2008/12/how-to-get-more-than-the-last-10-recently-played-tracks-from-lastfm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Automatically Take Photos Using Your Mac&#8217;s Webcam</title>
		<link>http://thecodetrain.co.uk/2008/11/how-to-automatically-take-photos-using-your-macs-webcam/</link>
		<comments>http://thecodetrain.co.uk/2008/11/how-to-automatically-take-photos-using-your-macs-webcam/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 19:34:47 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[camcapture]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[isight]]></category>
		<category><![CDATA[scratching an itch]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=143</guid>
		<description><![CDATA[<p>On friday, <a href="http://marknormanfrancis.com/">Norm</a> happened across <a href="http://www.flickr.com/photos/thevoicewithin/2249082200/">one of my automated photos</a> on Flickr and asked me how I did it.  Because I realised that I couldn&#8217;t actually remember exactly how everything fitted together I decided to take a look at it again this weekend and actually write things up this time.</p>

<p><a href="http://www.flickr.com/photos/thevoicewithin/2249082200/" title="Where is my happy face, take 2 by thevoicewithin, on Flickr"><img src="http://farm3.static.flickr.com/2343/2249082200_49f25a4281.jpg" width="500" height="375" alt="Where is my happy face, take 2" /></a></p>

<p>So, here&#8217;s how to do it:</p>

<ol>
<li><p>Create a directory <code>/Applications/autocamcapture</code> &#8211; this is where the executables we&#8217;ll be using will live.</p></li>
<li><p>Create a directory <code>~/Pictures/autocamcapture</code> &#8211; this is where the automatically generated images will live.</p></li>
<li><p>Download <a href="http://slappingturtle.com/home/index.php?option=com_content&amp;task=view&amp;id=20&amp;Itemid=1">CamCapture</a> and put the executable in <code>/Applications/autocamcapture</code></p></li>
<li><p>Open the &#8220;Script Editor&#8221; application and enter the following:</p>

<pre><code>set commandPath to "/Applications/autocamcapture/"
set commandName to "camcapture"
set outputImagePath to "~/Pictures/autocamcapture/"
set outputImageName to do shell script "date +%Y%m%d-%H%M%S"
do shell script commandPath &amp; commandName &amp; " " &amp; outputImagePath &amp; outputImageName
</code></pre></li>
<li><p>Save this file as <code>/Applications/autocamcapture/autocamcapture.scpt</code></p></li>
<li><p>Open a terminal window, and run <code>crontab -e</code>.  Add the following cron job:</p>

<pre><code>*      *       *       *       *       osascript /Applications/autocamcapture/autocamcapture.scpt
</code></pre></li>
<li><p>Now, once a minute a cron job will be fired off and a picture will be taken and placed in your <code>~/Pictures/autocamcapture</code> directory.</p></li>
</ol>

<p>The obvious question to go with this is &#8220;but why would you do this?&#8221;.  Frankly, originally the answer was just &#8220;because I can&#8221;.  I carried on doing it though because in amongst all the dross that inevitably gets taken <a href="http://www.flickr.com/search/?q=automated&amp;w=36778932%40N00">some interesting photos do occur</a>.  Try it out yourself, you might snap something fun.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>On friday, <a href="http://marknormanfrancis.com/">Norm</a> happened across <a href="http://www.flickr.com/photos/thevoicewithin/2249082200/">one of my automated photos</a> on Flickr and asked me how I did it.  Because I realised that I couldn&#8217;t actually remember exactly how everything fitted together I decided to take a look at it again this weekend and actually write things up this time.</p>

<p><a href="http://www.flickr.com/photos/thevoicewithin/2249082200/" title="Where is my happy face, take 2 by thevoicewithin, on Flickr"><img src="http://farm3.static.flickr.com/2343/2249082200_49f25a4281.jpg" width="500" height="375" alt="Where is my happy face, take 2" /></a></p>

<p>So, here&#8217;s how to do it:</p>

<ol>
<li><p>Create a directory <code>/Applications/autocamcapture</code> &#8211; this is where the executables we&#8217;ll be using will live.</p></li>
<li><p>Create a directory <code>~/Pictures/autocamcapture</code> &#8211; this is where the automatically generated images will live.</p></li>
<li><p>Download <a href="http://slappingturtle.com/home/index.php?option=com_content&amp;task=view&amp;id=20&amp;Itemid=1">CamCapture</a> and put the executable in <code>/Applications/autocamcapture</code></p></li>
<li><p>Open the &#8220;Script Editor&#8221; application and enter the following:</p>

<pre><code>set commandPath to "/Applications/autocamcapture/"
set commandName to "camcapture"
set outputImagePath to "~/Pictures/autocamcapture/"
set outputImageName to do shell script "date +%Y%m%d-%H%M%S"
do shell script commandPath &amp; commandName &amp; " " &amp; outputImagePath &amp; outputImageName
</code></pre></li>
<li><p>Save this file as <code>/Applications/autocamcapture/autocamcapture.scpt</code></p></li>
<li><p>Open a terminal window, and run <code>crontab -e</code>.  Add the following cron job:</p>

<pre><code>*      *       *       *       *       osascript /Applications/autocamcapture/autocamcapture.scpt
</code></pre></li>
<li><p>Now, once a minute a cron job will be fired off and a picture will be taken and placed in your <code>~/Pictures/autocamcapture</code> directory.</p></li>
</ol>

<p>The obvious question to go with this is &#8220;but why would you do this?&#8221;.  Frankly, originally the answer was just &#8220;because I can&#8221;.  I carried on doing it though because in amongst all the dross that inevitably gets taken <a href="http://www.flickr.com/search/?q=automated&amp;w=36778932%40N00">some interesting photos do occur</a>.  Try it out yourself, you might snap something fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2008/11/how-to-automatically-take-photos-using-your-macs-webcam/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WikiSlurp: Slurping Data from Wikipedia for Fun and Profit</title>
		<link>http://thecodetrain.co.uk/2008/09/wikislurp-slurping-data-from-wikipedia-for-fun-and-profit/</link>
		<comments>http://thecodetrain.co.uk/2008/09/wikislurp-slurping-data-from-wikipedia-for-fun-and-profit/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 14:00:29 +0000</pubDate>
		<dc:creator>Neil Crosby</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[barcamp]]></category>
		<category><![CDATA[barcamplondon5]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[isneilannoyedby]]></category>
		<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scratching an itch]]></category>
		<category><![CDATA[thetenwordreview]]></category>
		<category><![CDATA[wikipedia]]></category>
		<category><![CDATA[wikislurp]]></category>

		<guid isPermaLink="false">http://thecodetrain.co.uk/?p=15</guid>
		<description><![CDATA[<p>This last weekend I attended <a href="http://barcamp.org/BarCampLondon5">BarCamp London 5</a>, where I talked about WikiSlurp, my technique for accessing the wealth of data held within Wikipedia.  I currently use WikiSlurp on both <a href="http://isneilannoyedby.com">Is Neil Annoyed By</a> and <a href="http://thetenwordreview.com">The Ten Word Review</a> as a way to pull in additional information about the things described on individual pages.</p>

<p>These are the slides I put together for my talk:</p>

<div style="width:425px;text-align:left" id="__ss_622769"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/neilcrosby/mining-wikipedia-for-awesome-data-presentation?type=powerpoint" title="Mining Wikipedia For Awesome Data">Mining Wikipedia For Awesome Data</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=mining-wikipedia-for-awesome-data-1222603282334492-9&#038;stripped_title=mining-wikipedia-for-awesome-data-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=mining-wikipedia-for-awesome-data-1222603282334492-9&#038;stripped_title=mining-wikipedia-for-awesome-data-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View SlideShare <a style="text-decoration:underline;" href="http://www.slideshare.net/neilcrosby/mining-wikipedia-for-awesome-data-presentation?type=powerpoint" title="View Mining Wikipedia For Awesome Data on SlideShare">presentation</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">Upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/wikislurp">wikislurp</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/wikipedia">wikipedia</a>)</div></div>

<p>If you just want to <a href="http://thecodetrain.co.uk/downloads/wikislurp-0.1.zip">download the Code</a>, go right ahead.  If you want to know more about the project, read the <a href="http://thecodetrain.co.uk/code/wikislurp/">WikiSlurp Project page</a>.</p>
<div style="display:block"><small><em><a href="http://neilcrosby.com">Neil Crosby</a> also blogs at about t-shirts at <a href="http://iwearcotton.com">I Wear Cotton</a>, writes <a href="http://thetenwordreview.com/users/workingwithme">Ten Word Reviews</a>, and uploads <a href="http://www.flickr.com/photos/thevoicewithin/">photos</a> to flickr.  You can follow a combined feed of posts at <a href="http://neilcrosby.com/">NeilCrosby.com</a>.</em></small></div>]]></description>
			<content:encoded><![CDATA[<p>This last weekend I attended <a href="http://barcamp.org/BarCampLondon5">BarCamp London 5</a>, where I talked about WikiSlurp, my technique for accessing the wealth of data held within Wikipedia.  I currently use WikiSlurp on both <a href="http://isneilannoyedby.com">Is Neil Annoyed By</a> and <a href="http://thetenwordreview.com">The Ten Word Review</a> as a way to pull in additional information about the things described on individual pages.</p>

<p>These are the slides I put together for my talk:</p>

<div style="width:425px;text-align:left" id="__ss_622769"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/neilcrosby/mining-wikipedia-for-awesome-data-presentation?type=powerpoint" title="Mining Wikipedia For Awesome Data">Mining Wikipedia For Awesome Data</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=mining-wikipedia-for-awesome-data-1222603282334492-9&#038;stripped_title=mining-wikipedia-for-awesome-data-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=mining-wikipedia-for-awesome-data-1222603282334492-9&#038;stripped_title=mining-wikipedia-for-awesome-data-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View SlideShare <a style="text-decoration:underline;" href="http://www.slideshare.net/neilcrosby/mining-wikipedia-for-awesome-data-presentation?type=powerpoint" title="View Mining Wikipedia For Awesome Data on SlideShare">presentation</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">Upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/wikislurp">wikislurp</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/wikipedia">wikipedia</a>)</div></div>

<p>If you just want to <a href="http://thecodetrain.co.uk/downloads/wikislurp-0.1.zip">download the Code</a>, go right ahead.  If you want to know more about the project, read the <a href="http://thecodetrain.co.uk/code/wikislurp/">WikiSlurp Project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecodetrain.co.uk/2008/09/wikislurp-slurping-data-from-wikipedia-for-fun-and-profit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
