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

<channel>
	<title>Dae’s blog &#187; Programming</title>
	<atom:link href="http://dae.cyberic.eu/blog/categories/technical/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://dae.cyberic.eu</link>
	<description></description>
	<lastBuildDate>Sun, 11 Jul 2010 16:03:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>AppleScript to mount/unmount a drive</title>
		<link>http://dae.cyberic.eu/blog/applescript-to-mount-unmount-a-drive/</link>
		<comments>http://dae.cyberic.eu/blog/applescript-to-mount-unmount-a-drive/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 17:50:52 +0000</pubDate>
		<dc:creator>Dae</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[mac pro]]></category>

		<guid isPermaLink="false">http://dae.cyberic.eu/?p=512</guid>
		<description><![CDATA[On my Mac Pro I have two internal hard drives I rarely use. Some times they &#8220;sleep&#8221; and while doing so, every file opening dialog, search in Spotlight or search in Dictionary might wake them up and that takes some &#8230; <a href="http://dae.cyberic.eu/blog/applescript-to-mount-unmount-a-drive/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On my Mac Pro I have two internal hard drives I rarely use. Some times they &#8220;sleep&#8221; and while doing so, every file opening dialog, search in Spotlight or search in Dictionary might wake them up and that takes some time. I could, of course, disable sleeping in power settings, but then the drives would be unreasonably wasting power all the time, so I decided to write an <strong>AppleScript to mount or unmount a drive</strong> depending on it&#8217;s state.<br />
<span id="more-512"></span><br />
<strong>I&#8217;d like to emphasize: this script is meant to unmount an entire drive rather than just a volume. </strong><strong>It takes a volume as an identifier of the needed drive. </strong>This is mostly useful for Mac Pros.</p>
<p>I will make a proper release of the script some time, now you can have a half-baked source code. The script requires Growl to be installed in the system. Tested only on Mac OS X 10.6 &#8220;Snow Leopard&#8221;. Please use at your own risk!</p>
<p>Change <code>myVolumeLabel</code> variable to the label of any volume on the drive you want to (un)mount.</p>
<pre><code>set myVolumeLabel to "Storage HD"

tell application "GrowlHelperApp"
	set the allNotificationsList to {"Disk mounted", "Disk unmounted"}

	register as application "Disk Mounter" all notifications allNotificationsList default notifications allNotificationsList icon of application "Disk Utility.app"
end tell

tell application "Finder"
	set diskDev to do shell script "diskutil list | grep \"" &amp; myVolumeLabel &amp; "\" | grep -o 'disk[1-9]*' "
	if not (disk myVolumeLabel exists) then
		do shell script "diskutil mountDisk " &amp; diskDev
		tell application "GrowlHelperApp" to notify with name "Disk mounted" title "Volume mounted" description "Disk “" &amp; diskDev &amp; "” with volume “" &amp; myVolumeLabel &amp; "” has been successfully mounted." application name "Disk Mounter" icon of application "Disk Utility.app"
	else
		do shell script "diskutil unmountDisk " &amp; diskDev
		tell application "GrowlHelperApp" to notify with name "Disk unmounted" title "Disk unmounted" description "Disk “" &amp; diskDev &amp; "” with volume “" &amp; myVolumeLabel &amp; "” has been successfully unmounted." application name "Disk Mounter" icon of application "Disk Utility.app"
	end if
end tell</code></pre>
<p><strong>Last updated:</strong> 30.05.10</p>
<p><span style="color: #ff0000;"><strong>Update:</strong></span> please note that unmounting an internal HDD screws up some links, for instance, if you had shared folders — they will not be shared after re-mounting the drive. Use the script only with the drives that you never/link use at all in Mac OS — in my case, this applies to the Bootcamp drive.</p>
]]></content:encoded>
			<wfw:commentRss>http://dae.cyberic.eu/blog/applescript-to-mount-unmount-a-drive/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Permission error of AppleScript in iTunes</title>
		<link>http://dae.cyberic.eu/blog/permission-error-of-applescript-in-itunes/</link>
		<comments>http://dae.cyberic.eu/blog/permission-error-of-applescript-in-itunes/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 16:19:16 +0000</pubDate>
		<dc:creator>Dae</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[mac software]]></category>

		<guid isPermaLink="false">http://dae.cyberic.eu/?p=470</guid>
		<description><![CDATA[I was getting a permission error (code -54) when trying to set an id3 tag of a track using AppleScript. The solution was to add a delay between each operation: delay 1 Note that the track will remain &#8220;locked&#8221; until &#8230; <a href="http://dae.cyberic.eu/blog/permission-error-of-applescript-in-itunes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was getting a permission error (code -54) when trying to set an id3 tag of a  track using AppleScript. The solution was to add a delay between each  operation: <code>delay 1</code></p>
<p><strong>Note</strong> that the track will remain &#8220;locked&#8221; until you restart iTunes.</p>
]]></content:encoded>
			<wfw:commentRss>http://dae.cyberic.eu/blog/permission-error-of-applescript-in-itunes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launch character palette using AppleScript in Snow Leopard</title>
		<link>http://dae.cyberic.eu/blog/launch-character-palette-using-applescript-in-snow-leopard/</link>
		<comments>http://dae.cyberic.eu/blog/launch-character-palette-using-applescript-in-snow-leopard/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 21:47:03 +0000</pubDate>
		<dc:creator>Dae</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[applescript]]></category>

		<guid isPermaLink="false">http://dae.cyberic.eu/?p=57</guid>
		<description><![CDATA[tell application "CharacterPalette" to activate There is an issue though: the new character palette doesn&#8217;t get &#8220;bound&#8221; to any of the applications, therefore double-clicking a symbol doesn&#8217;t paste it automatically to the text field. You&#8217;d have to drag-and-drop. I&#8217;m posting &#8230; <a href="http://dae.cyberic.eu/blog/launch-character-palette-using-applescript-in-snow-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<pre><code>tell application "CharacterPalette" to activate</code></pre>
<p>There is an issue though: the new character palette doesn&#8217;t get &#8220;bound&#8221; to any of the applications, therefore double-clicking a symbol doesn&#8217;t paste it automatically to the text field. You&#8217;d have to drag-and-drop. </p>
<p>I&#8217;m posting this because most results from Google were telling me to launch a &#8220;.component&#8221;, and that &#8220;.component&#8221; doesn&#8217;t exist on my Snow Leopard system.</p>
]]></content:encoded>
			<wfw:commentRss>http://dae.cyberic.eu/blog/launch-character-palette-using-applescript-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restrict page access to authorized MODx managers only</title>
		<link>http://dae.cyberic.eu/blog/restrict-page-access-to-authorized-modx-managers-only/</link>
		<comments>http://dae.cyberic.eu/blog/restrict-page-access-to-authorized-modx-managers-only/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 17:50:57 +0000</pubDate>
		<dc:creator>Dae</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Releases]]></category>
		<category><![CDATA[modx]]></category>

		<guid isPermaLink="false">http://dae.cyberic.eu/?p=27</guid>
		<description><![CDATA[A while ago I needed to create a private zone with documentation, accessible only by the MODx managers. In order to restrict access I wrote a simple snippet, which you can now use as well. Snippet name: ManagersOnly Description: Restrict &#8230; <a href="http://dae.cyberic.eu/blog/restrict-page-access-to-authorized-modx-managers-only/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while ago I needed to create a private zone with documentation, accessible only by the MODx managers. In order to restrict access I wrote a simple snippet, which you can now use as well.<br />
<span id="more-27"></span><br />
<strong>Snippet name:</strong> ManagersOnly<br />
<strong>Description:</strong> Restrict access to managers only.</p>
<pre><code>if (!isset($_SESSION['mgrValidated']))
{
	header('Location: '.$modx->makeUrl($modx->config['unauthorized_page']));
	exit;
}
else
{
	$modx->setPlaceholder('manager_name', $_SESSION['mgrShortname']);
}</code></pre>
<p><strong>Usage:</strong> add <code>[[ManagersOnly]]</code> in the beginning of the page or in a template. In case the visitor is authorized as a manager, the snippet will also return the placeholder <code>[+manager_name+]</code> (MODx manager&#8217;s “short name”), so you can greet them. Please note that the placeholder will not work correctly with cached pages.</p>
]]></content:encoded>
			<wfw:commentRss>http://dae.cyberic.eu/blog/restrict-page-access-to-authorized-modx-managers-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add an &lt;option&gt; to a &lt;select&gt; using Mootools</title>
		<link>http://dae.cyberic.eu/blog/add-an-option-to-a-select-using-mootools/</link>
		<comments>http://dae.cyberic.eu/blog/add-an-option-to-a-select-using-mootools/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 17:42:46 +0000</pubDate>
		<dc:creator>Dae</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://dae.cyberic.eu/?p=19</guid>
		<description><![CDATA[var newoption = new Option("option html", "option value"); try { $('myselect').add(newoption, null); } catch (err) { $('myselect').add(newoption); } To select the newly created option: newoption.setProperty('selected', 'selected');]]></description>
			<content:encoded><![CDATA[<pre>
<code>var newoption = new Option("option html", "option value");
try
{
	$('myselect').add(newoption, null);
}
catch (err)
{
	$('myselect').add(newoption);
}</code>
</pre>
<p>To select the newly created option:</p>
<pre><code>newoption.setProperty('selected', 'selected');</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://dae.cyberic.eu/blog/add-an-option-to-a-select-using-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
