<?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>stetho:scope</title>
	<atom:link href="http://blog.stetho.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stetho.co.uk</link>
	<description>I have my uses</description>
	<lastBuildDate>Mon, 22 Jun 2009 22:34:19 +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>AppleScript and File Creation Dates</title>
		<link>http://blog.stetho.co.uk/2009/06/22/applescript-and-file-creation-dates/</link>
		<comments>http://blog.stetho.co.uk/2009/06/22/applescript-and-file-creation-dates/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 21:51:22 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[mdls]]></category>
		<category><![CDATA[stat]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=37</guid>
		<description><![CDATA[Sorry I&#8217;ve been quiet. I&#8217;m unemployed after being made redundant and I&#8217;m putting all my efforts in to finding a new job. However, I did come across this little problem the other day and wanted to share my solution. Getting a list of folders from the Finder, sorted by their creation date:
property f : alias [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry I&#8217;ve been quiet. I&#8217;m unemployed after being made redundant and I&#8217;m putting all my efforts in to finding a new job. However, I did come across this little problem the other day and wanted to share my solution. Getting a list of folders from the Finder, sorted by their creation date:<br />
<code>property f : alias "Macintosh HD:Developer:"</p>
<p>tell application "Finder"<br />
	set filelist to sort (get folders in f) by creation date<br />
end tell</code></p>
<p>This does the job perfectly for a small number of folders. However, when you execute this on a large number of folder or, as was the case, on a large number of folder on a server volume, it becomes very slow and can even time out. So the way round it is to use the command line. However, Unix in general doesn&#8217;t store a creation date in the inode. By extension, neither does OS X or any version of Linux. But there is a way round this. Apple&#8217;s HFS+, the file system on Macs, does store metadata about a file which can be accessed in other ways. The <strong>mdls</strong> command lists the metadata for a file. Using the -name switch, we can see a specific item of the metadata:<br />
<code><br />
>mdls -name kMDItemFSCreationDate test_doc.pdf<br />
kMDItemFSCreationDate = 2009-02-22 19:13:59 +0000<br />
</code></p>
<p>The <strong>stat</strong> command gives us a better way to do it. <strong>stat</strong> returns the status of a file or folder. The string it returns contains various information including the creation date for the target. Unlike mdls, stat also gives us quite a few command line options that allow us to manipulate the output.<br />
<code><br />
> stat -f "%m%t%Sm %N" test_doc.pdf<br />
1014405239	Feb 22 19:13:59 2002 test_doc.pdf<br />
</code><br />
The -f switch tells stat to format the output using the string that follows. In this case, it&#8217;s timestamp, tab, long date, space, file name.</p>
<p>Next we sort the output numerically in reverse order<br />
<code><br />
stat -f "%m%t%Sm %N" * | sort -rn<br />
</code></p>
<p>And finally, we remove the timestamp that we sorted on by cutting everything in the first column<br />
<code>stat -f "%m%t%Sm %N" * | sort -rn | cut -f2-</code></p>
<p>So now we have code that lists our files in the current directory by creation time, we just need to turn it in to AppleScript.<br />
<code><br />
property f : alias "Server:Work In Progress:"<br />
do shell script "stat -f " &#038; quote &#038; "%m%t%Sm %N" &#038; quote &#038; " " &#038; quoted form of POSIX path of f &#038; "* | sort -rn | cut -f2-"</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2009/06/22/applescript-and-file-creation-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A special post for @simX</title>
		<link>http://blog.stetho.co.uk/2009/04/03/a-special-post-for-simx/</link>
		<comments>http://blog.stetho.co.uk/2009/04/03/a-special-post-for-simx/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 20:26:29 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=32</guid>
		<description><![CDATA[AppleScript is unable to convert certain types of item properties in to other classes. For example, this doesn&#8217;t work:
every window whose bounds is {658, 277, 1539, 777}
Not because a window with those bounds doesn&#8217;t exist, but because the bounds are of class &#8220;Property&#8221; not &#8220;List&#8221;. Because AppleScript can&#8217;t tell that {658, 277, 1539, 777} is [...]]]></description>
			<content:encoded><![CDATA[<p>AppleScript is unable to convert certain types of item properties in to other classes. For example, this doesn&#8217;t work:</p>
<p><code>every window whose bounds is {658, 277, 1539, 777}</code></p>
<p>Not because a window with those bounds doesn&#8217;t exist, but because the bounds are of class &#8220;Property&#8221; not &#8220;List&#8221;. Because AppleScript can&#8217;t tell that {658, 277, 1539, 777} is a list it tries to covert it to text and fails. This is how you find a window by its bounds:</p>
<p><code><br />
tell application "Finder"<br />
	set theWindows to {}<br />
	repeat with i from 1 to count of windows<br />
		tell window i<br />
			if (get bounds) is {488, 123, 1369, 623} then<br />
				copy name to end of theWindows<br />
			end if<br />
		end tell<br />
	end repeat<br />
	theWindows<br />
end tell<br />
</code></p>
<p>Which, on my machine right now, returns the list {&#8220;Applications&#8221;}.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2009/04/03/a-special-post-for-simx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby On Rails on ClarkConnect 4.3</title>
		<link>http://blog.stetho.co.uk/2009/02/02/installing-ruby-on-rails-on-clarkconnect-43/</link>
		<comments>http://blog.stetho.co.uk/2009/02/02/installing-ruby-on-rails-on-clarkconnect-43/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 15:05:33 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[ClarkConnect]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=24</guid>
		<description><![CDATA[After a bit of messing around, this is how I got Ruby and RoR installed on my Clark Connect server. There are some pointers on the Clark Connect Forums but I still ran in to a number of errors that I had to figure out. So I&#8217;m putting it here for my own reference and [...]]]></description>
			<content:encoded><![CDATA[<p>After a bit of messing around, this is how I got Ruby and RoR installed on my Clark Connect server. There are some pointers on the Clark Connect Forums but I still ran in to a number of errors that I had to figure out. So I&#8217;m putting it here for my own reference and for anyone else who needs this information. Note that this installs Ruby-1.8.1.If you need something newer, you&#8217;ll need to install Ruby from scratch.</p>
<p>If you haven&#8217;t already done so, follow the instructions here for upgrading MySQL and PHP &#8211; <a href="http://www.clarkconnect.com/docs/Howtos_-_Installing_PHP_5_and_MySQL_5_on_ClarkConnect_4.x">Installing PHP 5 and MySQL 5 on Clark Connect.</a> This adds an Apt resource needed by the instructions below.</p>
<pre>
apt-get install httpd-devel ruby mysqlclient14 mysql-devel
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -zxvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
ruby setup.rb
gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config
gem install rails --include-dependencies</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2009/02/02/installing-ruby-on-rails-on-clarkconnect-43/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More AppleScript stuff</title>
		<link>http://blog.stetho.co.uk/2008/12/19/more-applescript-stuff/</link>
		<comments>http://blog.stetho.co.uk/2008/12/19/more-applescript-stuff/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 12:47:09 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[PDF]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=19</guid>
		<description><![CDATA[Creating a PDF from AppleScript
This creates test.pdf on your desktop from a variable containing text:
do shell script ("echo " &#38; quote &#38; your_text_variable &#38; quote &#38;
" &#124; /usr/bin/enscript -q -B --word-wrap -p -f Helvetica12 - 
 &#124; /usr/bin/pstopdf -i -o ~/Desktop/test.pdf")
]]></description>
			<content:encoded><![CDATA[<p><strong>Creating a PDF from AppleScript</strong></p>
<p>This creates test.pdf on your desktop from a variable containing text:</p>
<pre>do shell script ("echo " &amp; quote &amp; <span style="color: #ff0000;">your_text_variable</span> &amp; quote &amp;</pre>
<pre>" | /usr/bin/enscript -q -B --word-wrap -p <span class="punct">-</span><span class="ident">f</span> <span class="constant">Helvetica12 - </span></pre>
<pre><span class="constant"> | /usr/bin/pstopdf -i -o ~/Desktop/test.pdf")</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2008/12/19/more-applescript-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now that&#8217;s what I call a reference.</title>
		<link>http://blog.stetho.co.uk/2008/11/28/now-thats-what-i-call-a-reference/</link>
		<comments>http://blog.stetho.co.uk/2008/11/28/now-thats-what-i-call-a-reference/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 15:56:22 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[work]]></category>
		<category><![CDATA[Job Hunting]]></category>
		<category><![CDATA[References]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=14</guid>
		<description><![CDATA[Need to find some way of working this in to my Online CV.

]]></description>
			<content:encoded><![CDATA[<p>Need to find some way of working this in to my <a href="http://www.stetho.co.uk/cv">Online CV</a>.</p>
<p><a href="http://www.charlesarthur.com/"><img alt="" src="/images/catwitterquote2.jpg" title="Charles Arthur Reference" class="alignleft" width="478" height="77" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2008/11/28/now-thats-what-i-call-a-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript Questions on allexperts.com</title>
		<link>http://blog.stetho.co.uk/2008/11/26/applescript-questions-on-allexpertscom/</link>
		<comments>http://blog.stetho.co.uk/2008/11/26/applescript-questions-on-allexpertscom/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 14:39:28 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=11</guid>
		<description><![CDATA[For the past couple of years, I&#8217;ve been a voluteer on the questions and answers site, AllExperts.com. In that time I&#8217;ve mainly answered questions about broken hard disks and printers but every now and then an AppleScript question has appeared.
I&#8217;m going to start putting the questions and answer up on this blog for other people [...]]]></description>
			<content:encoded><![CDATA[<p>For the past couple of years, I&#8217;ve been a voluteer on the questions and answers site, <a href="http://www.allexperts.com/">AllExperts.com</a>. In that time I&#8217;ve mainly answered questions about broken hard disks and printers but every now and then an AppleScript question has appeared.</p>
<p>I&#8217;m going to start putting the questions and answer up on this blog for other people to see. There&#8217;s bound to be more than one person having a problem.</p>
<p><strong>Is there a specific AppleScript function to alter the boundaries of Firefox windows?</strong><br />
FireFox AppleScript support is really poor. Almost non-existent in fact. As the windows are part of the window manager you can address them through System Events:</p>
<p><code>tell application "System Events" to set size of window 1 of process "Firefox" to {300,300}</code></p>
<p><strong>How do you enable Spaces and add an extra row and column?</strong><br />
<code><br />
tell application "System Events"<br />
tell spaces preferences of expose preferences<br />
set spaces enabled to true<br />
set spaces columns to 3<br />
set spaces rows to 3<br />
end tell<br />
end tell<br />
</code></p>
<p><strong>How can I get all elements of a list except the last one?</strong></p>
<p><code>if (count of your_list) is greater than 1 then set your list to items 1 thru -2 of your_list</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2008/11/26/applescript-questions-on-allexpertscom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AppleScript to convert CMYK to RGB values</title>
		<link>http://blog.stetho.co.uk/2008/06/12/applescript-to-convert-cmyk-to-rgb-values/</link>
		<comments>http://blog.stetho.co.uk/2008/06/12/applescript-to-convert-cmyk-to-rgb-values/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 21:29:17 +0000</pubDate>
		<dc:creator>stetho</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[CMYK]]></category>
		<category><![CDATA[RGB]]></category>

		<guid isPermaLink="false">http://blog.stetho.co.uk/?p=3</guid>
		<description><![CDATA[A couple of days ago someone asked me if I knew how to convert CMYK to RGB using AppleScript. After boring them silly with my explanation of colour models and explaining that it&#8217;s not really possible, I came up with this which is a close approximation and finally gives me something to put on my [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago someone asked me if I knew how to convert CMYK to RGB using AppleScript. After boring them silly with my explanation of colour models and explaining that it&#8217;s not really possible, I came up with this which is a close approximation<em> and</em> finally gives me something to put on my blog.</p>
<pre>on cmykrgb(c, m, y, k)

    set r to 255 - (round (2.55 * (c + k)))
    set g to 255 - (round (2.55 * (m + k)))
    set b to 255 - (round (2.55 * (y + k)))

    if (r &lt; 0) then set r to 0
    if (g &lt; 0) then set g to 0
    if (b &lt; 0) then set b to 0

    return {r, g, b}
end cmykrgb</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.stetho.co.uk/2008/06/12/applescript-to-convert-cmyk-to-rgb-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
