<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Voodoo Programming</title>
	<atom:link href="http://www.cneophytou.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cneophytou.com</link>
	<description>Things programmers do that they know shouldn&#039;t work but they try anyway, and which sometimes actually work, such as recompiling everything.</description>
	<lastBuildDate>Mon, 20 Feb 2012 22:38:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Photo feed as Desktop Background</title>
		<link>http://www.cneophytou.com/2008/04/17/photo-feed-as-desktop-background/</link>
		<comments>http://www.cneophytou.com/2008/04/17/photo-feed-as-desktop-background/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 15:14:57 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[CC Licence]]></category>
		<category><![CDATA[Chromasia]]></category>
		<category><![CDATA[ddoi]]></category>
		<category><![CDATA[Feed]]></category>
		<category><![CDATA[Google Apps]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/?p=110</guid>
		<description><![CDATA[I first came up with this idea after reading a post on HackerMoJo.com about getting an RSS feed of images as a Screen Saver using a python script. The idea is simple: Take a feed, parse it, and save the photos it links to as numbered images in a folder on the disk, then use [...]]]></description>
			<content:encoded><![CDATA[I first came up with this idea after reading a post on <a href="http://hackermojo.com/mt-static/archives/2008/04/metropulse-launched.html">HackerMoJo.com</a> about getting an RSS feed of images as a Screen Saver using a python script. The idea is simple: Take a feed, parse it, and save the photos it links to as numbered images in a folder on the disk, then use that folder as a Screen Saver. Well, as it turns out you can also use that folder as a desktop background, but there are a few improvements that can be made.<br />
<br />
First, the script only worked with that particular feed. If you wanted to use a different feed, you would have to change the code. Second, the script would always download all the photos linked to from the feed, thus increasing the load placed on the hosting server. I wanted to use the script to download the photos from <a href="http://www.chromasia.com/iblog">Chromasia</a>, which brings me to point number three: some feeds don't link to the large photo, but instead only include a thumbnail. To solve these issues, I created a small application using Google's wonderful <a href="http://code.google.com/appengine/">App Engine</a>, which takes care of everything. More on how to use this after the jump.<br />
<span id="more-110"></span>
<br />
This application takes care of keeping a database of the most recent photos linked to from the provided feeds, thus balancing the load placed on the hosting servers, and also allowing me to serve the feeds in a single standardised format. So far, the script supports the feeds of David Nightingale's <a href="http://www.chromasia.com/iblog">Chromasia</a> who kindly agreed to let me download web-scaled versions of his photos for use with this script and also helped me test early versions of the app, and Sam Javanrouh's <a href="http://wvs.topleftpixel.com/">daily dose of imagery</a>.<br />
<br />
There are several ways to use these feeds. The easiest way is through iPhoto 6 or 7. Just subscribe to the iPhoto photo feed for either chromasia (<a href="http://deskfeed.neophytou.net/feed/chromasia">http://deskfeed.neophytou.net/feed/chromasia</a>) or daily dose of imagery (<a href="http://deskfeed.neophytou.net/feed/ddoi">http://deskfeed.neophytou.net/feed/ddoi</a>). There are three down sides to using this method: You have to open iPhoto every day to refresh the feeds manually, every time iPhoto refreshes it has to download all the photos over again, and you can only use the photos from a single feed, not multiple ones. Also in Tiger, I believe you can only use an iPhoto photo feed as a Screen Saver, not as a Desktop Background.<br />
<br />
The other way to use this application, is through a small Python script which I wrote. To use this, you need to create a folder called DeskFeed inside the Pictures folder located in your Home directory (resulting path: ~/Pictures/DeskFeed, where ~/ is your home directory). Then, <a href='http://www.cneophytou.com/wp-content/uploads/2008/04/deskfeed.py'>download this script</a> into the folder you just created, and run the following commands in the Terminal (found under <code>Applications/Utilities/Terminal</code>):</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x ~<span style="color: #000000; font-weight: bold;">/</span>Pictures<span style="color: #000000; font-weight: bold;">/</span>DeskFeed<span style="color: #000000; font-weight: bold;">/</span>deskfeed.py
~<span style="color: #000000; font-weight: bold;">/</span>Pictures<span style="color: #000000; font-weight: bold;">/</span>DeskFeed<span style="color: #000000; font-weight: bold;">/</span>deskfeed.py</pre></div></div>



<p>
This will automatically download the latest photos from the Chromasia and daily dose of imagery blogs, and save them in the DeskFeed folder. To modify which feeds are downloaded (or not), open the deskfeed.py file you just downloaded and comment out / uncomment the photo feeds you want on the first few lines that are clearly marked. You can have as many feeds as you want in the script, but they have to be generated from the App Engine script which I wrote.<br />
<br />
To set this up as a periodic task using <code>cron</code>, create a text file on your desktop called <code>dfcron</code>, and in it place this single line:</p>


<div class="wp_syntax"><div class="code"><pre class="cron" style="font-family:monospace;">5      1       *       *       *       /Users/username/Pictures/DeskFeed/deskfeed.py</pre></div></div>



<p>
Make sure you replace <code>username</code> with your own short username. What this file contains is a command that will tell <code>cron</code> to run the <code>deskfeed.py</code> file every day at 5 minutes past 1am. Then, run this command in the terminal once:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">crontab ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>dfcron</pre></div></div>



<p>
You can now safely delete dfcron. To set this folder as your desktop background, go to System Preferences / Desktop &amp; Screen Saver, press the little '+' button under the list of folders, navigate to the DeskFeed folder, and select Choose. I found that "Fit to Screen" with a black background works best.<br />
<br />
I am open to suggestions about what other photo feeds to include in this application, it only takes about 10 minutes to add a new feed. Furthermore, I will be creating a more solid application that will be customisable through preferences rather than relying on a Python script. But as this is a first attempt, I'm publishing the code to the script to see if anyone else has any suggestions for improvement. If you just want to look at the code used instead of downloading the above file, here it is:</p>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">md5</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">urllib</span> <span style="color: #ff7700;font-weight:bold;">import</span> URLopener
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">urllib2</span> <span style="color: #ff7700;font-weight:bold;">import</span> urlopen
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span>.<span style="color: black;">minidom</span> <span style="color: #ff7700;font-weight:bold;">import</span> parseString
&nbsp;
rss_feeds = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Comment / Uncomment the following lines to use the required feeds</span>
<span style="color: #808080; font-style: italic;">#</span>
rss_feeds<span style="color: black;">&#91;</span><span style="color: #483d8b;">'chromasia'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'http://deskfeed.neophytou.net/rss/chromasia'</span>
rss_feeds<span style="color: black;">&#91;</span><span style="color: #483d8b;">'ddoi'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'http://deskfeed.neophytou.net/rss/ddoi'</span>
&nbsp;
dst_dir = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">expanduser</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'~/Pictures/DeskFeed/'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Based on script found at HackerMoJo.com</span>
<span style="color: #808080; font-style: italic;"># http://hackermojo.com/mt-static/archives/2008/04/metropulse-launched.html</span>
<span style="color: #ff7700;font-weight:bold;">def</span> parseFeed<span style="color: black;">&#40;</span>rss<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">try</span>:
    rss_contents = urlopen<span style="color: black;">&#40;</span> rss <span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Failed to read rss feed %s&quot;</span> <span style="color: #66cc66;">%</span> rss
    <span style="color: #ff7700;font-weight:bold;">return</span>
  rss_src = rss_contents.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  rss_contents.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  dom = parseString<span style="color: black;">&#40;</span> rss_src <span style="color: black;">&#41;</span>
  node_lst = dom.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'item'</span><span style="color: black;">&#41;</span>
  items = <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>node_lst.<span style="color: black;">length</span><span style="color: black;">&#41;</span>
  hashes = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
  group = node_lst.<span style="color: black;">item</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'title'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">getAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'group'</span><span style="color: black;">&#41;</span>
  <span style="color: #808080; font-style: italic;"># Store the md5 hashes of all the saved photos</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> items:
    img_filename = <span style="color: #483d8b;">&quot;%s%s_%s.jpg&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>dst_dir,group,i<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      image_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>img_filename, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
      hashes<span style="color: black;">&#91;</span>img_filename<span style="color: black;">&#93;</span> = <span style="color: #dc143c;">md5</span>.<span style="color: #dc143c;">md5</span><span style="color: black;">&#40;</span>image_file.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">hexdigest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      image_file.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span>:
      hashes<span style="color: black;">&#91;</span>img_filename<span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">pass</span>
  <span style="color: #808080; font-style: italic;"># Go through all the photos in the rss feed, in reverse order</span>
  items.<span style="color: black;">reverse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> items:
    element = node_lst.<span style="color: black;">item</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span>
    group = element.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'title'</span> <span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">getAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'group'</span><span style="color: black;">&#41;</span>
    link = element.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'link'</span> <span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">getAttribute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'source'</span><span style="color: black;">&#41;</span>
    photo_hash = element.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'hash'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">firstChild</span>.<span style="color: black;">data</span>
    img_filename = <span style="color: #483d8b;">&quot;%s%s_%s.jpg&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>dst_dir, group, i<span style="color: black;">&#41;</span>
    <span style="color: #808080; font-style: italic;"># Check all the saved photos and see if any of them have the same hash</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span>:
      old_img_filename = <span style="color: #483d8b;">&quot;%s%s_%s.jpg&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>dst_dir, group, j<span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>hashes<span style="color: black;">&#91;</span>old_img_filename<span style="color: black;">&#93;</span> == photo_hash<span style="color: black;">&#41;</span>:
        <span style="color: #808080; font-style: italic;"># If one does, give it the current photo filename</span>
        <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;mv %s %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>old_img_filename, img_filename<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        hashes<span style="color: black;">&#91;</span>old_img_filename<span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;&quot;</span>
        hashes<span style="color: black;">&#91;</span>img_filename<span style="color: black;">&#93;</span> = photo_hash
        <span style="color: #ff7700;font-weight:bold;">break</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      image_file = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>img_filename, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
      old_hash = <span style="color: #dc143c;">md5</span>.<span style="color: #dc143c;">md5</span><span style="color: black;">&#40;</span>image_file.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">hexdigest</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      image_file.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>old_hash == photo_hash<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">continue</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span>:
      <span style="color: #ff7700;font-weight:bold;">pass</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
      URLopener<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">retrieve</span><span style="color: black;">&#40;</span>link, img_filename<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span>:
      <span style="color: #ff7700;font-weight:bold;">continue</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">for</span> key <span style="color: #ff7700;font-weight:bold;">in</span> rss_feeds:
    parseFeed<span style="color: black;">&#40;</span>rss_feeds<span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
  main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>



<p>
<a href='http://www.cneophytou.com/wp-content/uploads/2008/04/deskfeed.py'>Download this script</a><br />
<br />
That's pretty much it. As you can see, the script is not that complicated, and I can very easily modify the way the photos are served to the clients. This code has been tested under Leopard using Python 2.5, but also under Ubuntu using Python 2.4.3, and I believe it should also work under Tiger using Python 2.3, but I could very well be wrong. So as always, I'm open to feedback and suggestions. If anyone knows how to create a Preference pane, please contact me. I know exactly what needs to be done in the Preference pane, but I have no idea how to use Xcode.]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/04/17/photo-feed-as-desktop-background/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Downloading your code from Google App Engine</title>
		<link>http://www.cneophytou.com/2008/04/17/downloading-your-code-from-google-app-engine/</link>
		<comments>http://www.cneophytou.com/2008/04/17/downloading-your-code-from-google-app-engine/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 14:42:23 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Apps]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/?p=112</guid>
		<description><![CDATA[I've started using Google's App Engine since it launched, mostly playing around with Python (always wanted to learn), and setting up a small app to deal with my Desktop Photo Feed script. One irritation I had was that I wanted to share my code with a friend, but the app engine doesn't provide any way [...]]]></description>
			<content:encoded><![CDATA[I've started using Google's <a href="http://appengine.google.com/">App Engine</a> since it launched, mostly playing around with Python (always wanted to learn), and setting up a small app to deal with my <a href="http://www.cneophytou.com/2008/04/17/photo-feed-as-desktop-background/">Desktop Photo Feed</a> script. One irritation I had was that I wanted to share my code with a friend, but the app engine doesn't provide any way of downloading the source code.<br />
<br />
One way around this that I found, was a blog post by <a href="http://david-burger.blogspot.com/">David Burger</a> on <a href="http://david-burger.blogspot.com/2008/04/download-your-code-from-google-app.html">Download Your Code from Google App Engine</a>, where he created a Makefile to do the dirtywork. Because I don't like Makefiles (and have it from good authority that Googlers hate Makefiles too, but that's besides the point - just to reinforce my position), I modified his method to make it slightly more versatile so that it can work well with OS X (<code>tar</code> includes ._* resource fork files which are annoying), and also turn it into a shell script.<br />
<span id="more-112"></span>
<br />
There are two steps to the process. First, save this code as a file called something like <code>update.sh</code> in the base folder where your app code is located, and make it executable:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">ARCHIVE_DIR</span>=archive
<span style="color: #007800;">ARCHIVE_NAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">`</span>.tgz
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #800000;">${ARCHIVE_DIR}</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*~&quot;</span> <span style="color: #660033;">-delete</span>
<span style="color: #c20cb9; font-weight: bold;">find</span> . <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;*pyc&quot;</span> <span style="color: #660033;">-delete</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">COPY_EXTENDED_ATTRIBUTES_DISABLE</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">COPYFILE_DISABLE</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-czf</span> <span style="color: #800000;">${ARCHIVE_NAME}</span> <span style="color: #660033;">--exclude</span> .DS_Store <span style="color: #660033;">--exclude</span> <span style="color: #800000;">${ARCHIVE_NAME}</span> <span style="color: #660033;">-C</span> ..<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${ARCHIVE_DIR}</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${ARCHIVE_NAME}</span> <span style="color: #800000;">${ARCHIVE_DIR}</span>
appcfg.py update .<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>



<p>
<a href='http://www.cneophytou.com/wp-content/uploads/2008/04/update.sh'>Download this script</a><br />
<br />
Then, you would probably want to password protect the resource that points to this archive file, so add this to your <code>app.yaml</code> file:</p>


<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">- url: /archive
  static_dir: archive
  login: admin</pre></div></div>



<p>
Now, whenever you wish to update your app, just execute <code>./update.sh</code> instead of <code>./appcfg.py update ./</code>, and the archive of your source will be created and uploaded with your changes. To download, assuming the folder your application is in has the same name as your application, just visit <code>http://yourapp.appspot.com/archive/yourapp.tgz</code> where <code>yourapp</code> is your app's name, and <code>yourapp.tgz</code> is your app folder's name if it's different from your app's name, and you will be prompted to download the archive assuming you're logged in as administrator. That's it!]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/04/17/downloading-your-code-from-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Smooth SSH Passwordless Authentication</title>
		<link>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/</link>
		<comments>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 14:36:17 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/</guid>
		<description><![CDATA[This post first appeared on the Voodoo Finance blog which is maintained by my friend Constantinos Michael, and I&#8217;m recreating it here with some extensions so I can find the code more easily when I need it. Using computers remotely is a big part of what I do. Whether I&#8217;m at home and need to [...]]]></description>
			<content:encoded><![CDATA[This post first appeared on the <a href='http://cmichae.acm.jhu.edu/blog/2007/01/18/ssh-passwordless-authentication/'>Voodoo Finance</a> blog which is maintained by my friend <a href='http://cmichae.acm.jhu.edu/'>Constantinos Michael</a>, and I&#8217;m recreating it here with some extensions so I can find the code more easily when I need it.<br />
<br />
Using computers remotely is a big part of what I do. Whether I&#8217;m at home and need to connect to a computer in the lab, or in the lab or the road and need to connect to my home computer. The way I (and pretty much most other linux users) is through SSH. If you&#8217;ve ever had to open more than one ssh connection however, it gets old pretty quickly. First you need to remember the host (and potentially the port, if it&#8217;s not standard) of the machine you&#8217;re connecting to, and also your username on that machine. After those are typed in, you need to enter your password every time you initiate a new connection. Well, all of the above can be automated with a few quick keystrokes in the terminal.<br />
<span id="more-109"></span>
<br />
The first step is to generate an SSH key pair. This private / public key pair will be used to authenticate you on the target machine. As it&#8217;s using an RSA key pair, you can probably leave the passphrase empty as the attacker would first need access to your private key. If you&#8217;re really paranoid, you can type in an easy password (but you&#8217;ll need to type this password in every time you use the key). To generate this key, type the following in a terminal window:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>



<p>
After this is done, you&#8217;re ready to install this key on any remote machine you wish to access. Before you do that however, I suggest setting up some aliases to the target machine so you don&#8217;t have to type the host and username every time you wish to log in. To do that, you need to edit (or create) a file called <code>~/.ssh/config</code>. In this file, you can enter a block of text for each host you wish to create an alias for. You can add as many hosts you want, just make sure there&#8217;s an empty line between each configuration. This is an example of what needs to go in this file:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">host lab
user admin
HostName www.example.com
port 12345</pre></div></div>



<p>
There are many more options that can go in there, and it mostly depends on your setup. But for anything that you don&#8217;t need to specify in the ssh command line, you don&#8217;t need to add an option for in this file. For example with the text I provided above, when you type <code>ssh lab</code> in the command line, it will try to connect to <code>www.example.com</code> using the username <code>admin</code> on port <code>12345</code>. This would be equivalent to typing <code>ssh <span class="oe_textdirection">&#x6d;&#x6f;&#x63;&#x2e;&#x65;&#x6c;&#x70;&#x6d;&#x61;&#x78;&#x65;&#x2e;&#x77;&#x77;&#x77;<span class="oe_displaynone">null</span>&#x40;&#x6e;&#x69;&#x6d;&#x64;&#x61;</span> -oPort=12345</code>. Much easier, isn&#8217;t it?<br />
<br />
Now on to the juicy stuff. Create a script that will install your key on the remote machine. To do that, paste these instructions in the terminal:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key ;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+<span style="color: #c20cb9; font-weight: bold;">w</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;cat ~/.ssh/id_rsa.pub | ssh <span style="color: #000099; font-weight: bold;">\$</span>{1} <span style="color: #000099; font-weight: bold;">\&quot;</span>cat - &gt;&gt; ~/.ssh/authorized_keys<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> \
     <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w+x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key</pre></div></div>



<p>
At this stage, you&#8217;re done with the setup. All you need to do is type</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ssh-install-key lab</pre></div></div>



<p>
in the terminal window (assuming you&#8217;ve set up the above <code>config</code> file with a host called <code>lab</code>), enter  your password as many times as you&#8217;re prompted, and you&#8217;re done! Every subsequent time you wish to connect to this machine, all you need to do is type <code>ssh lab</code>, and you&#8217;re immediately connected, no questions asked! (Unless of course you provided a passphrase for your key pair, in which case you will be prompted for that password).]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simulating encrypted physical disk in OS X</title>
		<link>http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/</link>
		<comments>http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 22:01:55 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[CC Licence]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Finder]]></category>
		<category><![CDATA[Folder Actions]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/01/30/simulating-encrypted-thumb-drive-in-os-x/</guid>
		<description><![CDATA[I&#8217;ve always wanted to do this: have my personal files on a memory stick, encrypted, and when I insert the memory stick in a USB port then OS X asks me for a password to decrypt the files. Unfortunately, this functionality isn&#8217;t offered directly as you can&#8217;t (at least from what I&#8217;ve tried and read) [...]]]></description>
			<content:encoded><![CDATA[I&#8217;ve always wanted to do this: have my personal files on a memory stick, encrypted, and when I insert the memory stick in a USB port then OS X asks me for a password to decrypt the files. Unfortunately, this functionality isn&#8217;t offered directly as you can&#8217;t (at least from what I&#8217;ve tried and read) encrypt a device directly. What you can do however is create encrypted disk images, and place them in your thumb drive. There are two disadvantages with this method: First the process isn&#8217;t automatic, first the drive mounts, then you have to double-click on the encrypted disk image to mount it, and second after you do that you have two volumes on your Desktop. One for the thumb drive, and one for the encrypted image.<br />
<br />
Obviously, in my obsessive compulsive need to have everything work as I want them, I didn&#8217;t like this. As a result, I created the following scripts (including a folder action) which pretty much simulate the whole experience. These scripts were only tested on 10.5.1, but they should work on at least Tiger.<br />
<span id="more-107"></span>
<br />
<span class="update">Update 2008-02-01:</span> <a href='http://www.cneophytou.com/wp-content/uploads/2008/02/secure_scripts.tgz' title='Applescripts bundle'>Download</a> all the scripts featured on this page in a single archive file.<br />
<br />
<span class="update">Update 2008-02-08:</span> The automount and prepare scripts in the download archive were reversed (my mistake) which is now fixed. I also added compatibility for sparsebundle types, and the password entry when preparing a drive is now hidden (thanks John!)<br />
<br />
There are two steps to the process. The first step is to prepare the memory stick, and the second is to configure the folder action. The first step only has to be applied once, and works best on a freshly formatted memory stick, however it doesn&#8217;t have to be formatted; it will use all the available space to create the encrypted image. Save the following script as an application bundle somewhere, plug in the memory stick you wish to use as your &#8216;encrypted storage&#8217;, and drag-drop the mounted volume on the bundle. It will ask you for a password (which is typed in the clear &#8211; fair warning), then after a few minutes (with the default settings) it will finish creating the encrypted image, mark the entire volume as hidden, and eject the drive.</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">(*
    Prepare secure drive droplet
    Part of 'Simulating encrypted physical disk in OS X' by Constantinos Neophytou
    http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/
&nbsp;
    Version 0.1.1
*)</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">property</span> imageType : <span style="color: #009900;">&quot;UDIF&quot;</span> <span style="color: #808080; font-style: italic;">(* one of &quot;UDIF&quot;, &quot;SPARSE&quot; or &quot;SPARSEBUNDLE&quot; - the latter two have faster creation times, but leave empty space on the device *)</span>
<span style="color: #ff0033; font-weight: bold;">property</span> thePass : <span style="color: #009900;">&quot;&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">open</span> dropped_item
    <span style="color: #ff0033; font-weight: bold;">set</span> this_vol_alias <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>dropped_item <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">the</span> kind <span style="color: #ff0033; font-weight: bold;">of</span> this_vol_alias <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Volume&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> freeSpace <span style="color: #ff0033; font-weight: bold;">to</span> free <span style="color: #0066ff;">space</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_vol_alias
                <span style="color: #ff0033; font-weight: bold;">set</span> volumeName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_vol_alias
                <span style="color: #ff0033; font-weight: bold;">set</span> imgSize <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>round <span style="color: #000000;">&#40;</span>freeSpace <span style="color: #000000;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">1024</span> <span style="color: #000000;">*</span> <span style="color: #000000;">1024</span> <span style="color: #000000;">*</span> <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">/</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">1024</span> <span style="color: #000000;">*</span> <span style="color: #000000;">1024</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #808080; font-style: italic;">(* leave 1mb of free space, just in case *)</span>
&nbsp;
                <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Enter password for encrypted image:&quot;</span> <span style="color: #0066ff;">default answer</span> thePass <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">hidden</span> answer
                <span style="color: #ff0033; font-weight: bold;">set</span> thePass <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">text</span> returned <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">result</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
&nbsp;
                <span style="color: #ff0033; font-weight: bold;">set</span> createImg <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;hdiutil create &quot;</span> <span style="color: #000000;">&amp;</span> volumeName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;.secure -size &quot;</span> <span style="color: #000000;">&amp;</span> imgSize <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;m -fs HFS+ -type &quot;</span> <span style="color: #000000;">&amp;</span> imageType <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; -encryption -volName Secure -passphrase &quot;</span> <span style="color: #000000;">&amp;</span> thePass
                <span style="color: #ff0033; font-weight: bold;">set</span> thePass <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #808080; font-style: italic;">(* clear the password from memory *)</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> hideVol <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;chflags hidden &quot;</span> <span style="color: #000000;">&amp;</span> volumeName
                <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #ff0033; font-weight: bold;">timeout</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">600</span> seconds
                    <span style="color: #0066ff;">do shell script</span> createImg
                    <span style="color: #0066ff;">do shell script</span> hideVol
                    <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;hdiutil detach &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_vol_alias
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">timeout</span>
            <span style="color: #ff0033; font-weight: bold;">else</span>
                display alert <span style="color: #009900;">&quot;This script can only be executed on volumes&quot;</span>
                <span style="color: #ff0033; font-weight: bold;">return</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span> error_message <span style="color: #0066ff;">number</span> error_number
        <span style="color: #0066ff;">display dialog</span> error_message <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;OK&quot;</span><span style="color: #000000;">&#125;</span> default button <span style="color: #000000;">1</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">open</span></pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2008/02/secure_scripts.tgz">Download all scripts</a><br />
<br />
At this point, the memory stick is configured for use with the folder action. Warning: If you remove the drive and plug it back in without the folder action being in place, the disk will mount but it won&#8217;t show up in the Finder. You will have to use Disk Utility or the Terminal to un-mount it. Go ahead and copy the following code, save it as a script under <code>/Library/Scripts/Folder Action Scripts/</code>, and attach it as a folder action to <code>/Volumes</code>.</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">(*
    Automount secure drive folder action
    Part of 'Simulating encrypted physical disk in OS X' by Constantinos Neophytou
    http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/
&nbsp;
    Version 0.1.1
*)</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">property</span> secureName : <span style="color: #009900;">&quot;.secure&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span> this_folder <span style="color: #ff0033;">after</span> <span style="color: #0066ff;">receiving</span> these_volumes
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> volume_list <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">file</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_folder
            <span style="color: #808080; font-style: italic;">(* go through all entries in /Volumes/ *)</span>
            <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> volume_list
                <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> original <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> volume_list
                <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">the</span> kind <span style="color: #ff0033; font-weight: bold;">of</span> this_item <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Volume&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                    <span style="color: #ff0033; font-weight: bold;">set</span> this_disk <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>this_item <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><span style="color: #000000;">&#41;</span>
&nbsp;
                    <span style="color: #808080; font-style: italic;">(* is this item the newly mounted disk? *)</span>
                    <span style="color: #ff0033; font-weight: bold;">if</span> this_disk <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033; font-weight: bold;">in</span> these_volumes <span style="color: #ff0033; font-weight: bold;">then</span>
                        <span style="color: #808080; font-style: italic;">(* iterate through all files in the root of disk *)</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> searchCmd <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;ls -d &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk <span style="color: #000000;">&amp;</span> secureName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;*&quot;</span>
                        <span style="color: #808080; font-style: italic;">(* check to see if a hidden secure image  is available *)</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">try</span>
                            <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> searchCmd
                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
                        <span style="color: #808080; font-style: italic;">(* mount the secure image *)</span>
                        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>searchResult starts <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #009900;">&quot;/Volumes&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                            <span style="color: #ff0033; font-weight: bold;">set</span> hiddenFile <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">POSIX file</span> searchResult <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span>
                            <span style="color: #0066ff;">open</span> hiddenFile
                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> removing <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">from</span> this_folder <span style="color: #ff0033;">after</span> losing these_items
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">try</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> volume_list <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">file</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_folder
            <span style="color: #808080; font-style: italic;">(* go through all entries in /Volumes/ *)</span>
            <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> volume_list
                <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> original <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> volume_list
                <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">the</span> kind <span style="color: #ff0033; font-weight: bold;">of</span> this_item <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Volume&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                    <span style="color: #ff0033; font-weight: bold;">set</span> this_disk <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>this_item <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><span style="color: #000000;">&#41;</span>
&nbsp;
                    <span style="color: #ff0033; font-weight: bold;">set</span> searchCmd <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;ls -d &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk <span style="color: #000000;">&amp;</span> secureName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;*&quot;</span>
                    <span style="color: #808080; font-style: italic;">(* check to see if a hidden secure image  is available *)</span>
                    <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
                    <span style="color: #ff0033; font-weight: bold;">try</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> searchCmd
                    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
                    <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>searchResult starts <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #009900;">&quot;/Volumes&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                        <span style="color: #808080; font-style: italic;">(* eject the volume *)</span>
                        <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;hdiutil detach &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk
                        <span style="color: #808080; font-style: italic;">(* eject this_disk *)</span>
                        delay <span style="color: #000000;">1</span>
                        display alert <span style="color: #009900;">&quot;It is now safe to remove the encrypted disk&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">return</span>
                    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> removing <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">from</span></pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2008/02/secure_scripts.tgz">Download all scripts</a><br />
<br />
Now whenever you plug in the thumb drive, this script will kick in and try to open the encrypted image which will in turn make the Finder ask you for a password. Additionally, when you un-mount the encrypted image, it will find the thumb drive and un-mount it as well. You should wait for the confirmation dialog saying it&#8217;s safe to remove the device before doing so, as ejecting the encrypted image is not the same as ejecting the drive, the folder action has to kick in and do that for you.<br />
<br />
There are a couple of issues with this. The first one, I haven&#8217;t been able to find a decent solution for. If after you plug in the memory stick and you&#8217;re asked for a password for the encrypted device, you either enter the wrong password three times or press &#8216;Cancel&#8217;, then the encrypted image will not mount, but the memory stick will remain mounted. To eject it, you will have to use Disk Utility or the Terminal. The second one, is reverting the memory stick to its proper state. To do that, I created another script which you can just run by itself, after plugging in the memory stick and pressing &#8216;Cancel&#8217; when asked for the encrypted image password (i.e. it uses the &#8216;bad&#8217; state described in the previous problem). When run, the script will find the memory stick that contains the encrypted image and ask if you wish to revert it. If you press &#8216;Yes&#8217;, it will then ask if you wish to preserve the secure image. Pressing &#8216;Yes&#8217; will move the secure image on your Desktop (under the name <code>secure.dmg</code>), otherwise it will just delete it from the drive. It will also restore the hidden status of the thumb drive and eject it, so the next time you plug it in it will behave normally:</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">(*
    Restore secure drive
    Part of 'Simulating encrypted physical disk in OS X' by Constantinos Neophytou
    http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/
&nbsp;
    Version 0.1.1
*)</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">property</span> secureName : <span style="color: #009900;">&quot;.secure&quot;</span>
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> volume_list <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">file</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">POSIX file</span> <span style="color: #009900;">&quot;/Volumes/&quot;</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> volume_list
            <span style="color: #ff0033; font-weight: bold;">set</span> this_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> original <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> volume_list
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #ff0033;">the</span> kind <span style="color: #ff0033; font-weight: bold;">of</span> this_item <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Volume&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> this_disk <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>this_item <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><span style="color: #000000;">&#41;</span>
&nbsp;
                <span style="color: #ff0033; font-weight: bold;">set</span> searchCmd <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;ls -d &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk <span style="color: #000000;">&amp;</span> secureName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;*&quot;</span>
                <span style="color: #808080; font-style: italic;">(* check to see if a hidden secure image  is available *)</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
                <span style="color: #ff0033; font-weight: bold;">try</span>
                    <span style="color: #ff0033; font-weight: bold;">set</span> searchResult <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do shell script</span> searchCmd
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
                <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>searchResult starts <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #009900;">&quot;/Volumes&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                    <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Restore secure disk &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;?&quot;</span> <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#91;</span><span style="color: #009900;">&quot;No&quot;</span>, <span style="color: #009900;">&quot;Yes&quot;</span><span style="color: #000000;">&#93;</span> default button <span style="color: #000000;">2</span>
                    <span style="color: #ff0033; font-weight: bold;">set</span> the_button <span style="color: #ff0033; font-weight: bold;">to</span> button returned <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">result</span>
                    <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>the_button <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Yes&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                        <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Preserve copy of secure data on Desktop?&quot;</span> <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#91;</span><span style="color: #009900;">&quot;No&quot;</span>, <span style="color: #009900;">&quot;Yes&quot;</span><span style="color: #000000;">&#93;</span> default button <span style="color: #000000;">2</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> the_button <span style="color: #ff0033; font-weight: bold;">to</span> button returned <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">result</span>
                        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>the_button <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Yes&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                            <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #ff0033; font-weight: bold;">timeout</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">600</span> seconds
                                <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;mv &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> searchResult <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; ~/Desktop/secure.dmg&quot;</span>
                            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">timeout</span>
                        <span style="color: #ff0033; font-weight: bold;">else</span>
                            <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;rm -f &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> searchResult
                        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                        <span style="color: #ff0033; font-weight: bold;">set</span> volumeName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">quoted form</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_disk
                        <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;chflags nohidden &quot;</span> <span style="color: #000000;">&amp;</span> volumeName
                        <span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;hdiutil detach &quot;</span> <span style="color: #000000;">&amp;</span> volumeName
                        delay <span style="color: #000000;">1</span>
                        display alert <span style="color: #009900;">&quot;Device restored. It is now safe to unplug the device.&quot;</span>
                        <span style="color: #ff0033; font-weight: bold;">return</span>
                    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
                <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span> error_message <span style="color: #0066ff;">number</span> error_number
        <span style="color: #0066ff;">display dialog</span> error_message <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;OK&quot;</span><span style="color: #000000;">&#125;</span> default button <span style="color: #000000;">1</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2008/02/secure_scripts.tgz">Download all scripts</a><br />
<br />
As always, these scripts are provided without any warranty, and any suggested improvements are more than welcome!]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/01/30/simulating-encrypted-physical-disk-in-os-x/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Spoofing Leopard&#8217;s MAC address</title>
		<link>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/</link>
		<comments>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 19:34:50 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[MAC Address]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/</guid>
		<description><![CDATA[There are many legitimate reasons why someone would want to spoof a system&#8217;s MAC address. In my case, my University binds our network ports to a specific computer&#8217;s MAC address, and only allows you to reset that address once a week. My problems start when I want to switch my two computers for whatever reason, [...]]]></description>
			<content:encoded><![CDATA[There are many legitimate reasons why someone would want to spoof a system&#8217;s MAC address. In my case, my University binds our network ports to a specific computer&#8217;s MAC address, and only allows you to reset that address once a week. My problems start when I want to switch my two computers for whatever reason, and connect my smaller iBook to the wall (let&#8217;s say I want to keep a web server online, but wish to take my MacBook Pro on the road).<br />
<span id="more-106"></span>
<br />
In Tiger, it was very easy to spoof a MAC address:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> en0 ether 00:00:00:00:00:00</pre></div></div>



<p>
where <code>en0</code> is the network interface you wish to change the MAC address of, and <code>00:00:00:00:00:00</code> is the target MAC address. With Leopard, that line no longer works. No matter how much I searched, I couldn&#8217;t find a solid alternative. Turns out, it&#8217;s extremely simple:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> en0 lladdr 00:00:00:00:00:00</pre></div></div>



<p>
That&#8217;s it!<br />
<strong>Note:</strong> This has been tested under 10.5.1 with both en0 and en1, and at least for the wired interface it works as advertised.]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>Bandwidth throttling in OS X</title>
		<link>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/</link>
		<comments>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 14:27:52 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/</guid>
		<description><![CDATA[It&#8217;s been a while since my last post, and that&#8217;s because I&#8217;ve been busy with coursework, so I haven&#8217;t had time to mess around with OS X. However there was one feature I needed to figure out out of necessity if anything else. I have certain files I wish to freely share with some friends [...]]]></description>
			<content:encoded><![CDATA[It&#8217;s been a while since my last post, and that&#8217;s because I&#8217;ve been busy with coursework, so I haven&#8217;t had time to mess around with OS X. However there was one feature I needed to figure out out of necessity if anything else. I have certain files I wish to freely share with some friends of mine, and the easiest way for me to do that was put them on my local web server and serve them over http. The only problem with this approach, is that the university has a weekly data transfer limit of 5Gb per week during peak hours, those being between 6pm and midnight. Additionally, local traffic doesn&#8217;t count towards that limit, and if that limit is exceeded then my Internet would be blocked and limited to only the local network for the remainder of that week.<br />
<br />
Therefore, the solution I was looking for would not require me to turn off my web server (as I&#8217;d like to still access it locally), and would ideally simply limit the outgoing traffic automatically between those two times.<br />
<span id="more-105"></span>
<br />
One aspect that made this particular solution usable, was the fact that port 80 is firewalled from the external world. This means that if I want to run a web server on my local machine accessible from the outside, I have to do it on a different port. Therefore I use port 80 to access the web server locally, and port 8080 to access it from the outside. This gives me a dedicated point of entry for the traffic that I wish to limit the bandwidth.<br />
<br />
The solution is fairly simple, and involves only two tools: <code>cron</code>, for enabling and disabling the filter at specific times, and <code>ipfw</code> for actually setting up the filters. The idea is this: create a <code>pipe</code> using <code>ipfw</code> that limits outgoing traffic on port 8080 to a specified rate (let&#8217;s say 15KByte/s), and using a cron job add the pipe to my network interface at 6pm, and delete it at midnight. That&#8217;s it! Theoretically you only have to create the pipe once, but in order to have this survive across restarts, I added another cron job at 5:59pm that re-creates the pipe. The full contents of the crontab file (located at <code>/etc/crontab</code>) are as follows:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Set the bandwidth limit at 5:59pm</span>
<span style="color: #000000;">59</span> <span style="color: #000000;">17</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw pipe <span style="color: #000000;">1</span> config bw 15KByte<span style="color: #000000; font-weight: bold;">/</span>s
<span style="color: #666666; font-style: italic;"># Add the bandwidth limit to the specified port at 6:00pm</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">18</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw add <span style="color: #000000;">1</span> pipe <span style="color: #000000;">1</span> src-port <span style="color: #000000;">8080</span>
<span style="color: #666666; font-style: italic;"># Lift the bandwidth limit at 12:00am</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw delete <span style="color: #000000;">1</span></pre></div></div>



<p>
The problem with this is if the computer boots up or reboots after 6pm and before midnight, the filters will not be set. The solution is to use <code>anacron</code> for executing the ipfw commands, But as I rarely shut down or reboot my computer, it wasn&#8217;t worth it for me to make that happen. If I do make those modifications, I will post an update here. Also note that the ipfw commands need to be executed as root.<br />]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically restart crashed applications</title>
		<link>http://www.cneophytou.com/2007/10/14/automatically-restart-crashed-applications/</link>
		<comments>http://www.cneophytou.com/2007/10/14/automatically-restart-crashed-applications/#comments</comments>
		<pubDate>Sun, 14 Oct 2007 21:31:07 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[CC Licence]]></category>
		<category><![CDATA[Folder Actions]]></category>
		<category><![CDATA[Quicksilver]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2007/10/15/automatically-restart-crashed-applications/</guid>
		<description><![CDATA[I love Quicksilver. If I ever sit on a machine without it, I feel handicapped, like something extremely important is missing. My major gripe with Quicksilver (and, this might just be my setup, I&#8217;m not sure), is that it likes to crash a lot. At least 2-3 times a week. And when it crashes, it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[I love Quicksilver. If I ever sit on a machine without it, I feel handicapped, like something extremely important is missing. My major gripe with Quicksilver (and, this might just be my setup, I&#8217;m not sure), is that it likes to crash a lot. At least 2-3 times a week. And when it crashes, it&#8217;s extremely annoying because when I need to start a program up I use, well, Quicksilver!<br />
<br />
<span class='update'>Updated 2008-01-11:</span> Modified script for Leopard. New script at end of post.<br />
<br />
<span id="more-103"></span>
I&#8217;ve found a couple of different methods for relaunching Quicksilver easily or automatically. One was to keep an alias to Quicksilver on the bottom-left part of your desktop with no icon, and named as &#8221; &#8221; (i.e. a space). So when Quicksilver is off and you want to start it, you cmd-tab to the Finder, hit space, and cmd-o. Quick, easy, does the job, but hardly clean (or nerdy!).<br />
<br />
The other approach which I loved was playing around with launchd (found on <a href='http://www.macworld.com/weblogs/macosxhints/2007/04/autorestart/index.php'>MacWorld</a> and <a href='http://www.macosxhints.com/article.php?story=20060927132601570'>macosxhints.com</a>). With this service we can monitor a file for modifications, and when the file is modified we can perform an action. In this case, we would monitor the file <code>/Users/username/Library/Logs/CrashReporter/Quicksilver.crash.log</code>, and once its modified, launch Quicksilver. Clean, fully automated, but hardly simple. To make the task easier, <a href='http://lingon.sourceforge.net/'>Lingon</a> can be used to deal with launchd. However, I was never able to make this to work, and I don&#8217;t have the patience to sit down and figure out what the problem is.<br />
<br />
I did like the idea of monitoring Quicksilver.crash.log since that&#8217;s a direct indication that the application has crashed, but other than launchd I&#8217;m not familiar with any other automated service that can monitor for modifications in a file. I am however familiar with an automated service that monitors for modifications in a folder, courtesy of OS X, and that&#8217;s folder actions.<br />
<br />
I can therefore build a folder action which will monitor  <code>/Users/username/Library/Logs/CrashReporter/</code> for changes, see what files were added, and if a &#8216;marked&#8217; file was added then relaunch the relevant application and (this part is critical) delete the crash log so the script can work again. It took a couple of tries, but I think I found the most robust solution for this approach.<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> restartLog : <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Quicksilver.crash.log&quot;</span><span style="color: #000000;">&#125;</span>
<span style="color: #ff0033; font-weight: bold;">property</span> restartID : <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;daed&quot;</span><span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span> this_folder <span style="color: #ff0033;">after</span> <span style="color: #0066ff;">receiving</span> these_items
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> these_items
        <span style="color: #ff0033; font-weight: bold;">set</span> fileAlias <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> these_items <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> fileInfo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">info for</span> fileAlias
        <span style="color: #ff0033; font-weight: bold;">set</span> fileName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> fileInfo <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">text</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> fileName <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033; font-weight: bold;">in</span> restartLog <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #0066ff;">beep</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> itm <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">my</span> list_position<span style="color: #000000;">&#40;</span>fileName, restartLog<span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
                <span style="color: #0066ff;">open</span> <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">file</span> <span style="color: #0066ff;">id</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">item</span> itm <span style="color: #ff0033; font-weight: bold;">of</span> restartID<span style="color: #000000;">&#41;</span>
                <span style="color: #0066ff;">delete</span> <span style="color: #0066ff;">item</span> fileAlias
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> list_position<span style="color: #000000;">&#40;</span>this_item, this_list<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> <span style="color: #0066ff;">count</span> <span style="color: #ff0033; font-weight: bold;">of</span> this_list
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> this_list <span style="color: #ff0033; font-weight: bold;">is</span> this_item <span style="color: #ff0033; font-weight: bold;">then</span> <span style="color: #ff0033; font-weight: bold;">return</span> i
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #ff0033; font-weight: bold;">end</span> list_position</pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2007/10/restartcrashedapp.scpt">Download this script</a><br />
<br />
Note that to get this to work initially, you&#8217;ll have to open that folder and delete the existing Quicksilver.crash.log, otherwise this folder action will never kick in for Quicksilver!<br />
<br />
The critical part are the two properties at the top. The first property contains the name of the file to watch for, and the second property contains (in the same order as in the first property) the application file id for the related application. The reason for using the application file id is that this will remain constant on every system even if the application is renamed by the user.<br />
<br />
This script can be expanded to listen for any number of applications simply by adding the two parameters for each application to these properties. To get the application file id of the application you wish to monitor, simply run this code once in Script Editor while the target application is running:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">return</span> creator type <span style="color: #ff0033; font-weight: bold;">of</span> process <span style="color: #009900;">&quot;Process Name&quot;</span></pre></div></div>



<p>
and watch the output.<br />
<br />
As a side note, with this method you can chose to do any number of things instead of just relaunching the crashed application since it&#8217;s straight forward applescript. In my version I chose to &#8216;beep&#8217; as well, to let me know something went wrong (and the file trash sound is also a giveaway), but you really could do anything you want here.<br />
<br />
<span class='update'>Leopard Update:</span><br />
<br />
There have been a few changes in the way Leopard handles the crash log files, which simplifies the use of this script. Instead of using a single crash log file for each application and appending to it, Leopard simply creates a new timestamped crash log in the form <code>Name_YYYY-MM-DD-TIME_Hostname.crash</code>. This is easier, because we no longer have to worry about deleting the crash log, we can simply check if the newly added log starts with *Name*. Therefore, a simpler version of the above applescript (that can only work with a single app, but switching to lists shouldn&#8217;t be too hard), follows:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> restartName : <span style="color: #009900;">&quot;Quicksilver&quot;</span>
<span style="color: #ff0033; font-weight: bold;">property</span> restartID : <span style="color: #009900;">&quot;daed&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span> this_folder <span style="color: #ff0033;">after</span> <span style="color: #0066ff;">receiving</span> these_items
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> i <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">in</span> these_items
        <span style="color: #ff0033; font-weight: bold;">set</span> fileAlias <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> i <span style="color: #ff0033; font-weight: bold;">of</span> these_items <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> fileInfo <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">info for</span> fileAlias
        <span style="color: #ff0033; font-weight: bold;">set</span> fileName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> fileInfo <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">text</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> fileName starts <span style="color: #ff0033; font-weight: bold;">with</span> restartName <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #0066ff;">beep</span>
            <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
                <span style="color: #0066ff;">open</span> <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">file</span> <span style="color: #0066ff;">id</span> restartID
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">adding</span> <span style="color: #0066ff;">folder</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">to</span></pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2007/10/restartcrashedapp_10.5.scpt">Download this script</a><br />
<br />
If anyone can figure out how to use applescript instead of the shell commands and still have it work, please let me know.]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2007/10/14/automatically-restart-crashed-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Searching Google the way you want</title>
		<link>http://www.cneophytou.com/2007/09/18/searching-google-the-way-you-want/</link>
		<comments>http://www.cneophytou.com/2007/09/18/searching-google-the-way-you-want/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 19:56:53 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2007/09/18/searching-google-the-way-you-want/</guid>
		<description><![CDATA[Google is awesome. I don&#8217;t even know where to start with all the features they&#8217;ve got packed in that tiny little searchbox of theirs. There&#8217;s a lot of sites that explain some of these advanced features [google.com], but I&#8217;m more interested in the ones I use regularly, or ones that make my search experience easier. [...]]]></description>
			<content:encoded><![CDATA[Google is awesome. I don&#8217;t even know where to start with all the features they&#8217;ve got packed in that tiny little searchbox of theirs. <a href='http://blogoscoped.com/archive/2005-09-29-n85.html'>There&#8217;s</a> a <a href='http://www.mapelli.info/tips/ultimate-google-search-tips-guide'>lot</a> of <a href='http://googlesystem.blogspot.com/2007/01/google-search-tips.html'>sites</a> that explain some of these advanced <a href='http://www.google.com/help/basics.html'>features</a> [google.com], but I&#8217;m more interested in the ones I use regularly, or ones that make my search experience easier.<br />
<br />
First, I&#8217;ll start with the <a href='http://www.google.com/experimental/index.html#BetaShortcuts'>Google by Keyboard</a> search. I first came across this in a <a href='http://lifehacker.com/software/firefox/install-the-google-by-keyboard-firefox-search-plugin-261569.php'>Lifehacker article</a>. I liked Google by Keyboard because it allowed me to use the same keyboard shortcuts that I use in <a href='http://www.google.com/reader/'>Google Reader</a> for my search results. The best part? The post included a link to an .xml file which would enable Firefox to have &#8216;Google by Keyboard&#8217; as one of the options in it&#8217;s search box!<br />
<span id="more-98"></span>
<br />
Unfortunately, the link on lifehacker no longer works, so here&#8217;s a link to <a href='http://www.cneophytou.com/wp-content/uploads/scripts/ffgooglekeyboard.xml'>my copy</a> of the .xml file. To install, simply download the .xml file, and save it in the <code>searchplugins</code> directory inside your Firefox profile directory, as per the lifehacker post instructions. To repeat:<br />
</p>
<blockquote>
<p>
On Windows, that path is C:\Program Files\Mozilla Firefox\searchplugins\<br />
On the Mac, go with ~/Library/Application Support/Firefox/profiles/yourprofilenamehere/searchplugins/
</p>
</blockquote>
<p>
and then simply restart Firefox. Now at the time, I was not using Firefox&#8217;s box to search, but instead Google&#8217;s toolbar. So I went ahead and created a custom .xml file to add the button to the Google toolbar. To install it, you can simply <a href='http://toolbar.google.com/buttons/add?url=http://www.cneophytou.com/wp-content/uploads/scripts/googlekeyboard.xml'>click on this link</a>.<br />
<br />
But that&#8217;s not all. There&#8217;s another search feature that I&#8217;ve learned to love, and use all the time, especially since I&#8217;ve started <a href='http://www.cneophytou.com/2007/07/24/itunes-scripts-i-cant-live-without/'>organizing my iTunes Library</a>. I&#8217;m talking about Google Music search, and like most &#8216;special&#8217; searches in Google it triggers automatically when it detects you&#8217;re searching for something music-related. I have not been able to find a &#8216;home page&#8217; for Google Music Search, which is a problem because most of my searches don&#8217;t get automatically recognized as a music search (for example I&#8217;ve recently been searching for the band called &#8216;<a href='http://www.google.com/musica?aid=t32ACWyHO6F'>Peaches</a>&#8216;&#8230; They&#8217;re pretty good btw. Obviously there&#8217;s no way searching for &#8216;peaches&#8217; on Google will ever trigger music search).<br />
<br />
Now what I would usually do is search for something like &#8216;Pixies&#8217; (as per the Music Search example), which would always bring up the Music search link, and proceed from there. But that&#8217;s two steps I&#8217;d love to completely eliminate. So, instead, I went ahead and modified the above .xml files to directly search Google Music. To use, you can either <a href='http://www.cneophytou.com/wp-content/uploads/scripts/ffgooglemusic.xml'>download</a> the firefox search plugin and follow the same directions as above, or if you&#8217;re using the Google toolbar, <a href='http://toolbar.google.com/buttons/add?url=http://www.cneophytou.com/wp-content/uploads/scripts/googlemusic.xml'>install the button</a>.<br />
<br />
I wonder if there&#8217;s an easy way of creating a script to automate this process for any arbitrary Google Search url&#8230; hmm&#8230;]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2007/09/18/searching-google-the-way-you-want/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iTunes scripts I can&#8217;t live without</title>
		<link>http://www.cneophytou.com/2007/07/24/itunes-scripts-i-cant-live-without/</link>
		<comments>http://www.cneophytou.com/2007/07/24/itunes-scripts-i-cant-live-without/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 18:04:22 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Quicksilver]]></category>
		<category><![CDATA[Shortcuts]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2007/07/24/itunes-scripts-i-cant-live-without/</guid>
		<description><![CDATA[I have few obsessions in my life, and one of those happens to be keeping my iTunes library in some form (and definition) of &#8216;order&#8217;, without having me go completely insane. This involves keeping the ID3 data as accurate as I can make it (very tedious process as I had about 100 songs named Track [...]]]></description>
			<content:encoded><![CDATA[I have few obsessions in my life, and one of those happens to be keeping my iTunes library in some form (and definition) of &#8216;order&#8217;, without having me go completely insane. This involves keeping the ID3 data as accurate as I can make it (very tedious process as I had about 100 songs named Track 3 &#8211; Unknown Artist), but that is more or less under control. What I&#8217;m working on now is rating all of my music (I&#8217;m sure every one has their own rating scheme, and there&#8217;s no need to share mine here&#8230; Just suffice to say that a 0-star rating means the song hasn&#8217;t been reviewed), and also getting as much album artwork to go with iTune&#8217;s cover flow so I can use it without looking at the same default image every time&#8230;<br />
<br />
Doing all this manually would pretty much take up all my time, so over a period of few months (back when I first started dealing with my iTunes library), I built a few applescripts which help me manage all these tasks, and which are bound to keyboard shortcuts in Quicksilver.<br />
<span id="more-96"></span>
</p>
<h1>Rating</h1>
<p>
I have all the standard 0-5 star rating scripts, which are bound to cmd-opt-0 through cmd-opt-5 respectively. Since I use Growl, I wanted a notification to come up for this fact, and use the album artwork (if any) as the notification icon. This is the script for the 5 star rating, where for every other (0-4 stars) script the only modification is the actual rating (commented in the script)<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> emdash : «data utxt2014» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> black_star : «data utxt272F» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> white_star : «data utxt2606» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> dot : «data utxt00B7» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">set</span> appName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
<span style="color: #ff0033; font-weight: bold;">set</span> app2Name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> appName<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> app2Name<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">then</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> class <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033; font-weight: bold;">in</span> <span style="color: #000000;">&#123;</span>track, <span style="color: #0066ff;">file</span> track, URL track, device track, shared track, audio CD<span style="color: #000000;">&#125;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #808080; font-style: italic;">(* Increments of 20, from 0 to 100 for 0 - 5 stars *)</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> rating <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">100</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">my</span> notifyTrack<span style="color: #000000;">&#40;</span>current track, player position, <span style="color: #009900;">&quot;5 Stars&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #808080; font-style: italic;">(* or whatever else you want *)</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> notifyTrack<span style="color: #000000;">&#40;</span>myTrack, pos, txt<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkArtist <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkAlbum <span style="color: #ff0033; font-weight: bold;">to</span> album <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkTime <span style="color: #ff0033; font-weight: bold;">to</span> time <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkRating <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>rating <span style="color: #ff0033; font-weight: bold;">of</span> myTrack<span style="color: #000000;">&#41;</span> <span style="color: #000000;">/</span> <span style="color: #000000;">20</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkPos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">my</span> getTimeString<span style="color: #000000;">&#40;</span>pos<span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> artworkCount <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">if</span> artworkCount &gt; <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">tell</span> myTrack
                <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>data <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> iTunesIcon <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:Applications:iTunes.app:Contents:Resources:iTunes.icns&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> read <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> iTunesIcon<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">as</span> picture
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>txt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> txt <span style="color: #ff0033; font-weight: bold;">to</span> trkName
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkAlbum
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkName <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkAlbum <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkInfo <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; (&quot;</span> <span style="color: #000000;">&amp;</span> trkAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;)&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">my</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> notifyTrack
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> trkRating <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> black_star
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">5</span> <span style="color: #000000;">-</span> trkRating<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> dot
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">return</span> stars
<span style="color: #ff0033; font-weight: bold;">end</span> showStars
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> allNotificationsList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Rating Change&quot;</span>, <span style="color: #009900;">&quot;Song Skipping&quot;</span>, <span style="color: #009900;">&quot;Song Info&quot;</span><span style="color: #000000;">&#125;</span>
        register <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">application</span> ¬
            <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> all notifications allNotificationsList default notifications allNotificationsList ¬
            icon <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkArt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">missing value</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Rating Change&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Rating Change&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> pictImage <span style="color: #ff0033;">the</span> trkArt
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showQSNotify
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showTrackInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlTunes&quot;</span>
            show current track
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showTrackInfo
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> getTimeString<span style="color: #000000;">&#40;</span>secs<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> secs <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">number</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_seconds <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes ≥ <span style="color: #000000;">60</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_hours <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>no_hours <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">return</span> minutes_text <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> seconds_text
<span style="color: #ff0033; font-weight: bold;">end</span> getTimeString</pre></div></div>



<p><a href="http://www.cneophytou.com/wp-content/uploads/2007/07/rating.scpt">Download this script</a></p>
<h1>Skipping</h1>
<p>
Sometimes, I find myself having a few hours of free time, where I want to just sit down and rate all my unrated songs. Instead of using the mouse to skip through every song (since I&#8217;ve already heard all of them, I just haven&#8217;t considered a rating for them), I have a script that skips a quarter of the song on each press, and places the playhead at 3 seconds from the end on the 4th activation. Useful for quickly skipping through a song.<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> emdash : «data utxt2014» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> black_star : «data utxt272F» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> white_star : «data utxt2606» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> dot : «data utxt00B7» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">set</span> appName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
<span style="color: #ff0033; font-weight: bold;">set</span> app2Name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> appName<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> app2Name<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">then</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> myTrack <span style="color: #ff0033; font-weight: bold;">to</span> current track
            <span style="color: #ff0033; font-weight: bold;">set</span> dur <span style="color: #ff0033; font-weight: bold;">to</span> duration <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
            <span style="color: #ff0033; font-weight: bold;">set</span> q1 <span style="color: #ff0033; font-weight: bold;">to</span> dur <span style="color: #000000;">/</span> <span style="color: #000000;">4</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> q2 <span style="color: #ff0033; font-weight: bold;">to</span> q1 <span style="color: #000000;">*</span> <span style="color: #000000;">2</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> q3 <span style="color: #ff0033; font-weight: bold;">to</span> q1 <span style="color: #000000;">*</span> <span style="color: #000000;">3</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> q4 <span style="color: #ff0033; font-weight: bold;">to</span> dur <span style="color: #000000;">-</span> <span style="color: #000000;">3</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> curPos <span style="color: #ff0033; font-weight: bold;">to</span> player position
            <span style="color: #ff0033; font-weight: bold;">set</span> counter <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">0</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> theList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span>q1, q2, q3, q4, dur<span style="color: #000000;">&#125;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> pos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">0</span>
            <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">while</span> pos <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">less</span> than <span style="color: #ff0033;">or</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> curPos
                <span style="color: #ff0033; font-weight: bold;">set</span> counter <span style="color: #ff0033; font-weight: bold;">to</span> counter <span style="color: #000000;">+</span> <span style="color: #000000;">1</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> pos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> counter <span style="color: #ff0033; font-weight: bold;">of</span> theList
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
            <span style="color: #ff0033; font-weight: bold;">if</span> pos <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">less</span> than <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">then</span> <span style="color: #ff0033; font-weight: bold;">set</span> pos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">1</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> player position <span style="color: #ff0033; font-weight: bold;">to</span> pos
&nbsp;
            <span style="color: #ff0033; font-weight: bold;">if</span> counter <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">greater</span> than <span style="color: #000000;">3</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">my</span> notifyTrack<span style="color: #000000;">&#40;</span>myTrack, player position, <span style="color: #009900;">&quot;Ending Song&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">else</span>
                <span style="color: #ff0033; font-weight: bold;">my</span> notifyTrack<span style="color: #000000;">&#40;</span>myTrack, player position, <span style="color: #009900;">&quot;Song Skip&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #808080; font-style: italic;">(* my showTrackInfo() *)</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> notifyTrack<span style="color: #000000;">&#40;</span>myTrack, pos, txt<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkArtist <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkAlbum <span style="color: #ff0033; font-weight: bold;">to</span> album <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkTime <span style="color: #ff0033; font-weight: bold;">to</span> time <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkRating <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>rating <span style="color: #ff0033; font-weight: bold;">of</span> myTrack<span style="color: #000000;">&#41;</span> <span style="color: #000000;">/</span> <span style="color: #000000;">20</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkPos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">my</span> getTimeString<span style="color: #000000;">&#40;</span>pos<span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> artworkCount <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">if</span> artworkCount &gt; <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">tell</span> myTrack
                <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>data <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> iTunesIcon <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:Applications:iTunes.app:Contents:Resources:iTunes.icns&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> read <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> iTunesIcon<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">as</span> picture
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>txt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> txt <span style="color: #ff0033; font-weight: bold;">to</span> trkName
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkAlbum
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkName <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkAlbum <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkInfo <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; (&quot;</span> <span style="color: #000000;">&amp;</span> trkAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;)&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">my</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> notifyTrack
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> trkRating <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> black_star
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">5</span> <span style="color: #000000;">-</span> trkRating<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> dot
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">return</span> stars
<span style="color: #ff0033; font-weight: bold;">end</span> showStars
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> allNotificationsList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Rating Change&quot;</span>, <span style="color: #009900;">&quot;Song Skipping&quot;</span>, <span style="color: #009900;">&quot;Song Info&quot;</span><span style="color: #000000;">&#125;</span>
        register <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">application</span> ¬
            <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> all notifications allNotificationsList default notifications allNotificationsList ¬
            icon <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkArt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">missing value</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Song Skipping&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Song Skipping&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> pictImage <span style="color: #ff0033;">the</span> trkArt
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showQSNotify
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showTrackInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlTunes&quot;</span>
            show current track
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showTrackInfo
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> getTimeString<span style="color: #000000;">&#40;</span>secs<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> secs <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">number</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_seconds <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes ≥ <span style="color: #000000;">60</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_hours <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>no_hours <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">return</span> minutes_text <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> seconds_text
<span style="color: #ff0033; font-weight: bold;">end</span> getTimeString</pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2007/07/skipping.scpt">Download this script</a><br />
<br />
This method works well with a couple of smart playlists and clever manipulation of the Party Shuffle feature. I have two smart playlists (one of them is used to filter out tv shows and movies, but not video clips). One is named &#8220;Other Video&#8221;, and has the following rules:</p>
<ul><li>Match <strong>any</strong> of the following:</li>
<li>Video kind is Movie</li>
<li>Video kind is TV Show</li>
</ul>
<p>
The other is named &#8220;All Unrated&#8221;, and has the following rules:<br /></p>
<ul>
<li>Match <strong>all</strong> of the following:</li>
<li>My rating is less than 1 star</li>
<li>Podcast is false</li>
<li>Playlist is not Other Video</li>
</ul>
<p>
Finally, in Party Shuffle, at the bottom, I have Source: &#8220;All Unrated&#8221;, Display 5 recently played songs, and 15 upcoming songs. This way, even though the song I just rate will be removed from the &#8220;All Unrated&#8221; smart playlist, it won&#8217;t stop playing as it&#8217;s in the Party Shuffle playlist.<br />
</p>
<h1>Artwork</h1>
<p>
I first ran &#8220;Get Album Artwork&#8221; in iTunes, but obviously that had a fairly limited success as a lot of my music has vital information like Album missing, and also a lot of the music I listen to isn&#8217;t even in the iTunes store. To cover the gap, I&#8217;m a fanatic <a href='http://growl.info/documentation/growltunes.php'>GrowlTunes</a> user, which does all the heavy work of fetching album covers (sometimes more successfully than others). GrowlTunes first looks for album artwork in the song itself, and if it doesn&#8217;t find any it then fetches it from the internet to display the Growl alert. What it does NOT do is save it with the song, but it DOES save it locally so it doesn&#8217;t have to fetch it again (in my opinion this is a very good thing as anything under a 95% success ratio you&#8217;ll want to review, and GrowlTunes is more like 70%). So what I&#8217;ve done is prepared a script that, for the current track, looks at the default GrowlTunes location, and if it finds an album cover it adds it to the song (to run it, you will need to replace your own short user name at the first line of the script):<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> myUserName : <span style="color: #009900;">&quot;Constantinos&quot;</span>
<span style="color: #ff0033; font-weight: bold;">property</span> appName : <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> appName
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">then</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">try</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> myTrack <span style="color: #ff0033; font-weight: bold;">to</span> current track
            <span style="color: #ff0033; font-weight: bold;">set</span> trackName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trackName <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trackName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Unknown Track&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trackArtist <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trackArtist <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trackArtist <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Unknown Artist&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trackAlbum <span style="color: #ff0033; font-weight: bold;">to</span> album <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trackAlbum <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trackAlbum <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Unknown Album&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">set</span> artworkFilename <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;/Users/&quot;</span> <span style="color: #000000;">&amp;</span> myUserName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/Library/Images/Music/&quot;</span> <span style="color: #000000;">&amp;</span> trackArtist <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trackAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/Tracks/&quot;</span> <span style="color: #000000;">&amp;</span> trackName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/Track.png&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> deleteFilename <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:Users:&quot;</span> <span style="color: #000000;">&amp;</span> myUserName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:Library:Images:Music:&quot;</span> <span style="color: #000000;">&amp;</span> trackArtist <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> trackAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:Tracks:&quot;</span> <span style="color: #000000;">&amp;</span> trackName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:Track.png&quot;</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">set</span> deleteCoverFilename <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:Users:&quot;</span> <span style="color: #000000;">&amp;</span> myUserName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:Library:Images:Music:&quot;</span> <span style="color: #000000;">&amp;</span> trackArtist <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> trackAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:Cover.png&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> albumCoverFilename <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;/Users/&quot;</span> <span style="color: #000000;">&amp;</span> myUserName <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/Library/Images/Music/&quot;</span> <span style="color: #000000;">&amp;</span> trackArtist <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trackAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/Cover.png&quot;</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">set</span> tempfile <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:tmp:temporary.pict&quot;</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Image Events&quot;</span>
        <span style="color: #808080; font-style: italic;">(* set artworkFile to (POSIX file artworkFilename)
        set myImage to open (artworkFile as alias) *)</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> myImage <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">open</span> artworkFilename
        <span style="color: #ff0033; font-weight: bold;">try</span>
            <span style="color: #0066ff;">save</span> myImage <span style="color: #ff0033;">as</span> PICT <span style="color: #ff0033; font-weight: bold;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> tempfile<span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
            <span style="color: #ff0033; font-weight: bold;">try</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> deleteFilename <span style="color: #ff0033; font-weight: bold;">to</span> deleteCoverFilename
                <span style="color: #ff0033; font-weight: bold;">set</span> myImage <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">open</span> albumCoverFilename
                <span style="color: #0066ff;">save</span> myImage <span style="color: #ff0033;">as</span> PICT <span style="color: #ff0033; font-weight: bold;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> tempfile<span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span>
                <span style="color: #ff0033; font-weight: bold;">return</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #0066ff;">close</span> myImage
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> myTrack <span style="color: #ff0033; font-weight: bold;">to</span> current track
        <span style="color: #ff0033; font-weight: bold;">set</span> artworkCount <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> myArt <span style="color: #ff0033; font-weight: bold;">to</span> read <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> tempfile<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">from</span> <span style="color: #000000;">513</span> <span style="color: #ff0033;">as</span> picture
        <span style="color: #ff0033; font-weight: bold;">if</span> artworkCount &gt; <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> data <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #000000;">&#40;</span>artworkCount <span style="color: #000000;">+</span> <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">to</span> myArt
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> data <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> current track <span style="color: #ff0033; font-weight: bold;">to</span> myArt
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Image Events&quot;</span>
        <span style="color: #0066ff;">delete</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> tempfile<span style="color: #000000;">&#41;</span>
        <span style="color: #0066ff;">delete</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> deleteFilename<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span></pre></div></div>



<p><a href="http://www.cneophytou.com/wp-content/uploads/2007/07/artwork.scpt">Download this script</a></p>
<h1>Notifications</h1>
<p>
The first two scripts use the same &#8220;Hotkey iTunes Notification&#8221; application name to register with Growl, with three types of notification: &#8220;Rating Change&#8221;, &#8220;Song Skipping&#8221; and &#8220;Song Info&#8221;. The last one simply brings up a detailed notification dialog with the current song&#8217;s playhead position, title, artist, rating, album and album art, which can all fit in the small &#8220;Smoke&#8221; style notification window. If you&#8217;re interested in that, the script follows:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">property</span> emdash : «data utxt2014» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> black_star : «data utxt272F» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> white_star : «data utxt2606» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
<span style="color: #ff0033; font-weight: bold;">property</span> dot : «data utxt00B7» <span style="color: #ff0033;">as</span> Unicode <span style="color: #0066ff;">text</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">set</span> appName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
<span style="color: #ff0033; font-weight: bold;">set</span> app2Name <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;System Events&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> appName<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> processes <span style="color: #ff0033;">contains</span> app2Name<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">if</span> appIsRunning <span style="color: #ff0033; font-weight: bold;">then</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">my</span> notifyTrack<span style="color: #000000;">&#40;</span>current track, player position, <span style="color: #0066ff;">false</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> notifyTrack<span style="color: #000000;">&#40;</span>myTrack, pos, txt<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkName <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkArtist <span style="color: #ff0033; font-weight: bold;">to</span> artist <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkAlbum <span style="color: #ff0033; font-weight: bold;">to</span> album <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkTime <span style="color: #ff0033; font-weight: bold;">to</span> time <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">set</span> trkRating <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>rating <span style="color: #ff0033; font-weight: bold;">of</span> myTrack<span style="color: #000000;">&#41;</span> <span style="color: #000000;">/</span> <span style="color: #000000;">20</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> trkPos <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">my</span> getTimeString<span style="color: #000000;">&#40;</span>pos<span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> artworkCount <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">count</span> <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #ff0033; font-weight: bold;">of</span> myTrack
        <span style="color: #ff0033; font-weight: bold;">if</span> artworkCount &gt; <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">tell</span> myTrack
                <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>data <span style="color: #ff0033; font-weight: bold;">of</span> artwork <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> iTunesIcon <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Macintosh HD:Applications:iTunes.app:Contents:Resources:iTunes.icns&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkArt <span style="color: #ff0033; font-weight: bold;">to</span> read <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">file</span> iTunesIcon<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">as</span> picture
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>txt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">false</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> txt <span style="color: #ff0033; font-weight: bold;">to</span> trkName
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkAlbum
        <span style="color: #ff0033; font-weight: bold;">else</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkName <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkPos <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span> <span style="color: #000000;">&amp;</span> trkTime <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> emdash <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> trkArtist
            <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkAlbum <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
                <span style="color: #ff0033; font-weight: bold;">set</span> trkInfo <span style="color: #ff0033; font-weight: bold;">to</span> trkInfo <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; (&quot;</span> <span style="color: #000000;">&amp;</span> trkAlbum <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;)&quot;</span>
            <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">my</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
<span style="color: #ff0033; font-weight: bold;">end</span> notifyTrack
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showStars<span style="color: #000000;">&#40;</span>trkRating<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> trkRating <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> black_star
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">5</span> <span style="color: #000000;">-</span> trkRating<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">times</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> stars <span style="color: #ff0033; font-weight: bold;">to</span> stars <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot; &quot;</span> <span style="color: #000000;">&amp;</span> dot
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span>
    <span style="color: #ff0033; font-weight: bold;">return</span> stars
<span style="color: #ff0033; font-weight: bold;">end</span> showStars
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showQSNotify<span style="color: #000000;">&#40;</span>txt, trkArt, trkInfo<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> allNotificationsList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Rating Change&quot;</span>, <span style="color: #009900;">&quot;Song Skipping&quot;</span>, <span style="color: #009900;">&quot;Song Info&quot;</span><span style="color: #000000;">&#125;</span>
        register <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">application</span> ¬
            <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> all notifications allNotificationsList default notifications allNotificationsList ¬
            icon <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span>
&nbsp;
        <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>trkArt <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">equal</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">missing value</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Song Info&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span>
        <span style="color: #ff0033; font-weight: bold;">else</span>
            notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Song Info&quot;</span> title txt description trkInfo <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> <span style="color: #009900;">&quot;Hotkey iTunes Notification&quot;</span> pictImage <span style="color: #ff0033;">the</span> trkArt
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showQSNotify
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> showTrackInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">try</span>
        <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlTunes&quot;</span>
            show current track
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span>
<span style="color: #ff0033; font-weight: bold;">end</span> showTrackInfo
&nbsp;
<span style="color: #ff0033; font-weight: bold;">on</span> getTimeString<span style="color: #000000;">&#40;</span>secs<span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> secs <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">number</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">set</span> no_seconds <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_seconds <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> seconds_text <span style="color: #ff0033; font-weight: bold;">to</span> no_seconds <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
    <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes ≥ <span style="color: #000000;">60</span> <span style="color: #ff0033; font-weight: bold;">then</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_hours <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">div</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">mod</span> <span style="color: #000000;">60</span>
        <span style="color: #ff0033; font-weight: bold;">if</span> no_minutes <span style="color: #000000;">&lt;</span> <span style="color: #000000;">10</span> <span style="color: #ff0033; font-weight: bold;">then</span>
            <span style="color: #ff0033; font-weight: bold;">set</span> no_minutes <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;0&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
        <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span>no_hours <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span>
    <span style="color: #ff0033; font-weight: bold;">else</span>
        <span style="color: #ff0033; font-weight: bold;">set</span> minutes_text <span style="color: #ff0033; font-weight: bold;">to</span> no_minutes <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span>
    <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
&nbsp;
    <span style="color: #ff0033; font-weight: bold;">return</span> minutes_text <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;:&quot;</span> <span style="color: #000000;">&amp;</span> seconds_text
<span style="color: #ff0033; font-weight: bold;">end</span> getTimeString</pre></div></div>



<p>
<a href="http://www.cneophytou.com/wp-content/uploads/2007/07/notifications.scpt">Download this script</a><br />
<br />
That&#8217;s pretty much it&#8230; Enjoy!]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2007/07/24/itunes-scripts-i-cant-live-without/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Share Windows XP license between Parallels and Boot Camp</title>
		<link>http://www.cneophytou.com/2007/07/18/share-windows-xp-license-between-parallels-and-boot-camp/</link>
		<comments>http://www.cneophytou.com/2007/07/18/share-windows-xp-license-between-parallels-and-boot-camp/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 19:46:40 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[OS X]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Boot Camp]]></category>
		<category><![CDATA[Parallels]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2007/07/18/share-windows-xp-license-in-parallels-and-boot-camp/</guid>
		<description><![CDATA[Since my first installation of Boot Camp and Parallels, I&#8217;ve kept two separate Windows XP installations on my drive. One on Boot Camp, used for gaming and other resource-intensive tasks, and the other exclusively on Parallels, used for running some random software I come across and also to test the websites I build in IE. [...]]]></description>
			<content:encoded><![CDATA[Since my first installation of <a href='http://www.apple.com/bootcamp/'>Boot Camp</a> and <a href='http://www.parallels.com/'>Parallels</a>, I&#8217;ve kept two separate Windows XP installations on my drive. One on Boot Camp, used for gaming and other resource-intensive tasks, and the other exclusively on Parallels, used for running some random software I come across and also to test the websites I build in IE. The reason I&#8217;ve been doing this is because even though Parallels touts being able to <a href='http://lifehacker.com/software/geek-to-live/virtualize-and-dual+boot-the-same-windows-on-your-mac-267905.php'>run a boot camped windows installation</a> [via <a href='http://www.lifehacker.com'>lifehacker</a>], you can&#8217;t do BOTH (at least not off the shelf). You have a Boot Camp installation that you either run through Parallels, or by itself. The reason for this is that Parallels has to create a new hardware profile which XP picks up as a different machine, and invalidates your installation.<br />
<br />
<span id="more-95"></span>
No matter how much I searched I couldn&#8217;t find a way to use the same installation under both circumstances. Thus, when Parallels 3 came out I immediately paid for the upgrade (even before the release) for the much promised &#8217;3D&#8217; support, which, I believed, would enable me to play at least some of my games under Parallels, thus relatively eliminating the need to boot into XP. Alas, as most others, I was frustrated to find out that Parallels&#8217; so-called 3D support was actually marginal support for DirectX 8.1, and absolutely NO support for DX9 or greater.<br />
<br />
After all but giving up hope, I came across <a href='http://lifehacker.com/software/geek-to-live/virtualize-and-dual+boot-the-same-windows-on-your-mac-267905.php#c1816617'>this comment</a> on the afore-mentioned lifehacker post, which pointed me to a <a href='http://forum.parallels.com/showthread.php?t=13394'>Parallels&#8217; forum thread</a>. To cut a long story short, I am now able to boot the same Boot Camp installation of XP both directly AND via Parallels without having WGA complain and invalidate my copy!<br />
<br />
The process (reiterated from the above thread), is very simple:<br />
</p>
<ol>
<li>Find the MAC address of your Apples&#8217;s &#8220;en0&#8243; adaptor. To do that, either:<ul><li>Open Terminal.app and type <code>ifconfig en0</code>, the MAC address should be located on the line that says &#8220;ether 00:00:00:00:00:00&#8243;, where &#8217;00:00:00:00:00:00&#8242; would be the code you&#8217;re looking for</li><li>OR open &#8220;System Preferences&#8221;, click on the &#8220;Network&#8221; icon, from the &#8220;show&#8221; drop down select &#8220;Built-in Ethernet&#8221;, click the &#8220;Ethernet&#8221; tab, and the MAC address should be listed under &#8216;Ethernet ID:&#8217;</li></ul></li>
<li>Start up Parallels and select your Boot Camp installation (do NOT start the virtual machine)</li>
<li>Go to &#8220;Edit&#8221;/&#8221;Virtual Machine&#8221;</li>
<li>Select &#8220;Network Adapter 1&#8243; on the left, and the &#8220;Advanced&#8221; tab on the right</li>
<li>In the &#8220;MAC address&#8221; field replace the entry with the MAC address of en0 which you lifted above, minus the colons.</li>
</ol>
<p>
<br />
That&#8217;s it! No more complaining by that damned WGA <img src='http://www.cneophytou.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2007/07/18/share-windows-xp-license-between-parallels-and-boot-camp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

