<?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>Surgical Diversions &#187; code</title>
	<atom:link href="http://thefragens.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://thefragens.com/blog</link>
	<description>My time out of the operating room.</description>
	<lastBuildDate>Mon, 01 Mar 2010 05:21:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fail2ban on Leopard Server</title>
		<link>http://thefragens.com/blog/2009/09/fail2ban-on-leopard-server/</link>
		<comments>http://thefragens.com/blog/2009/09/fail2ban-on-leopard-server/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 23:52:25 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[osx-server]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=630</guid>
		<description><![CDATA[So here I am running my own server &#8212; for almost 2 years now. It&#8217;s been a real learning experience and I&#8217;ve tried to share. My latest add-on has been fail2ban. I got tired of looking into my logs and seeing where script kiddies or bots were trying to take control of my server. Fortunately, [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2008/06/forwarding-email-in-leopard-server-part-2/' rel='bookmark' title='Permanent Link: Forwarding Email in Leopard Server, part 2'>Forwarding Email in Leopard Server, part 2</a> <small>I&#8217;ve previously written about problems with Leopard server and forwarding...</small></li>
<li><a href='http://thefragens.com/blog/2008/02/forwarding-email-in-leopard-server/' rel='bookmark' title='Permanent Link: Forwarding Email in Leopard Server'>Forwarding Email in Leopard Server</a> <small>OK, to put it mildly the Workgroup Manager and Email...</small></li>
<li><a href='http://thefragens.com/blog/2007/12/leopard-server-dhcp-nat/' rel='bookmark' title='Permanent Link: Leopard Server DHCP-NAT'>Leopard Server DHCP-NAT</a> <small>Well, I&#8217;m finally getting most of the initial stuff for...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>So here I am running my own server &#8212; for almost 2 years now. It&#8217;s been a real learning experience and I&#8217;ve tried to share. My latest add-on has been <a href="http://www.fail2ban.org/wiki/index.php/Main_Page" onclick="urchinTracker('/outgoing/www.fail2ban.org/wiki/index.php/Main_Page?referer=');">fail2ban</a>. I got tired of looking into my logs and seeing where script kiddies or bots were trying to take control of my server. Fortunately, none have.</p>

<p>After a bit of googling, I found fail2ban. It&#8217;s a collection of python scripts.</p>

<p>&gt; Fail2ban scans log files like /var/log/pwdfail or /var/log/apache/error_log and bans IP that makes too many password failures. It updates firewall rules to reject the IP address.</p>

<p>There are a few tricks I&#8217;ve discovered along the way to make it work on my installation and likely on Mac OS X Server in general.</p>

<p>First is that fail2ban creates a PID and socket file in a directory that it fails to create. Yeah, that&#8217;s a <a href="https://sourceforge.net/tracker/?func=detail&amp;aid=2013282&amp;group_id=121032&amp;atid=689044" onclick="urchinTracker('/outgoing/sourceforge.net/tracker/?func=detail_amp_aid=2013282_amp_group_id=121032_amp_atid=689044&amp;referer=');">bug</a>. Since I didn&#8217;t want to mess around with the actual scripts in the program, I created a plist that issues the <code>mkdir /var/run/fail2ban</code> command. I placed this in /System/Library/LaunchDaemons and set it to Run at Load. <a href="https://sourceforge.net/projects/lingon/files/" onclick="urchinTracker('/outgoing/sourceforge.net/projects/lingon/files/?referer=');">Lingon</a> is your friend, but&#8217;s now inactive. <img src='http://thefragens.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>

<p>After creating the file you have to use the command line to move it to the /System/Library/LaunchDaemons directory. I also created another launchd plist to reload fail2ban every day. I did this because I run multiple virtual websites and the error logs for those sites get rotated and the names have some time code or something tacked on the end of the filename.</p>

<p>OK, problem 1 solved. Next I discovered that since fail2ban is really running on a multitude of linux boxes all the different methods of IP tracking, sorting etc. were really useless on my OS X Server. I run ipfw firewall and fortunately there&#8217;s a module for that in fail2ban. Unfortunately it&#8217;s not quite set up correctly, at least it wasn&#8217;t for me. I had to tweak it a bit.</p>

<p>What this means is that your <code>action</code> is always going to be <code>ipfw</code>. I tweaked the <code>ipfw.conf</code> file a bit. Now it does the following.</p>

<ol>
<li>Logs it&#8217;s action to ipfw.log</li>
<li>Adds a rulenum to the ipfw command. I did this because some other rule in my setup was allowing the IP before my deny could take effect. By lowering the rulenum my deny now fires off first.</li>
<li>Abstracted the protocol (tcp, udp) to pass as a variable. Just in case something you want to block isn&#8217;t <code>tcp</code>.</li>
</ol>

<p>I also created another filter as I found many times some machine would excessively hit my Apache server looking for nonexistent files. Since it sounds like something a bot would do I decided to ban it. This was the simple creation of a new filter.</p>

<p>I created a <code>jail.local</code> file to hold all my prefs and through trial and error discovered that the examples of how to <code>call</code> for a jail weren&#8217;t working for me. Perhaps I just didn&#8217;t understand the examples. I soon discovered that parameters for the <code>jail action</code> needed to be passed inside of square brackets in the prefs.</p>

<p>I&#8217;m sure, if you&#8217;ve gotten this far that you&#8217;re either very confused by this whole post or that you&#8217;ve had an epiphany. To further the epiphany along <a href="http://thefragens.com/pub/fail2ban-osx.zip">I&#8217;ve uploaded my file changes</a>.</p>

<p>You should be able to figure out what file goes where from the folder structure of the upload.</p>

<p>A couple of things in summary to remember. First, turn on your server&#8217;s firewall. Then make sure you change your server&#8217;s local IP address in the files to match your own. That&#8217;s the setting for <code>localhost</code>.</p>

<p>Good luck. If you have any questions leave a comment.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2008/06/forwarding-email-in-leopard-server-part-2/' rel='bookmark' title='Permanent Link: Forwarding Email in Leopard Server, part 2'>Forwarding Email in Leopard Server, part 2</a> <small>I&#8217;ve previously written about problems with Leopard server and forwarding...</small></li>
<li><a href='http://thefragens.com/blog/2008/02/forwarding-email-in-leopard-server/' rel='bookmark' title='Permanent Link: Forwarding Email in Leopard Server'>Forwarding Email in Leopard Server</a> <small>OK, to put it mildly the Workgroup Manager and Email...</small></li>
<li><a href='http://thefragens.com/blog/2007/12/leopard-server-dhcp-nat/' rel='bookmark' title='Permanent Link: Leopard Server DHCP-NAT'>Leopard Server DHCP-NAT</a> <small>Well, I&#8217;m finally getting most of the initial stuff for...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2009/09/fail2ban-on-leopard-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VoodooPad Pro Blogging</title>
		<link>http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/</link>
		<comments>http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/#comments</comments>
		<pubDate>Thu, 07 May 2009 21:54:59 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=619</guid>
		<description><![CDATA[It&#8217;s time to package up all my VoodooPad Pro blogging scripts and assorted web export plugins so that I can


Remember what the heck I was thinking.
Remember what all these pieces were supposed to accomplish as a whole.
Provide some sort of reference to others interested in this stuff.


Concept: To use VoodooPad Pro as a CMS for [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2006/11/voodoopad-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Blogging'>VoodooPad Blogging</a> <small>Well, it&#8217;s not really VoodooPad blogging but it&#8217;s pretty close....</small></li>
<li><a href='http://thefragens.com/blog/2006/11/voodoopad-automation/' rel='bookmark' title='Permanent Link: VoodooPad Automation'>VoodooPad Automation</a> <small>I&#8217;ve finally gotten it working. I&#8217;ve now got a Ruby...</small></li>
<li><a href='http://thefragens.com/blog/2006/09/voodoopad-goodness/' rel='bookmark' title='Permanent Link: VoodooPad goodness'>VoodooPad goodness</a> <small>Thanks to Gus Mueller for loads of help adapting a...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time to package up all my <a href="http://flyingmeat.com/voodoopad/voodoopadpro.html" onclick="urchinTracker('/outgoing/flyingmeat.com/voodoopad/voodoopadpro.html?referer=');">VoodooPad Pro</a> blogging scripts and assorted web export plugins so that I can</p>

<ol>
<li>Remember what the heck I was thinking.</li>
<li>Remember what all these pieces were supposed to accomplish as a whole.</li>
<li>Provide some sort of reference to others interested in this stuff.</li>
</ol>

<p><strong>Concept:</strong> To use VoodooPad Pro as a CMS for a web site, allowing for static sites and inclusion of blog-style concatenated page. The blog-style page was originally intended as a &#8220;News&#8221; page of a static business site. SEO optimization necessitating the addition of a page with re-newing content. <em>Google likes it more.</em></p>

<p>Disclaimer: I like <a href="http://daringfireball.net/projects/markdown/" onclick="urchinTracker('/outgoing/daringfireball.net/projects/markdown/?referer=');">Markdown</a> and built these scripts around the fact that the VPP document is essentially always formatted in plain text. Images need to be added using links.</p>

<p>I will include a <a href="http://thefragens.com/pub/sample-project.zip">sample package</a> that contains a VPP document, a web export plugin and several script plugins. The site the sample is based upon is at <a href="http://losrobleshoa.org" onclick="urchinTracker('/outgoing/losrobleshoa.org?referer=');">http://losrobleshoa.org</a>.</p>

<p>VoodooPad Pro is a requirement as the meta data and triggers are necessary in the creation of the files. My workflow is as follows.</p>

<ol>
<li>Create new page/post.</li>
<li>Run script plugin <code>Blog &amp;gt; Meta Markup - HomepageMeta</code> on new page.</li>
<li>Run script plugin <code>Blog &amp;gt; Make Homepage and Feed</code></li>
<li>Run web export.</li>
<li>FTP files up to site. I use <a href="http://www.panic.com/transmit/" onclick="urchinTracker('/outgoing/www.panic.com/transmit/?referer=');">Transmit</a>. It&#8217;s also a great app.</li>
</ol>

<p>The script will move all the created files into a folder structure so that the file structure on the computer will match the web site structure.</p>

<p><strong>VoodooPad Pro document</strong>
<strong>Item meta</strong> data is contained in the <code>HomepageMeta</code> page of the document. This is where most of the personalized info on the site is contained.</p>

<p>In the VPP document tags are used to create a pseudo-folder structure. This means that a page may only have one tag. Some pages are not exported but are used as reference, ie. links in the sidebar or the HomepageMeta page. Static pages that are to be rendered at the root level of the site are tagged <code>main</code>.</p>

<p><strong>Triggers</strong> can be used to include certain information into specific pages or info on every page. I use this for things like Google Analytics which needs to be on every page or the analytics confirmation that is only on the index.html page.</p>

<p><strong>The Web Export Plugin</strong>
Some customization of these files will be necessary for your specific site.</p>

<ul>
<li><p><code>preflight.sh</code> - creates the actual folder hierarchy, the folders are created in the <code>preflight.sh</code> script. The <code>preflight.sh</code> script also copies files like images to the export folder. These images are kept in the web export plugin. File like <code>robots.txt</code> that need to be at the root level are kept in a <code>root</code> folder inside the web export plugin.</p></li>
<li><p><code>postflight.sh</code> - can be used to rename pages that may be PHP based from <code>.html</code> to <code>.php</code></p></li>
<li><p><code>deleteVPExtra.sh</code> - deletes the <em>extra</em> pages that VoodooPad creates during a web export. No changes to this file are needed.</p></li>
<li><p><code>fixRelativePaths.sh</code> - fixes the relative URLs that occur inside of nested pages. No changes to this file are needed.</p></li>
<li><p><code>parseMetaXml.rb</code> - Parses the meta.xml file that VoodooPad creates and uses that infomation to move files into their correct folder structure on the disk and to create a valid sitemap.xml file for use with Google Sitemaps.</p></li>
<li><p><code>Info.plist</code> - This file was edited to call these scripts during the web export process.</p></li>
</ul>

<p><strong>Script Plugins</strong>
These are placed in the <code>~/Library/Application Support/VoodooPad/Script PlugIns/</code> folder. No changes should be required in these scripts. They will be viewable from the <code>Plugin &amp;gt; Blog</code> menu in VoodooPad.</p>

<ul>
<li><p><code>meta_markup_HomepageMeta.lua</code> -  Takes the data from the page <code>HomepageMeta</code> in the VPP doc and adds specific item meta data to the frontmost page.</p></li>
<li><p><code>meta_markup_update.lua</code> - Propagates changes made to the <code>HomepageMeta</code> page to all the item meta data of all pages that require them. This is only just the pages used for the blog-style page.</p></li>
<li><p><code>blog_home_atom.lua</code> - Creates the blog-style page now called <code>home</code> in the VPP document and also creates a valid atom.xml feed in the output directory.</p></li>
</ul>

<p>Comments and questions are welcome. If some enterprising person wants to wrap this all up in the new plugin architecture that would be cool. I&#8217;m happy to help if I can.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2006/11/voodoopad-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Blogging'>VoodooPad Blogging</a> <small>Well, it&#8217;s not really VoodooPad blogging but it&#8217;s pretty close....</small></li>
<li><a href='http://thefragens.com/blog/2006/11/voodoopad-automation/' rel='bookmark' title='Permanent Link: VoodooPad Automation'>VoodooPad Automation</a> <small>I&#8217;ve finally gotten it working. I&#8217;ve now got a Ruby...</small></li>
<li><a href='http://thefragens.com/blog/2006/09/voodoopad-goodness/' rel='bookmark' title='Permanent Link: VoodooPad goodness'>VoodooPad goodness</a> <small>Thanks to Gus Mueller for loads of help adapting a...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iCal - Exchange Time Zone Fix - Chapter 3</title>
		<link>http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/</link>
		<comments>http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 23:42:25 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=596</guid>
		<description><![CDATA[I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow for adding multiple Exchange servers to the script so that you should only need a single script. The set-up is slightly more complex.



As the image above shows there are now only 2 properties, both of which are lists. These lists work together as an array; [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the <a href="http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/">iCal-Invite-Fix script</a> again. This time to allow for adding multiple Exchange servers to the script so that you should only need a single script. The set-up is slightly more complex.</p>

<p><img src="http://thefragens.com/blog/wp-content/uploads/2009/01/ical-fix-properties3.jpg" border="0" alt="ical-fix-properties3.jpg" width="550" height="104" /></p>

<p>As the image above shows there are now only 2 properties, both of which are lists. These lists work together as an array; which means the order of the list items is crucial.</p>

<ul>
<li><code>exchange_fragment</code> contains unique fragments of the TZID that the Exchange server sends.</li>
<li><code>ical_tzid</code> contains the tzid info that iCal expects to see.</li>
</ul>

<p>If you have any problems setting it up let me know. <a href="http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/">This post</a> has all the info for the script.</p>

<p><a href="http://thefragens.com/pub/iCal-Invite-Fix.scpt">Download the iCal-Invite-Fix script</a>.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Importing Mail Message Attachments into Aperture</title>
		<link>http://thefragens.com/blog/2008/11/importing-mail-message-attachments-into-aperture/</link>
		<comments>http://thefragens.com/blog/2008/11/importing-mail-message-attachments-into-aperture/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 00:04:01 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=575</guid>
		<description><![CDATA[So I&#8217;ve just gotten my new Unibody MacBook and Aperture. Immediately I find myself wanting for a Quick Look &#62; Add to Aperture just like there is for iPhoto. Unfortunately it&#8217;s nowhere to be found. Fortunately Aperture is scriptable.

Version 1.0 of SaveAttachments2Aperture is now available. It&#8217;s currently very simple with little error checking. It works [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2006/08/switching-to-mailapp/' rel='bookmark' title='Permanent Link: Switching to Mail.app'>Switching to Mail.app</a> <small>I&#8217;ve recently switched to Mail.app. I never really used it...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve just gotten my new Unibody MacBook and Aperture. Immediately I find myself wanting for a <em>Quick Look &gt; Add to Aperture</em> just like there is for iPhoto. Unfortunately it&#8217;s nowhere to be found. Fortunately Aperture is scriptable.</p>

<p>Version 1.0 of <a href="http://www.thefragens.com/pub/SaveAttachments2Aperture.scpt" onclick="urchinTracker('/outgoing/www.thefragens.com/pub/SaveAttachments2Aperture.scpt?referer=');">SaveAttachments2Aperture</a> is now available. It&#8217;s currently very simple with little error checking. It works multiple attachments per message and imports all attachments of a selected message into a new Aperture project.</p>

<p>It could be used in a Mail rule though I prefer to select it manually from the Script menu. I have it saved in <code>~/Library/Scripts/Applications/Mail/</code>.</p>

<p>A thanks goes out to <a href="http://homepage.mac.com/jlarson7/index.html" onclick="urchinTracker('/outgoing/homepage.mac.com/jlarson7/index.html?referer=');">Automating Aperture</a> where I got some of the Aperture scripting.</p>

<p>Comments welcome.</p>

<p><strong>Update</strong>
Now at version 1.1. I added some simple logic to only import certain file types. You might need to add to this list. If I&#8217;m missing some let me know, especially with Raw images.</p>

<p>v1.2 - add a bunch of the <em>usual</em> camera raw file types</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2006/08/switching-to-mailapp/' rel='bookmark' title='Permanent Link: Switching to Mail.app'>Switching to Mail.app</a> <small>I&#8217;ve recently switched to Mail.app. I never really used it...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/11/importing-mail-message-attachments-into-aperture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iCal - Exchange Time Zone Fix - Chapter 2</title>
		<link>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/</link>
		<comments>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 21:40:45 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=524</guid>
		<description><![CDATA[It was a few months ago that I originally wrote the first incarnation of the MailExchange2iCal script. Since then I&#8217;ve been in contact with a few users trying to make it work for them and I&#8217;ve found a number of peculiarities in the types of email invites sent by Exchange/Outlook. The biggest problem was that [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>It was a few months ago that I originally wrote the first incarnation of the <a href="http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/">MailExchange2iCal script</a>. Since then I&#8217;ve been in contact with a few users trying to make it work for them and I&#8217;ve found a number of peculiarities in the types of email invites sent by Exchange/Outlook. The biggest problem was that the time zone data for the event was improperly formatted. This caused all sorts of problems for Mac users.</p>

<p>Let&#8217;s start at the beginning. Sometimes integration of a Mac in the corporate environment is a bit difficult and takes a bit of ingenuity. This is especially true when dealing with Exchange. The current versions of iCal and iCal Server are CalDAV and iCalendar compliant. Only Outlook 2007 is said to be CalDAV and iCalendar compliant. Previous versions of Outlook are not compliant and don’t play well with other calendar applications. Here’s the actual <a href="http://www.kanzaki.com/docs/ical/tzid.html" onclick="urchinTracker('/outgoing/www.kanzaki.com/docs/ical/tzid.html?referer=');">time zone (TZID)</a> spec and <a href="http://www.kanzaki.com/docs/ical/tzid-p.html" onclick="urchinTracker('/outgoing/www.kanzaki.com/docs/ical/tzid-p.html?referer=');">the spec for how it should be formatted</a>. You can see by looking at it that the TZID that Outlook produces is non-compliant.</p>

<p>A quick Google search shows an <a href="http://www.roughlydrafted.com/2007/07/21/using-iphone-ical-caldav-calendar-servers-and-mac-os-x-leopard-2/" onclick="urchinTracker('/outgoing/www.roughlydrafted.com/2007/07/21/using-iphone-ical-caldav-calendar-servers-and-mac-os-x-leopard-2/?referer=');">article</a> or <a href="http://hardware.itbusinessnet.com/articles/viewarticle.jsp?id=46651-1&amp;afterinter=true" onclick="urchinTracker('/outgoing/hardware.itbusinessnet.com/articles/viewarticle.jsp?id=46651-1_amp_afterinter=true&amp;referer=');">two</a> that explain this very well.</p>

<p>I&#8217;ve found that there are at least 3 different types of invites that can be sent by Exchange/Outlook.</p>

<ol>
<li><code>METHOD:REQUEST</code> - This is the usual email requesting that you attend a meeting.</li>
<li><code>METHOD:PUBLISH</code> - This is essentially a publication notice for an event. It doesn&#8217;t ask you to reply.</li>
<li><code>METHOD:CANCEL</code> - This is a cancellation notice for an event.</li>
</ol>

<p>Additionally, I&#8217;ve found that the emails that contain these invites are formated in at least 3 different ways. Sometimes the calendar event is within the body of the message and is encoded with <code>Content-Transfer-Encoding</code> in either <code>8bit</code> or <code>quoted-printable</code>. Always the <code>.ics</code> file is attached.</p>

<p>My script does the following:</p>

<ol>
<li>It parses the message to either extract the calendar data from the body of the message or from the <code>.ics</code> attachment.</li>
<li>It then figures out if the invite is of type <code>METHOD:REQUEST</code>, <code>METHOD:PUBLISH</code> or <code>METHOD:CANCEL</code>.</li>
<li>If the invite is one of the first 2 types. The time zone is fixed and the event is imported into iCal. You might have to select into which calendar the event will be imported.</li>
<li>If the invite is of type <code>METHOD:CANCEL</code> then the script will locate the corresponding event and set it&#8217;s status to cancelled.</li>
</ol>

<p>* You will have to manually delete the event. It will appear in iCal to have a white strike-through font style.
* Repeating events all seem to have the same UID (Unique IDentifier). I don&#8217;t know why. Every repeating event will be thusly marked as cancelled. You will then manually delete the specific event and manually run the script again while the cancellation message is selected. This will reset the remaining repeating events back to confirmed. Yes, I know this is a bit of a kludge but I don&#8217;t have a better method.
5. It will parse the message to allow for invites from multiple Exchange servers.</p>

<p>My script, now re-named <code>iCal-Invite-Fix.scpt</code>, will need to be customized for each Exchange server from which you receive invites. There are 3 properties at the beginning of the script. They are <code>exchange_fragment</code>, <code>ical_tzid</code> and <code>myCalendar</code>. These first two properties are lists and the order of the items is crucial. The specific item (position in list) of each list must correspond to each other.</p>

<ul>
<li><code>exchange_fragment</code> is a unique fragment of the TZID that your Exchange server sends.</li>
<li><code>ical_tzid</code> is the time zone of the Exchange server in proper format.</li>
<li>This means no spaces, though spaces are replaced automatically with the underscore &#8216;_&#8217;.</li>
<li>For instance, I&#8217;m in Southern California and the correct time zone should be written as <code>US/Pacific</code> or <code>America/Los_Angeles</code>. You can find this information by selecting the time zone drop down menu in the upper right corner of your iCal window and select <code>Other...</code>. If you look in iCal&#8217;s upper right corner for the time zone menu bar the last example will appear as <code>America/Los Angeles</code>.</li>
<li><code>myCalendar</code> is the name of the calendar that normally receives the events. It is needed for the cancellation to function.</li>
</ul>

<!-- img src="http://thefragens.com/blog/wp-content/uploads/2008/08/ical-fix-properties.jpg" alt="ical-fix-properties.jpg" border="0" width="624" height="126" /-->

<p><img src="http://thefragens.com/blog/wp-content/uploads/2008/12/ical-fix-properties2.jpg" border="0" alt="ical-fix-properties2.jpg" width="540" height="143" /></p>

<p>Save the script and either set it up to run from a mail rule or as I do call it from the System AppleScript menu. You will need to save the script in ~/Library/Scripts/Applications/Mail/ folder. Create this folder if it doesn’t exist.</p>

<p>To set the script up to run automatically you will need to create a new Mail rule as follows.</p>

<ol>
<li>Mail -&gt; Preferences -&gt; Rules -&gt; Add Rule</li>
<li>Description &#8220;iCal Invite Fix&#8221;</li>
<li>If &#8220;any&#8221; of the following conditions are met:</li>
</ol>

<p>* &#8220;Any Attachment Name&#8221; &#8220;ends with&#8221; &#8220;.ics&#8221;
4. Perform the following actions:
* Run AppleScript &#8220;~/Library/Scripts/Applications/Mail/iCal-Invite-Fix.scpt&#8221;
5. Click &#8220;OK&#8221; and then &#8220;Apply&#8221;</p>

<p><img src="http://thefragens.com/blog/wp-content/uploads/2008/08/ical-fix-rule.jpg" border="0" alt="ical-fix-rule.jpg" width="556" height="218" /></p>

<p>You can also run the script manually from the system-wide script menu. To install this menu. Open up the <code>/Applications/AppleScript/AppleScript Utility.app</code> and check the <code>Show Script menu in menu bar</code> box. If you put the script in the folder location indicated above it will now be visible when Mail.app is the current application.</p>

<p><a href="http://thefragens.com/pub/iCal-Invite-Fix.scpt">Download the iCal-Invite-Fix script</a>.</p>

<p>Please let me know if there are any problems or you need help setting this up. The script was not entirely my creation and <a href="http://www.macosxhints.com/article.php?story=20060821073102694" onclick="urchinTracker('/outgoing/www.macosxhints.com/article.php?story=20060821073102694&amp;referer=');">credit also goes to others</a>. I’m quite certain any errors are likely mine. <img src='http://thefragens.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p><strong>Updated</strong>: Now produces CalDAV-compliant TZIDs, no quotes.</p>

<p><strong>Updated again</strong>: Now will move the .ics files from /tmp to the Trash.</p>

<p><strong>Update 12/03/2008</strong>: Fixed the <code>METHOD:PUBLISH</code> invite to no longer ask to select which calendar to add event. It will automatically select the first local calendar, like it does with <code>METHOD:REQUEST</code>.</p>

<p><strong>Updated 12/28/2008</strong>: Added ability to use single script with multiple Exchange servers. The trade-off is a slightly more complex set up.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
<li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>iCal - Exchange Time Zone Fix - part 2</title>
		<link>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/</link>
		<comments>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 00:10:31 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=514</guid>
		<description><![CDATA[I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script. It seems if the .ics invite was only listed as an attachment or in base64 encoding then the script would fail. I&#8217;ve subsequently revised the script to handle this and to more gracefully ask into which calendar you want the event imported.

I&#8217;ve also fixed the [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come across a problem with the <a href="http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/">original MailExchange2iCal-TZ-fix script</a>. It seems if the .ics invite was only listed as an attachment or in base64 encoding then the script would fail. I&#8217;ve subsequently revised the script to handle this and to more gracefully ask into which calendar you want the event imported.</p>

<p>I&#8217;ve also fixed the script so that it runs successfully from a rule.</p>

<p><strong>Note</strong>: The <code>ical_TZID</code> property cannot have any spaces. Replace all spaces with underscores &#8220;<code>_</code>&#8221;. In iCal <code>America/Los_Angeles</code> will look like <code>America/Los Angeles</code> in the iCal dropdown menu.</p>

<p>Let me know if there are any problems.</p>

<p>As always you can <a href="http://thefragens.com/pub/iCal-Invite-Fix.scpt">download the MailExchange2iCal-TZ-fix script here</a>.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix'>iCal - Exchange Time Zone Fix</a> <small>As any Mac user who deals with Microsoft Exchange invites...</small></li>
<li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Text and Quote Wrapping</title>
		<link>http://thefragens.com/blog/2008/06/text-and-quote-wrapping/</link>
		<comments>http://thefragens.com/blog/2008/06/text-and-quote-wrapping/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 22:57:40 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=499</guid>
		<description><![CDATA[If any of you find yourself using webmail you&#8217;ll know what I&#8217;m talking about. If you&#8217;re at all like me, you like to be able to follow the replies in an email thread. Using webmail the quoting and wrapping get screwed up quite easily.

I was looking for a simple way to rewrap, unwrap, increase the [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2006/03/quick-links-applescript/' rel='bookmark' title='Permanent Link: Quick Links AppleScript'>Quick Links AppleScript</a> <small>Last week, in response to a plea from Steve; he...</small></li>
<li><a href='http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Pro Blogging'>VoodooPad Pro Blogging</a> <small>It&#8217;s time to package up all my VoodooPad Pro blogging...</small></li>
<li><a href='http://thefragens.com/blog/2006/02/converting-the-clipboard/' rel='bookmark' title='Permanent Link: Converting the Clipboard'>Converting the Clipboard</a> <small>Steve talks about un-styling of the text on the clipboard...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>If any of you find yourself using webmail you&#8217;ll know what I&#8217;m talking about. If you&#8217;re at all like me, you like to be able to follow the replies in an email thread. Using webmail the quoting and wrapping get screwed up quite easily.</p>

<p>I was looking for a simple way to rewrap, unwrap, increase the quote level, and decrease the quote level of any selection of text. I found that there were several good shareware programs that did this, and many other things. But I was really looking for a simple one-trick pony of sorts. So in the usual fashion I decided to roll my own. What I did was create a single shell script that when passed a parameter will do what you want to whatever is in the clipboard. It then replaces the clipboard with the changed text.</p>

<p>I call the package <a href="http://thefragens.com/pub/quote_changes.zip"><em>quote&#95;changes</em></a>. Go get it.</p>

<p>After you unzip it, put it in <code>~/Library/Scripts/</code>. Activate your system-wide script menu from the <code>AppleScript Utility.app</code>.</p>

<p>The scripts are all meant to be in the same folder. The scripts that does all the work is <code>change_quote.sh</code>. The usage of the script is as follows:</p>

<p><code>$ change_quote.sh increase</code> &#8212; will rewrap the text on the clipboard and increase the level of quoting (&gt;). The additional scripts in the package are simply calls with the appropriate parameters. The full usage is</p>

<p>$ change_quote.sh (increase|decrease|rewrap|unwrap)</p>

<p>If anyone has any problems let me know. I hope others find this useful. Enjoy.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2006/03/quick-links-applescript/' rel='bookmark' title='Permanent Link: Quick Links AppleScript'>Quick Links AppleScript</a> <small>Last week, in response to a plea from Steve; he...</small></li>
<li><a href='http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Pro Blogging'>VoodooPad Pro Blogging</a> <small>It&#8217;s time to package up all my VoodooPad Pro blogging...</small></li>
<li><a href='http://thefragens.com/blog/2006/02/converting-the-clipboard/' rel='bookmark' title='Permanent Link: Converting the Clipboard'>Converting the Clipboard</a> <small>Steve talks about un-styling of the text on the clipboard...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/06/text-and-quote-wrapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iCal - Exchange Time Zone Fix</title>
		<link>http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/</link>
		<comments>http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 18:06:26 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mac-osx]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=484</guid>
		<description><![CDATA[As any Mac user who deals with Microsoft Exchange invites will tell you Exchange screws up the time zone information. What this means is that you will likely miss your meetings. Not a good thing.

Justin Hartman has recently given you his solution to this problem. I haven&#8217;t tested it but in looking at it I&#8217;m [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>As any Mac user who deals with Microsoft Exchange invites will tell you <em>Exchange screws up the time zone information</em>. What this means is that you will likely miss your meetings. Not a good thing.</p>

<p><a href="http://justinhartman.com/2008/03/31/apple-ical-microsoft-exchange-fix-for-leopard/" onclick="urchinTracker('/outgoing/justinhartman.com/2008/03/31/apple-ical-microsoft-exchange-fix-for-leopard/?referer=');">Justin Hartman</a> has recently given you his solution to this problem. I haven&#8217;t tested it but in looking at it I&#8217;m certain it works just fine. I say this because he&#8217;s fixing the problem is a similar manner. It&#8217;s just that he&#8217;s using a combination of shell scripts and AppleScripts. I&#8217;ve got it down to a single AppleScript.</p>

<p>There is one <code>property</code> at the head of the script that needs to be fixed depending upon the location of your Exchange server. What you need to do is copy in the correct property from what iCal expects to see as time zone information.</p>

<p><img src="http://thefragens.com/blog/wp-content/uploads/2008/05/ical-tzid.png" border="0" alt="ical-tzid.png" width="523" height="112" /></p>

<p>You can find this information by selecting the time zone drop down menu in the upper right corner of your iCal window and select <code>Other...</code>.</p>

<p>Once there find the location of your Exchange server and see what the resultant time zone information looks like in iCal. In my case, I live in California and my time zone is <code>US/Pacific</code> or <code>America/Los_Angeles</code> but the Exchange server in question lives in Dallas. So I set the property to <code>US/Central</code>.</p>

<p><strong>Note</strong>: The <code>ical_TZID</code> property cannot have any spaces. Replace all spaces with underscores &#8220;<code>_</code>&#8221;. In iCal <code>America/Los_Angeles</code> will look like <code>America/Los Angeles</code> in the iCal dropdown menu.</p>

<p>I think I&#8217;ve built in the enough logic to grab any twisted time zone information out of the Exchange invite that Exchange can produce. If I&#8217;m wrong let me know.</p>

<p>Save the script and either set it up to run from a mail rule or as I do call it from the System AppleScript menu. You will need to save the script in <code>~/Library/Scripts/Applications/Mail/</code> folder. Create this folder if it doesn&#8217;t exist.</p>

<p>The script was not entirely my creation and <a href="http://www.macosxhints.com/article.php?story=20060821073102694" onclick="urchinTracker('/outgoing/www.macosxhints.com/article.php?story=20060821073102694&amp;referer=');">credit also goes to others</a>. I&#8217;m quite certain any errors are likely mine. <img src='http://thefragens.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>If it works for you let me know. If it doesn&#8217;t work let me know that too and I&#8217;ll see if it can be fixed.</p>

<p>You will likely need a different copy of the script for each Exchange server that send you invites.</p>

<p><strong>Update</strong> - 5 August 2008</p>

<p>To set the script up to run automatically you will need to create a new Mail rule as follows.</p>

<ol>
<li>Mail -&gt; Preferences -&gt; Rules -&gt; Add Rule</li>
<li>Description &#8220;Fix Exchange Invites&#8221;</li>
<li>If &#8220;any&#8221; of the following conditions are met:</li>
</ol>

<p>* &#8220;Content-Class&#8221; &#8220;Contains&#8221; &#8220;urn:content-classes:calendarmessage&#8221;
Note that the Content-Class header is not in the default list of headers on which you can set a rule action, but you can add it. This hint originally <a href="http://www.macosxhints.com/article.php?story=20060821073102694" onclick="urchinTracker('/outgoing/www.macosxhints.com/article.php?story=20060821073102694&amp;referer=');">here</a>.
* &#8220;Any Attachment Name&#8221; &#8220;ends with&#8221; &#8220;.ics&#8221;
4. Perform the following actions:
* &#8220;Run AppleScript&#8221; &#8220;~/Library/Scripts/Applications/Mail/MailExchange2iCal-TZ-fix.scpt&#8221;
5. Click &#8220;OK&#8221; and then &#8220;Apply&#8221;</p>

<p><strong>Update</strong> - 11 August 2008</p>

<p>I found a glaring problem that I believe I&#8217;ve fixed. Apparently if the invite is only sent as an attachment the previous version of the script wouldn&#8217;t parse out the .ics attachment. This new version will. Please download it.</p>

<p><strong>Update</strong> - 18 August 2008</p>

<p>I re-wrote the script making it better and more versatile. <a href="http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/">Please go to it&#8217;s new post home.</a></p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-part-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - part 2'>iCal - Exchange Time Zone Fix - part 2</a> <small>I&#8217;ve come across a problem with the original MailExchange2iCal-TZ-fix script....</small></li>
<li><a href='http://thefragens.com/blog/2008/08/ical-exchange-time-zone-fix-chapter-2/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 2'>iCal - Exchange Time Zone Fix - Chapter 2</a> <small>It was a few months ago that I originally wrote...</small></li>
<li><a href='http://thefragens.com/blog/2008/12/ical-exchange-time-zone-fix-chapter-3/' rel='bookmark' title='Permanent Link: iCal - Exchange Time Zone Fix - Chapter 3'>iCal - Exchange Time Zone Fix - Chapter 3</a> <small>I&#8217;ve updated the iCal-Invite-Fix script again. This time to allow...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/04/ical-exchange-time-zone-fix/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>WordPress SVN</title>
		<link>http://thefragens.com/blog/2008/02/wordpress-svn/</link>
		<comments>http://thefragens.com/blog/2008/02/wordpress-svn/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 00:45:52 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[blogging]]></category>

		<guid isPermaLink="false">http://thefragens.com/blog/?p=473</guid>
		<description><![CDATA[OK, since I&#8217;ve switched over to WordPress I have to admit it&#8217;s been pretty painless. I decided to go with the SVN update process since I know it&#8217;s much easier. But the monkey wrench in the process is having to switch to the new checkout for every stable release.

So instead of

$ cd ./blog
$ svn up


I [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2007/11/moved-to-wordpress/' rel='bookmark' title='Permanent Link: Moved to WordPress!'>Moved to WordPress!</a> <small>Well, here I am switched over to WordPress. It&#8217;s not...</small></li>
<li><a href='http://thefragens.com/blog/2008/07/wordpress-and-the-iphone/' rel='bookmark' title='Permanent Link: WordPress and the iPhone'>WordPress and the iPhone</a> <small>So I&#8217;m trying out the latest WordPress for iPhone app...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>OK, since I&#8217;ve switched over to WordPress I have to admit it&#8217;s been pretty painless. I decided to go with the <a href="http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion" onclick="urchinTracker('/outgoing/codex.wordpress.org/Installing/Updating_WordPress_with_Subversion?referer=');">SVN update process</a> since I know it&#8217;s much easier. But the monkey wrench in the process is having to switch to the new checkout for every stable release.</p>

<p>So instead of</p>

<pre><code>$ cd ./blog
$ svn up
</code></pre>

<p>I have to do the following.</p>

<pre><code>$ cd ./blog
$ svn sw http://svn.automattic.com/wordpress/tags/2.3.2/
$ svn up
</code></pre>

<p>Why isn&#8217;t there a symlink for the latest stable release? Then I could set up..</p>

<pre><code>$ svn sw http://svn.automattic.com/wordpress/tags/current
</code></pre>

<p>and be done with it.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2007/11/moved-to-wordpress/' rel='bookmark' title='Permanent Link: Moved to WordPress!'>Moved to WordPress!</a> <small>Well, here I am switched over to WordPress. It&#8217;s not...</small></li>
<li><a href='http://thefragens.com/blog/2008/07/wordpress-and-the-iphone/' rel='bookmark' title='Permanent Link: WordPress and the iPhone'>WordPress and the iPhone</a> <small>So I&#8217;m trying out the latest WordPress for iPhone app...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2008/02/wordpress-svn/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>URL Rewriting</title>
		<link>http://thefragens.com/blog/2007/11/url-rewriting/</link>
		<comments>http://thefragens.com/blog/2007/11/url-rewriting/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 19:16:12 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://drfragen.com/wordpress/?p=463</guid>
		<description><![CDATA[This is a real late addition.

The following is a tutorial from Ross Shannon on URL rewriting. Like Marlyse I&#8217;m repeating the content for my future use.

An Introduction to Rewriting

by Ross Shannon

The Apache server&#8217;s mod_rewrite module gives you the ability to transparently redirect one URL to another, without the user&#8217;s knowlege. This opens up all sorts [...]


Related posts:<ol><li><a href='http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Pro Blogging'>VoodooPad Pro Blogging</a> <small>It&#8217;s time to package up all my VoodooPad Pro blogging...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is a real late addition.</p>

<p><em>The following is a tutorial from Ross Shannon on URL rewriting. Like <a href="http://www.marlyse.com/index.php?p=490" onclick="urchinTracker('/outgoing/www.marlyse.com/index.php?p=490&amp;referer=');">Marlyse</a> I&#8217;m repeating the content for my future use.</em></p>

<h2><a href="http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html" onclick="urchinTracker('/outgoing/www.yourhtmlsource.com/sitemanagement/urlrewriting.html?referer=');">An Introduction to Rewriting</a></h2>

<p>by <a href="http://www.yourhtmlsource.com/about/" onclick="urchinTracker('/outgoing/www.yourhtmlsource.com/about/?referer=');">Ross Shannon</a></p>

<p>The Apache server&#8217;s <code>mod_rewrite</code> module gives you the ability to transparently redirect one URL to another, without the user&#8217;s knowlege. This opens up all sorts of possibilities, from simply redirecting old URLs to new addresses, to cleaning up the &#8216;dirty&#8217; URLs coming from a poor publishing system &#8212; giving you URLs that are friendlier to both readers and search engines.</p>

<p><em>This page was last updated on 2005-02-10</em></p>

<p>Readable URLs are nice. A well designed website will have a logical file system layout, with smart folder and file names, and as many implementation details left out as possible. In the best designed sites, readers can <strong>guess at filenames with a high level of success</strong>.</p>

<p>However, there are some cases when the best possible information design can&#8217;t stop your site&#8217;s URLs from being nigh-on impossible to use. For instance, you may be using a Content Management System that serves out URLs that look something like</p>

<p>http://www.site.com/viewcatalog.asp?category=hats&amp;prodID=53</p>

<p>This is a horrible URL, but it and its brethren are becoming increasingly prevalent in these days of dynamically generated pages. There are a number of problems with an URL of this kind.</p>

<ul>
<li>It <strong>exposes the underlying technology</strong> of the website (in this case ASP). This can give potential hackers clues as to what type of data they should send along with the query string to perform a &#8216;front-door&#8217; attack on the site. Information like this shouldn&#8217;t be given away if you can help it.</li>
</ul>

<p>Even if you&#8217;re not overly concerned with the security of your site, <strong>the technology you&#8217;re using is at best irrelevant</strong> &#8212; and at worst a source of confusion &#8212; to your readers, so it should be hidden from them if possible.</p>

<p>Also, if at some point in the future you decide to change the language that your site is based on (to <a href="http://php.net/" onclick="urchinTracker('/outgoing/php.net/?referer=');">» PHP</a>, for instance); all your old URLs will stop working. This is a pretty serious problem, as anyone who has tackled a full-on site rewrite will attest.</p>

<ul>
<li><p><strong>The URL is littered with awkward punctuation</strong>, like the question mark and ampersand. Those &amp; characters, in particular, are problematic because if another webmaster links to this page using that URL, the unescaped ampersands will mess up their <a href="http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html" onclick="urchinTracker('/outgoing/www.yourhtmlsource.com/accessibility/xhtmlexplained.html?referer=');">XHTML</a> conformance.</p></li>
<li><p>Some <strong>search engines won&#8217;t index pages which they think are generated dynamically</strong>. They&#8217;ll see that question mark in the URL and just turn their asses around.</p></li>
</ul>

<p>Luckily, using rewriting, we can clean up this URL to something far more manageable. For example, we could map it to</p>

<p>http://www.site.com/catalog/hats/53/</p>

<p>Much better. This URL is more logical, readable and memorable, and will be picked up by all search engines. The <em>faux</em>-directories are short and descriptive. Importantly, it looks more <em>permanent</em>.</p>

<p>To use <code>mod_rewrite</code>, you supply it with the link text you want the server to match, and the real URLs that these URLs will be redirected to. The URLs to be matched can be straight file addresses, which will match one file, or they can be <em>regular expressions</em>, which will match many files.</p>

<h2>Basic Rewriting</h2>

<p>Some servers will not have <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html" onclick="urchinTracker('/outgoing/httpd.apache.org/docs/mod/mod_rewrite.html?referer=');">» mod_rewrite</a> enabled by default. As long as the <a href="http://modules.apache.org/" onclick="urchinTracker('/outgoing/modules.apache.org/?referer=');">» module</a> is present in the installation, you can enable it simply by starting a .htaccess file with the command</p>

<p><code>**RewriteEngine** on</code></p>

<p>Put this .htaccess file in your root so that rewriting is enabled throughout your site. You only need to write this line once per .htaccess file.</p>

<h3>Basic Redirects</h3>

<p>We&#8217;ll start off with a straight redirect; as if you had moved a file to a new location and want all links to the old location to be forwarded to the new location. Though you shouldn&#8217;t really ever <a href="http://www.w3.org/Provider/Style/URI.html" title="As Sir Tim says, &amp;‘Cool URIs don&amp;’t change&amp;’" onclick="urchinTracker('/outgoing/www.w3.org/Provider/Style/URI.html?referer=');">» move a file</a> once it has been placed on the web; at least when you <em>simply have to</em>, you can do your best to stop any old links from breaking.</p>

<p><code>**RewriteEngine** on
**RewriteRule** **^**old\.html**$** new.html</code></p>

<p>Though this is the simplest example possible, it may throw a few people off. The structure of the &#8216;old&#8217; URL is the only difficult part in this <code>RewriteRule</code>. There are three special characters in there.</p>

<ul>
<li>The caret, <code>^</code>, signifies the <strong>start of an url</strong>, under the current directory. This directory is whatever directory the .htaccess file is in. You&#8217;ll start almost all matches with a caret.</li>
<li>The dollar sign, <code>$</code>, signifies the <strong>end of the string to be matched</strong>. You should add this in to stop your rules matching the first part of longer URLs.</li>
<li>The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didn&#8217;t <strong>escape it with the backslash</strong>, which tells Apache to treat it as a normal character.</li>
</ul>

<p>So, this rule will make your server transparently redirect from old.html to the new.html page. Your reader will have no idea that it happened, and it&#8217;s pretty much instantaneous.</p>

<h3>Forcing New Requests</h3>

<p>Sometimes you <em>do</em> want your readers to know a redirect has occurred, and can do this by forcing a new HTTP request for the new page. This will make the browser load up the new page as if it was the page originally requested, and the location bar will change to show the URL of the new page. All you need to do is turn on the <code>[R]</code> flag, by appending it to the rule:</p>

<p><code>**RewriteRule** **^**old\.html**$** new.html **[R]**</code></p>

<h2>Using Regular Expressions</h2>

<p>Now we get on to the <em>really</em> useful stuff. The power of <code>mod_rewrite</code> comes at the expense of complexity. If this is your first encounter with regular expressions, you may find them to be a tough nut to crack, but the options they afford you are well worth the slog. I&#8217;ll be providing plenty of examples to guide you through the basics here.</p>

<p>Using regular expressions you can have your rules matching a set of URLs at a time, and mass-redirect them to their actual pages. Take this rule;</p>

<p><code>**RewriteRule** **^**products/([0-9][0-9])/**$** productinfo.php?prodID=$1</code></p>

<p>This will match any URLs that start with &#8216;products/&#8217;, followed by any two digits, followed by a forward slash. For example, this rule will match an URL like products/12/ or products/99/, and redirect it to the PHP page.</p>

<p>The parts in square brackets are called <em>ranges</em>. In this case we&#8217;re allowing anything in the range 0-9, which is any digit. Other ranges would be <code>[A-Z]</code>, which is any uppercase letter; <code>[a-z]</code>, any lowercase letter; and <code>[A-Za-z]</code>, any letter in either case.</p>

<p>We have <strong>encased the regular expression part of the URL in parentheses</strong>, because we want to <strong>store whatever value was found here for later use</strong>. In this case we&#8217;re sending this value to a PHP page as an argument. Once we have a value in parentheses we can use it through what&#8217;s called a <em>back-reference</em>. <strong>Each of the parts you&#8217;ve placed in parentheses are given an index, starting with one</strong>. So, the first back-reference is <code>$1</code>, the third is <code>$3</code> etc.</p>

<p>Thus, once the redirect is done, the page loaded in the readers&#8217; browser will be something like productinfo.php?prodID=12 or something similar. Of course, we&#8217;re keeping this true URL secret from the reader, because it likely ain&#8217;t the prettiest thing they&#8217;ll see all day.</p>

<h3>Adding Trailing Slashes</h3>

<p>If your site visitor had entered something like products/12, the rule above won&#8217;t do a redirect, as the slash at the end is missing. To promote good URL writing, we&#8217;ll take care of this by doing a direct redirect to the same URL with the slash appended.</p>

<p><code>**RewriteRule** **^**products/([0-9][0-9])**$** products/$1/ **[R]**</code></p>

<p><strong>Multiple redirects in the same .htaccess file can be applied in sequence</strong>, which is what we&#8217;re doing here. This rule is added before the one we did above, like so:</p>

<p><code>**RewriteRule** **^**products/([0-9][0-9])**$** products/$1/ **[R]**
**RewriteRule** **^**products/([0-9][0-9])/**$** productinfo.php?prodID=$1</code></p>

<p>Thus, if the user types in the URL products/12, our first rule kicks in, rewriting the URL to include the trailing slash, and doing a new request for products/12/ so the user can see that we likes our trailing slashes around here. Then the second rule has something to match, and transparently redirects this URL to productinfo.php?prodID=12. <em>Slick.</em></p>

<h3>Match Modifiers</h3>

<p>You can expand your regular expression patterns by adding some modifier characters, which allow you to match URLs with an indefinite number of characters. In our examples above, we were only allowing two numbers after products. This isn&#8217;t the most expandable solution, as if the shop ever grew beyond these initial confines of 99 products and created the URL productinfo.php?prodID=100, our rules would cease to match this URL.</p>

<p>So, instead of hard-coding a set number of characters to look for, we&#8217;ll work in some room to grow by allowing any number of characters to be entered. The rule below does just that:</p>

<p><code>**RewriteRule** **^**products/([0-9]**+**)**$** products/$1/ **[R]**</code></p>

<p>Note the plus sign (<code>+</code>) that has snuck in there. This modifier changes whatever comes directly before it, by saying &#8216;<strong>one or more of the preceding character or range</strong>.&#8217; In this case it means that the rule will match any URL that starts with products/ and ends with at least one digit. So this&#8217;ll match both products/1 and products/1000.</p>

<h3>Adding Guessable URLs</h3>

<p>Using these simple commands you can set up a slew of &#8216;shortcut URLs&#8217; that you think visitors will likely try to enter to get to pages they know exist on your site. For example, I&#8217;d imagine a lot of visitors try jumping straight into our <a href="http://www.yourhtmlsource.com/stylesheets/" onclick="urchinTracker('/outgoing/www.yourhtmlsource.com/stylesheets/?referer=');">stylesheets</a> section by typing the URL http://www.yourhtmlsource.com/css/. We can catch these cases, and hopefully alert the reader to the correct address by updating their location bar once the redirect is done with these lines:</p>

<p><code>**RewriteRule** **^**css(/)?**$** /stylesheets/ **[R]**</code></p>

<p>The simple regular expression in this rule allows it to match the css URL with or without a trailing slash. The question mark means &#8216;zero or one of the preceding character or range&#8217; &#8212; in other words either yourhtmlsource.com/css or yourhtmlsource.com/css/ will both be taken care of by this one rule.</p>

<p>This approach means less confusing <a href="http://www.yourhtmlsource.com/sitemanagement/custom404error.html" title="Even if you&amp;’ve set up your own, nobody likes to hit them" onclick="urchinTracker('/outgoing/www.yourhtmlsource.com/sitemanagement/custom404error.html?referer=');">404 errors</a> for your readers, and a site that seems to run a whole lot smoother all &#8216;round.</p>


<p>Related posts:<ol><li><a href='http://thefragens.com/blog/2009/05/voodoopad-pro-blogging/' rel='bookmark' title='Permanent Link: VoodooPad Pro Blogging'>VoodooPad Pro Blogging</a> <small>It&#8217;s time to package up all my VoodooPad Pro blogging...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/' onclick="urchinTracker('/outgoing/mitcho.com/code/yarpp/?referer=');">Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://thefragens.com/blog/2007/11/url-rewriting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
