<?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>Vanderbrew &#187; Code</title>
	<atom:link href="http://vanderbrew.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://vanderbrew.com/blog</link>
	<description>The shared bits</description>
	<lastBuildDate>Sun, 04 Apr 2010 17:04:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Project Euler and Math</title>
		<link>http://vanderbrew.com/blog/2010/02/23/project-euler-and-math/</link>
		<comments>http://vanderbrew.com/blog/2010/02/23/project-euler-and-math/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 15:10:21 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[euler]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/?p=284</guid>
		<description><![CDATA[I&#8217;ve always had the sense that there was a lot of math out there that I didn&#8217;t know. There is a great deal of graphics math and crypto math and others that I&#8217;ve never felt I had much reason to explore &#8211; but I recently realized that there&#8217;s value in looking into some of this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always had the sense that there was a lot of math out there that I didn&#8217;t know. There is a great deal of graphics math and crypto math and others that I&#8217;ve never felt I had much reason to explore &#8211; but I recently realized that there&#8217;s value in looking into some of this other math.</p>
<p>I&#8217;ve known about <a href="http://projecteuler.net/">Project Euler</a> for a while now but only recently did I start trying to solve the problems. My first approach to any problem was just to try to brute force it (I&#8217;ve got a speedy modern computer that can do math well, how long can it take to solve these?) but surprisingly it doesn&#8217;t always work. I find myself having to go out and do research. Learn about techniques and algorithms for solving math problems and apply them in my own code.</p>
<p>It&#8217;s been a wonderfully refreshing lesson in thinking outside my own box. I&#8217;ve found that I don&#8217;t always know the best solution. There are algorithm tools out there that some incredibly smart people have deduced/devised and learning of and about them is very good for my development both professionally and personally.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2010/02/23/project-euler-and-math/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add To Yojimbo with AppleScript</title>
		<link>http://vanderbrew.com/blog/2010/02/18/add-to-yojimbo-with-applescript/</link>
		<comments>http://vanderbrew.com/blog/2010/02/18/add-to-yojimbo-with-applescript/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 06:17:20 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[netnewswire]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[yojimbo]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/?p=278</guid>
		<description><![CDATA[I&#8217;ve started using Yojimbo more as an Anything Bucket and I wanted an easy way to get stuff into it. I found several AppleScripts and they were all good, but they were for individual applications. I try to minimize how much I have to think about routine stuff &#8211; I&#8217;d much rather have code that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started using Yojimbo more as an <a href="http://shawnblanc.net/2009/09/yojimbo-and-anything-buckets/">Anything Bucket</a> and I wanted an easy way to get stuff into it. I found several AppleScripts and they were all good, but they were for individual applications. I try to minimize how much I have to think about routine stuff &#8211; I&#8217;d much rather have code that just &#8220;does the right thing&#8221; so I set out to meld the scripts into a single one.</p>
<p>I&#8217;m quite happy with the results. I&#8217;ve got a single shortcut setup (⌘⌥Y) in <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> and I can use it in any of the apps that I need to capture from (Mail, Safari, NetNewsWire).</p>
<p><a href="/blog/wp-content/uploads/2010/02/Add%20To%20Yojimbo.scpt.zip">Direct download link</a></p>
<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">(*<br />
<br />
Add To Yojimbo Script<br />
<br />
Matt Vanderpol <br />
1.0 - 2010-02-18<br />
<br />
Collects tag info and creates a new web archive or note in Yojimbo. Can cancel from tag<br />
collection screen to cancel action.<br />
<br />
Currently works from:<br />
&nbsp; NetNewsWire - creates web archive<br />
&nbsp; Mail - creates note<br />
&nbsp; Safari - creates web archive<br />
&nbsp; <br />
Notifies via growsl on success or failure.<br />
<br />
Based on work by:<br />
&nbsp; &nbsp; John Gruber (Create Yojimbo Bookmark From NetNewsWire - http://daringfireball.net/misc/2007/05/nnw-to-yojimbo-bookmark)<br />
&nbsp; &nbsp; Jom Correia (Create Yojimbo Note From Apple Mail - http://www.listsearch.com/Yojimbo/Thread/index.lasso?342#2169)<br />
&nbsp; &nbsp; Jim DeVona (Bookmark in Yojimbo - http://anoved.net/software/bookmark-in-yojimbo/)<br />
&nbsp; &nbsp; <br />
<br />
*)</span><br />
<br />
<span style="color: #ff0033; font-weight: bold;">global</span> gScript, gApplication<br />
<br />
<span style="color: #808080; font-style: italic;">-- From: http://daringfireball.net/2009/01/applescripts_targetting_safari_or_webkit</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _app <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033;">every</span> process <span style="color: #ff0033;">whose</span> frontmost <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> _app<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> GetCurrentApp<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> GetTags<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- prompt for tags</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tags <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _dlog2 <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Set tags (if any) for web archive:&quot;</span> <span style="color: #0066ff;">default answer</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;&quot;</span> default button <span style="color: #000000;">2</span> cancel button <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _action2 <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> button returned <span style="color: #ff0033; font-weight: bold;">of</span> _dlog2<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> _action2 <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #ff0033;">or</span> _action2 <span style="color: #000000;">=</span> <span style="color: #009900;">&quot;Cancel&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Cancel Add&quot;</span> description <span style="color: #009900;">&quot;User cancelled adding item to Yojimbo&quot;</span> <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">error</span> <span style="color: #0066ff;">number</span> <span style="color: #000000;">-</span><span style="color: #000000;">128</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _answer <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> _dlog2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> _answer <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> AppleScript<span style="">'</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;, &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tags <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">items</span> <span style="color: #ff0033; font-weight: bold;">of</span> _answer<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> _tags<br />
<span style="color: #ff0033; font-weight: bold;">end</span> GetTags<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> GenerateMessageText<span style="color: #000000;">&#40;</span>m<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Mail&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _sender <span style="color: #ff0033; font-weight: bold;">to</span> sender <span style="color: #ff0033; font-weight: bold;">of</span> m<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _subject <span style="color: #ff0033; font-weight: bold;">to</span> subject <span style="color: #ff0033; font-weight: bold;">of</span> m<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _date <span style="color: #ff0033; font-weight: bold;">to</span> date received <span style="color: #ff0033; font-weight: bold;">of</span> m <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _contents <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">content</span> <span style="color: #ff0033; font-weight: bold;">of</span> m<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _messageString <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;From:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">tab</span> <span style="color: #000000;">&amp;</span> _sender <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _messageString <span style="color: #ff0033; font-weight: bold;">to</span> _messageString <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;Subject:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">tab</span> <span style="color: #000000;">&amp;</span> _subject <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _messageString <span style="color: #ff0033; font-weight: bold;">to</span> _messageString <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;Date:&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #0066ff;">tab</span> <span style="color: #000000;">&amp;</span> _date <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _messageString <span style="color: #ff0033; font-weight: bold;">to</span> _messageString <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #000000;">&amp;</span> _contents<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> GenerateMessageText<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> AddWebArchive<span style="color: #000000;">&#40;</span>h_URL, _tags, _title<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Yojimbo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _new_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">make</span> <span style="color: #0066ff;">new</span> web archive <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">contents</span> h_URL<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add tags _tags <span style="color: #ff0033; font-weight: bold;">to</span> _new_item<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Success Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Import Success&quot;</span> description <span style="color: #009900;">&quot;Successfully imported <span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> _title <span style="color: #000000;">&amp;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\&quot;</span> to Yojimbo&quot;</span> <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> AddWebArchive<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> AddNote<span style="color: #000000;">&#40;</span>_contents, _name, _tags<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- create the new note</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Yojimbo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _new_item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">make</span> <span style="color: #0066ff;">new</span> note <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">properties</span> <span style="color: #000000;">&#123;</span><span style="color: #0066ff;">contents</span>:_contents, <span style="color: #0066ff;">name</span>:_name<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; add tags _tags <span style="color: #ff0033; font-weight: bold;">to</span> _new_item<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Success Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Note Created&quot;</span> description ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;&quot;</span> <span style="color: #000000;">&amp;</span> _name <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> AddNote<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #0066ff;">run</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> gApplication <span style="color: #ff0033; font-weight: bold;">to</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> gScript <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;Add To Yojimbo Script&quot;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <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;Success Notification&quot;</span>, <span style="color: #009900;">&quot;Failure Notification&quot;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> enabledNotificationsList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Success Notification&quot;</span>, <span style="color: #009900;">&quot;Failure Notification&quot;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; register <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">application</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gScript all notifications allNotificationsList ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default notifications enabledNotificationsList ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; icon <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> gApplication<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;NetNewsWire&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tags <span style="color: #ff0033; font-weight: bold;">to</span> GetTags<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;NetNewsWire&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033;">index</span> <span style="color: #ff0033; font-weight: bold;">of</span> selected <span style="color: #0066ff;">tab</span> <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tabNum <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">index</span> <span style="color: #ff0033; font-weight: bold;">of</span> selected <span style="color: #0066ff;">tab</span> <span style="color: #000000;">+</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tabURLs <span style="color: #ff0033; font-weight: bold;">to</span> URLs <span style="color: #ff0033; font-weight: bold;">of</span> tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033; font-weight: bold;">get</span> <span style="color: #0066ff;">item</span> _tabNum <span style="color: #ff0033; font-weight: bold;">of</span> _tabURLs<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tabTitles <span style="color: #ff0033; font-weight: bold;">to</span> titles <span style="color: #ff0033; font-weight: bold;">of</span> tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _newItemTitle <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033; font-weight: bold;">get</span> <span style="color: #0066ff;">item</span> _tabNum <span style="color: #ff0033; font-weight: bold;">of</span> _tabTitles<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">my</span> AddWebArchive<span style="color: #000000;">&#40;</span>h_URL, _tags, _newItemTitle<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #0066ff;">exists</span> selectedHeadline <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> URL <span style="color: #ff0033; font-weight: bold;">of</span> selectedHeadline<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _newItemTitle <span style="color: #ff0033; font-weight: bold;">to</span> title <span style="color: #ff0033; font-weight: bold;">of</span> selectedHeadline<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">my</span> AddWebArchive<span style="color: #000000;">&#40;</span>h_URL, _tags, _newItemTitle<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">error</span> <span style="color: #009900;">&quot;No headline is selected.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Import Failure&quot;</span> description <span style="color: #009900;">&quot;Failed to import <span style="color: #000000; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000;">&amp;</span> newItemTitle <span style="color: #000000;">&amp;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\&quot;</span> to Yojimbo. &nbsp;Error: &quot;</span> <span style="color: #000000;">&amp;</span> error_message <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Mail&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tags <span style="color: #ff0033; font-weight: bold;">to</span> GetTags<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Mail&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> message viewer <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _messageList <span style="color: #ff0033; font-weight: bold;">to</span> selected messages<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _name <span style="color: #ff0033; font-weight: bold;">to</span> subject <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> _messageList<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _contents <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> m <span style="color: #ff0033; font-weight: bold;">in</span> _messageList<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _contents <span style="color: #ff0033; font-weight: bold;">to</span> _contents <span style="color: #000000;">&amp;</span> <span style="color: #ff0033; font-weight: bold;">my</span> GenerateMessageText<span style="color: #000000;">&#40;</span>m<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">my</span> AddNote<span style="color: #000000;">&#40;</span>_contents, _name, _tags<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Safari&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _tags <span style="color: #ff0033; font-weight: bold;">to</span> GetTags<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- identify the page to create web archive for, if any&nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> URL <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">document</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _pageTitle <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">the</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">document</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">my</span> AddWebArchive<span style="color: #000000;">&#40;</span>h_URL, _tags, _pageTitle<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Unknown Application&quot;</span> description <span style="color: #009900;">&quot;Don't know how to add to Yojimbo from &quot;</span> <span style="color: #000000;">&amp;</span> gApplication ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #0066ff;">run</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2010/02/18/add-to-yojimbo-with-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View in Readability AppleScript</title>
		<link>http://vanderbrew.com/blog/2010/02/15/view-in-readability-applescript/</link>
		<comments>http://vanderbrew.com/blog/2010/02/15/view-in-readability-applescript/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 21:05:37 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[readability]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/?p=272</guid>
		<description><![CDATA[I&#8217;ve been using Readability for a while now and it&#8217;s an amazingly cool tool. I highly recommend it for anyone who reads anything online. In the interest of making things easier and more streamlined I&#8217;ve written an AppleScript that can load pages in Readability from various sources. The script is smart and &#8220;does the right [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://lab.arc90.com/experiments/readability/">Readability</a> for a while now and it&#8217;s an amazingly cool tool. I highly recommend it for anyone who reads anything online.</p>
<p>In the interest of making things easier and more streamlined I&#8217;ve written an AppleScript that can load pages in Readability from various sources. The script is smart and &#8220;does the right thing&#8221; based on which app you&#8217;re running. I&#8217;ve only had a need for it from Safari, NetNewsWire and Yojimbo so that&#8217;s all it&#8217;s setup for but it should be easy to extend if you want.</p>
<p>I&#8217;ve got the script hooked up to a shortcut using <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a>.</p>
<p><a href="/blog/wp-content/uploads/2010/02/View%20in%20Readability.scpt.zip">Direct download link</a></p>
<p>You will likely want to update the <code class="codecolorer applescript default"><span class="applescript">JS</span></code> variable to match your own Readability styling.</p>
<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;height:300px;"><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">(*<br />
<br />
View in Readability Script<br />
<br />
Matt Vanderpol<br />
1.0 - February 15, 2010<br />
<br />
Based largely on Adam Bell's code from http://macscripter.net/viewtopic.php?id=29702<br />
<br />
Supports Safari, NetNewsWire and Yojimbo (bookmarks and web archives. Shows the current<br />
web &quot;document&quot; with Readability (http://lab.arc90.com/experiments/readability/).<br />
<br />
Yojimbo needs to open the URL in Safari because I don't see a way to run JS inside Yojimbo.<br />
<br />
*)</span><br />
<br />
<span style="color: #ff0033; font-weight: bold;">global</span> gScript, gApplication<br />
<span style="color: #ff0033; font-weight: bold;">set</span> gScript <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;View in Readability Script&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> gApplication <span style="color: #ff0033; font-weight: bold;">to</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;">-- From: http://daringfireball.net/2009/01/applescripts_targetting_safari_or_webkit</span><br />
<span style="color: #ff0033; font-weight: bold;">on</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _currentApp <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033;">every</span> process <span style="color: #ff0033;">whose</span> frontmost <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> _currentApp<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> GetCurrentApp<br />
<br />
<span style="color: #ff0033; font-weight: bold;">set</span> JS <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;readStyle='style-newspaper';<br />
&nbsp; &nbsp; readSize='size-medium';<br />
&nbsp; &nbsp; readMargin='margin-wide';<br />
&nbsp; &nbsp; _readability_script=document.createElement('SCRIPT');<br />
&nbsp; &nbsp; _readability_script.type='text/javascript';<br />
&nbsp; &nbsp; _readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());<br />
&nbsp; &nbsp; document.getElementsByTagName('head')[0].appendChild(_readability_script);<br />
&nbsp; &nbsp; _readability_css=document.createElement('LINK');<br />
&nbsp; &nbsp; _readability_css.rel='stylesheet';<br />
&nbsp; &nbsp; _readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';<br />
&nbsp; &nbsp; _readability_css.type='text/css';<br />
&nbsp; &nbsp; _readability_css.media='all';<br />
&nbsp; &nbsp; document.getElementsByTagName('head')[0].appendChild(_readability_css);<br />
&nbsp; &nbsp; _readability_print_css=document.createElement('LINK');<br />
&nbsp; &nbsp; _readability_print_css.rel='stylesheet';<br />
&nbsp; &nbsp; _readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';<br />
&nbsp; &nbsp; _readability_print_css.media='print';<br />
&nbsp; &nbsp; _readability_print_css.type='text/css';<br />
&nbsp; &nbsp; document.getElementsByTagName('head')[0].appendChild(_readability_print_css);&quot;</span><br />
<br />
<br />
<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; <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;Success Notification&quot;</span>, <span style="color: #009900;">&quot;Failure Notification&quot;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> enabledNotificationsList <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;Success Notification&quot;</span>, <span style="color: #009900;">&quot;Failure Notification&quot;</span><span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; register <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">application</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; gScript all notifications allNotificationsList ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; default notifications enabledNotificationsList ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; icon <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> gApplication<br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<br />
<span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Safari&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">document</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do JavaScript</span> JS<br />
<span style="color: #ff0033; font-weight: bold;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;NetNewsWire&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">document</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;NetNewsWire&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">do JavaScript</span> JS<br />
<span style="color: #ff0033; font-weight: bold;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> gApplication <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #009900;">&quot;Yojimbo&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Yojimbo&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Can't use JS in Yojimbo so need to open in Safari and run script again</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _selection <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">selection</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> length <span style="color: #ff0033; font-weight: bold;">of</span> _selection <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #000000;">0</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Nothing Selected&quot;</span> description <span style="color: #009900;">&quot;No item selected to view in Readability from &quot;</span> <span style="color: #000000;">&amp;</span> gApplication ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _item <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> _selection<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> source URL <span style="color: #ff0033; font-weight: bold;">of</span> _item<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">on</span> <span style="color: #ff0033; font-weight: bold;">error</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> h_URL <span style="color: #ff0033; font-weight: bold;">to</span> location <span style="color: #ff0033; font-weight: bold;">of</span> _item<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> h_URL <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #ff0033;">not</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">activate</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">make</span> <span style="color: #0066ff;">new</span> <span style="color: #0066ff;">document</span> <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">properties</span> <span style="color: #000000;">&#123;</span>URL:h_URL<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">-- Now that document web page is open, call this script again to use readability</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delay <span style="color: #000000;">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> theUNIXPath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">path to</span> <span style="color: #0066ff;">me</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">alias</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> thePosixPath <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">POSIX path</span> <span style="color: #ff0033; font-weight: bold;">of</span> theUNIXPath<span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">run</span> <span style="color: #ff0033; font-weight: bold;">script</span> <span style="color: #000000;">&#40;</span>thePosixPath<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;No URL&quot;</span> description <span style="color: #009900;">&quot;Can't find URL to view in Readability from &quot;</span> <span style="color: #000000;">&amp;</span> gApplication ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;GrowlHelperApp&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; notify <span style="color: #ff0033; font-weight: bold;">with</span> <span style="color: #0066ff;">name</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Failure Notification&quot;</span> title ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&quot;Unknown Application&quot;</span> description <span style="color: #009900;">&quot;Don't know how to view in Readability from &quot;</span> <span style="color: #000000;">&amp;</span> gApplication ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066ff;">application</span> <span style="color: #0066ff;">name</span> gScript<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2010/02/15/view-in-readability-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Current Application with AppleScript</title>
		<link>http://vanderbrew.com/blog/2010/02/15/get-current-application-with-applescript/</link>
		<comments>http://vanderbrew.com/blog/2010/02/15/get-current-application-with-applescript/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 19:40:28 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/?p=264</guid>
		<description><![CDATA[My recent applescript development required different action based on what application was currently active. Surprisingly, there is no good result for this from google. I pulled this out of a Daring Fireball code example (Writing AppleScripts That Dynamically Target Either Safari or WebKit) and am showcasing it so that others who are looking for the [...]]]></description>
			<content:encoded><![CDATA[<p>My recent applescript development required different action based on what application was currently active. Surprisingly, there is no good result for this from google. I pulled this out of a <a href="http://daringfireball.net">Daring Fireball</a> code example (<a href="http://daringfireball.net/2009/01/applescripts_targetting_safari_or_webkit">Writing AppleScripts That Dynamically Target Either Safari or WebKit</a>) and am showcasing it so that others who are looking for the functionality can find it without too much effort.</p>
<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0033; font-weight: bold;">on</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> _app <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">item</span> <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#40;</span><span style="color: #ff0033;">every</span> process <span style="color: #ff0033;">whose</span> frontmost <span style="color: #ff0033; font-weight: bold;">is</span> <span style="color: #0066ff;">true</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> <span style="color: #0066ff;">name</span> <span style="color: #ff0033; font-weight: bold;">of</span> _app<br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> GetCurrentApp<br />
<br />
<span style="color: #ff0033; font-weight: bold;">set</span> _app <span style="color: #ff0033; font-weight: bold;">to</span> GetCurrentApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2010/02/15/get-current-application-with-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Marking Duplicate Web Archive Items in Yojimbo</title>
		<link>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/</link>
		<comments>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 22:15:50 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/</guid>
		<description><![CDATA[I saw Archive Flagged Items from NetNewsWire into Yojimbo (via) and found it a really neat tool. I&#8217;ve started using it to keep a more permanent record of interesting new articles. I have lots of news articles flagged and I&#8217;ve had the import crash on me before for various reasons which has resulted in some [...]]]></description>
			<content:encoded><![CDATA[<p>I saw <a href="http://snippets.dzone.com/posts/show/5001">Archive Flagged Items from NetNewsWire into Yojimbo</a> (<a href="http://ranchero.com/?comments=1&#038;postid=1801">via</a>) and found it a really neat tool. I&#8217;ve started using it to keep a more permanent record of interesting new articles.</p>
<p>I have lots of news articles flagged and I&#8217;ve had the import crash on me before for various reasons which has resulted in some duplicate web archives being created. The reason for the duplicates is usually because there was a redirect to the actual article that Yojimbo followed, so the URL in NetNewsWire doesn&#8217;t match the Yojimbo URL and checking for existing items on load doesn&#8217;t work.</p>
<p>This was a great opportunity for me to explore <a href="http://rubyosa.rubyforge.org/" title="RubyOSA: Ruby/AppleEvent Bridge">RubyOSA</a> and continue learning <a href="http://www.ruby-lang.org/" title="Ruby Programming Language">Ruby</a> so I wrote a script to detect duplicate web archives based on name and mark them with a &#8220;Duplicate&#8221; label.</p>
<p>[ruby]<br />
#!/usr/local/bin/ruby</p>
<p>require &#8216;rubygems&#8217;<br />
require &#8216;rbosa&#8217;</p>
<p>yojimbo = OSA.app(&#8216;Yojimbo&#8217;)</p>
<p>seen = Hash.new(false)</p>
<p># Duplicate label details<br />
duplicateLabelName = &#8216;Duplicate&#8217;<br />
# An almost painful red<br />
duplicateLabelColor = [65535, 1536, 4628]<br />
duplicateLabel = nil</p>
<p># See if we already have a label named &#8216;Duplicate&#8217; and save it<br />
yojimbo.labels.map  { |l| l.name == duplicateLabelName &#038;&#038; duplicateLabel = l }</p>
<p># Make a label if we don&#8217;t have it already<br />
if (duplicateLabel.nil?)<br />
  duplicateLabel = yojimbo.make(OSA::Yojimbo::Label,<br />
                                nil,<br />
                                :color => duplicateLabelColor,<br />
                                :name => duplicateLabelName)<br />
end</p>
<p>yojimbo.web_archive_items.each do |f|<br />
  if (seen.include?(f.name))<br />
    puts &#8220;Found a duplicate: #{f.name}&#8221;<br />
    f.label= duplicateLabel<br />
    seen[f.name].label= duplicateLabel<br />
  else<br />
    seen[f.name] = f<br />
  end<br />
end<br />
[/ruby]</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2008/02/02/marking-duplicate-web-archive-items-in-yojimbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Syntax Highlighting</title>
		<link>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/</link>
		<comments>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 14:31:24 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/</guid>
		<description><![CDATA[I&#8217;d like to start posting code on my blog so I&#8217;m testing out a syntax highlighter plugin. This post will likely go through several iterations as I see what it can do and how to do it. Here&#8217;s some ruby: [ruby] def addPages(urls) return false unless urls urls.each{ &#124;u&#124; @queue 2; i&#8211;) if (i % [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to start posting code on my blog so I&#8217;m testing out a syntax highlighter plugin. This post will likely go through several iterations as I see what it can do and how to do it.</p>
<p>Here&#8217;s some ruby:<br />
[ruby]<br />
def addPages(urls)<br />
	return false unless urls<br />
	urls.each{ |u| @queue << PageFactory.newPage(u) }<br />
	@queue.uniq! # Get rid of dupes.<br />
end<br />
[/ruby]</p>
<p>Here's some Perl:<br />
[perl]<br />
my @text = ( 'here', 'are', 'some', 'words' );<br />
my $offset = 0;<br />
print join(' ', map { choppedCase($_) } @text );</p>
<p># Convert a string to "ChOpPeD cAsE"<br />
sub choppedCase<br />
{<br />
	my $word = shift;<br />
	my @chars = split('', $word);<br />
	my $char_count = scalar(@chars);</p>
<p>	for (my $i = $offset; $i < $char_count; $i+=2)<br />
	{<br />
	    $chars[$i] = uc($chars[$i]);<br />
	}</p>
<p>	# Track odd length words so we constantly alternate in a string<br />
	if ($char_count % 2)<br />
	{<br />
		$offset = $offset == 0 ? 1 : 0;<br />
	}<br />
	return join('', @chars);<br />
}<br />
[/perl]</p>
<p>Here's some PHP<br />
[PHP]<br />
// Pattern to match the directory path that a file is in<br />
$dir_pattern = "@(/.*)/[^/]*$@";</p>
<p>// Take a path that's (possibly) relative to the directory that the script is executing in<br />
// and convert it to an absolute path.<br />
function absolutize($path)<br />
{<br />
	global $dir_pattern;</p>
<p>	// Only operate on paths that are relative<br />
	if (substr($path, 0, 1) == '.' &#038;&#038; preg_match($dir_pattern, $_SERVER['PHP_SELF'], $matches))<br />
		$path = implode('', array($matches[1], '/', $path));</p>
<p>	$path_bits = explode('/', $path);<br />
	$elms = array();<br />
	foreach ($path_bits as $bit)<br />
	{<br />
		if ($bit == '' || $bit == '.')<br />
			continue;<br />
		if ($bit == '..') {<br />
			array_pop($elms);<br />
			continue;<br />
		}<br />
		$elms[]= $bit;<br />
	}<br />
	// Push an empty string on top so that we get a leading / when we implode<br />
	array_unshift($elms, '');<br />
	return implode('/', $elms);<br />
}<br />
[/PHP]</p>
<p>I just realized that I've coded in all three of these languages this week - plus JavaScript (can't find a good sample to post).</p>
<p><b>Update</b><br />
JavaScript<br />
[javascript]<br />
// Add commas to a long number to make it more readable.<br />
// Currently only supports whole numbers.<br />
var addCommas = function(aNumber)<br />
{<br />
  // Convert our number to an array and reverse it so that<br />
  // we can easily work from most significant digits down<br />
  // to least significant<br />
  var bitsR = (aNumber.toString().split(&#8221;)).reverse();<br />
  for (var i = bitsR.length &#8211; 1; i>2; i&#8211;)<br />
    if (i % 3 == 0)<br />
      bitsR.splice(i, 0, &#8216;,&#8217;);<br />
  // Return our array with commas added back to the proper order<br />
  // for display on the screen.<br />
  return bitsR.reverse().join(&#8221;);<br />
};<br />
[/javascript]</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2008/01/26/testing-syntax-highlighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My First Rails Plugin &#8211; JavaScriptFunction</title>
		<link>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/</link>
		<comments>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/#comments</comments>
		<pubDate>Sat, 15 Jul 2006 20:33:53 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/</guid>
		<description><![CDATA[I&#8217;m working on a Rails app using RJS and Prototype Window Class. I needed to be able to return an anonymous JavaScript function in my RJS template but when passing it in a string to page.call it kept getting quoted and didn&#8217;t work right (as you would expect). I solved it by creating a JavaScriptFunction [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a Rails app using RJS and <a href="http://prototype-window.xilinus.com/">Prototype Window Class</a>. I needed to be able to return an anonymous JavaScript function in my RJS template but when passing it in a string to</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">page.call</div></div>
<p>it kept getting quoted and didn&#8217;t work right (as you would expect).</p>
<p>I solved it by creating a JavaScriptFunction class and helpers so that it&#8217;s easily usable in an RJS template. Browse the <a href="http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/">plugin</a> or install it:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;pre&gt;<br />
# With subversion<br />
./script/plugin install -x http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/<br />
<br />
# Without subversion<br />
./script/plugin install http://svn.vanderbrew.com/svn/repos/plugins/javascript_function/<br />
&lt;/pre&gt;</div></div>
<p>To use it, just do:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;pre&gt;<br />
page.call 'Dialog.confirm', &quot;New Thing - do you want to add it?&quot;, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { :windowParameters =&gt; { :width =&gt; 300 },<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :sokLabel =&gt; 'Yes',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :cancelLabel =&gt; 'No',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :buttonClass =&gt; 'myButtonClass',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :id =&gt; 'myDialogId',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :cancel =&gt; anonymous_javascript_function(:parameters =&gt; [&quot;win&quot;], <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:body =&gt; &quot;$('#{@element_id}').innerHTML = '#{escape_javascript @thing.name}'&quot;),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :sok =&gt; anonymous_javascript_function(:parameters =&gt; [&quot;win&quot;], <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:body =&gt; &quot;return true;&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&lt;/pre&gt;</div></div>
<p>It&#8217;s my first plugin so I&#8217;m open to any feedback you have about it. Please use the <a href="/blog/contact/">Contact form</a> to reach me.</p>
<p>Note &#8211; the keys</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">:sokLabel</div></div>
<p>and</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">:sok</div></div>
<p>shouldn&#8217;t have an &#8216;s&#8217; in the front for real implementation with the JS library &#8211; I did that to prevent an emoticon from appearing thanks to WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/15/my-first-rails-plugin-javascriptfunction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creative Writing vs Coding</title>
		<link>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/</link>
		<comments>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/#comments</comments>
		<pubDate>Sat, 15 Jul 2006 06:59:48 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Creativity]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/</guid>
		<description><![CDATA[So, as you probably noticed, my creative writing on the site has fallen off quite a bit lately. It seems that I can focus on creative writing or I can focus on coding, but I&#8217;m not so good at doing both at the same time. I&#8217;m going to be focusing on coding for the foreseeable [...]]]></description>
			<content:encoded><![CDATA[<p>So, as you probably noticed, my creative writing on the site has fallen off quite a bit lately. It seems that I can focus on creative writing or I can focus on coding, but I&#8217;m not so good at doing both at the same time.</p>
<p>I&#8217;m going to be focusing on coding for the foreseeable future because that&#8217;s where I want to allocate my time right now. I&#8217;ve got a big unfinished project in that arena and it&#8217;s time to make some progress on it, hopefully contributing back to the community as I go.</p>
<p>I hope to return to more consistent writing in the future and I&#8217;m sure that I&#8217;ll have the occasional line here and there but I don&#8217;t think that there will be very many for a few months. I&#8217;ve created a <a href="/blog/category/creativity/feed/">Creativity feed</a> and if you&#8217;re just visiting for the writing I encourage you to simply track that with your feed aggregator.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/14/creative-writing-vs-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; Edit In Place with Local Autocomplete</title>
		<link>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/</link>
		<comments>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/#comments</comments>
		<pubDate>Mon, 10 Jul 2006 00:12:40 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/</guid>
		<description><![CDATA[I purchased a copy of Chad Fowler&#8217;s excellent Rails Recipes recently. He&#8217;s got a few recipes dealing with edit in place and one about building local autocomplete. I pulled these recipes together into a single solution that gives me an edit in place with local autocomplete functionality. Rails Helper I created a couple Rails helper [...]]]></description>
			<content:encoded><![CDATA[<p>I purchased a copy of Chad Fowler&#8217;s excellent <a href="http://www.pragmaticprogrammer.com/titles/fr_rr/index.html">Rails Recipes</a> recently. He&#8217;s got a few recipes dealing with edit in place and one about building local autocomplete. I pulled these recipes together into a single solution that gives me an edit in place with local autocomplete functionality.</p>
<p><b>Rails Helper</b><br />
I created a couple Rails helper functions to encapsulate the functionality so I can call it with one function in my view. View the <a href="/Projects/InPlaceEditorWithAutocomplete/ruby/application_helper.rb">source</a>, with <a href="/Projects/InPlaceEditorWithAutocomplete/docs/application_helper_rb.html">syntax highlighting</a>.</p>
<p><b>JavaScript</b><br />
I had to extend the existing Scriptaculous code to support my specific functionality. View the <a href="/Projects/InPlaceEditorWithAutocomplete/javascript/in_place_editor_with_local_autocomplete.js">source</a>, with <a href="/Projects/InPlaceEditorWithAutocomplete/docs/in_place_editor_with_local_autocomplete_js.html">syntax highlighting</a>.</p>
<p><b>Implementation</b><br />
Now, you just include the JS in your page and use the new helper to build the UI component.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:600px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;pre&gt;<br />
&lt;%= in_place_editor_field_with_local_autocomplete :recipe,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :cookbook_title,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :catalog =&gt; 'cookbooks',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :fullSearch =&gt; true,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :frequency =&gt; 0,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :minChars =&gt; 2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
%&gt;<br />
&lt;/pre&gt;</div></div>
<p><b>Update</b><br />
Ola Bini has developed an <a href="http://opensource.ki.se/inplacecompleter.html">InPlaceEditor with Autocomplete</a> <a href="http://svn.ki.se/rails/plugins/in_place_completer/">plugin</a> for Rails. Definitely worth a look.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/07/09/rails-edit-in-place-with-local-autocomplete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;We found no matches for phil&apos;s phalse bottom. Below are results for pool.&#8221;</title>
		<link>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/</link>
		<comments>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/#comments</comments>
		<pubDate>Wed, 18 Jan 2006 03:45:03 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/</guid>
		<description><![CDATA[So, I was on Amazon yesterday, looking for a false bottom for making a lauter tun. I was awfully surprised to see that result. I&#8217;m guessing that it&#8217;s a perfect example of what can happen when suggestion code goes wrong, probably due to the combination of specific and uncommon search terms. Even more interesting is [...]]]></description>
			<content:encoded><![CDATA[<p>So, I was on Amazon yesterday, looking for a false bottom for making a <a href="http://www.northernbrewer.com/docs/html/sparging.html#id2847835">lauter tun</a>. I was awfully surprised to see that result. I&#8217;m guessing that it&#8217;s a perfect example of what can happen when suggestion code goes wrong, probably due to the combination of specific and uncommon search terms.</p>
<p>Even more interesting is the fact that I get this result when searching in the <a href="http://www.amazon.com/gp/browse.html/102-8458530-1577765?node=286168">Outdoor Living</a> area of Amazon&#8217;s site, but not when searching from the &#8220;homepage&#8221;. I guess that it&#8217;s just a testament to the complexity of the site and how segragated the functionality of different stores is.</p>
]]></content:encoded>
			<wfw:commentRss>http://vanderbrew.com/blog/2006/01/17/we-found-no-matches-for-phils-phalse-bottom-below-are-results-for-pool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

