<?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>Brett Terpstrasnow leopard page  - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/snow-leopard/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Tue, 22 May 2012 02:49:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Automated search and link text Service</title>
		<link>http://brettterpstra.com/automated-search-and-link-text-service/</link>
		<comments>http://brettterpstra.com/automated-search-and-link-text-service/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 23:52:15 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=961</guid>
		<description><![CDATA[<p>Update: Download link has been updated with a new Bing version. The Yahoo search API was sunset recently and the original service fails to work now. The new download will work for the time being… I’ve had this one laying around for a long time, so I thought I’d toss it out on the ‘net and see if anyone else&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/automated-search-and-link-text-service/">Automated search and link text Service</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Download link has been updated with a new Bing version. The Yahoo search API was sunset recently and the original service fails to work now. The new download will work for the time being…</p>

<p>I’ve had this one laying around for a long time, so I thought I’d toss it out on the ‘net and see if anyone else had a use for it. It’s actually really handy, and a big timesaver. It takes selected text and uses the Yahoo API to run a quick search for that term, and returns the result as a Markdown link. You can, of course, modify the output to any text-based markup (Rich Text links are a pain).</p>

<p>There’s a quick video of it in action in the full post, plus some extra info and a download link…</p>

<p><span id="more-961"></span></p>

<p>The Service is called “First Yahoo Link,” and does exactly that. In the video below, I just wrote out some random words that were pretty sure to have predictable search results. The more vague the search terms, the more unpredictable the result, obviously. I’m running the Service with the shortcut <code>CTRL-SHIFT-Y</code>, which I set in the Keyboard pane of the System Preferences. Here goes:</p>

<p><video width="480" height="270" controls="" autobuffer="autobuffer">
    <source src="http://cdn.brettterpstra.com/media/newfirstyahoolink2.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
    <source src="http://cdn.brettterpstra.com/media/newfirstyahoolink2.ogv"  type='video/ogg; codecs="theora, vorbis"'>
</video></p>

<p>The majority of the code is a Yahoo API wrapper for Ruby by <a href="http://premshree.livejournal.com/">Premshree Pillai</a>. I just shoved it into my Run Shell Script action in the Automator Workflow and built off of it. It just escapes your selected text, passes it to a Web search and then formats the first result in the returned array. There’s probably a lot more you could do with it, but I like its simplicity and relative speed. It’s definitely faster than flipping over to a browser, running a search and copying a link, coming back and pasting/formatting it manually.</p>

<p>Give it a shot, you never know, you just might like it.</p>

<p>Oh, and in case you haven’t been through this drill before, unzip the file, put the resulting <code>workflow</code> file in ~/Library/Services and then go into System Preferences &gt; Keyboard &gt; Keyboard Shortcuts and add a shortcut key for the “First Yahoo Link” service you should now have in there. Then just select text and hit your shortcut key (or pull it down in the Application &gt; Services menu). Done.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AutoLinkWebSearch.zip?9d7bd4" title="Download Auto-link Web Search (165)"><img src="http://brettterpstra.com/wp-content/images/serviceicon.jpg?9d7bd4" alt="download image for Auto-link Web Search" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AutoLinkWebSearch.zip?9d7bd4" title="Download Auto-link Web Search (165)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AutoLinkWebSearch.zip?9d7bd4" title="Download Auto-link Web Search (165)">Auto-link Web Search</a> — A Snow Leopard Service that takes selected text, runs a Bing search for it and returns the first result as a Markdown link around the original text. <a href="http://brettterpstra.com/automated-search-and-link-text-service/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/auto-link-text-service-updated/' rel='bookmark' title='Auto-link text service updated'>Auto-link text service updated</a></li>
<li><a href='http://brettterpstra.com/songza-lucky-link-service/' rel='bookmark' title='Songza Lucky Link Service'>Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/automated-search-and-link-text-service/">Automated search and link text Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/automated-search-and-link-text-service/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://cdn.brettterpstra.com/media/newfirstyahoolink2.ogv" length="853095" type="video/ogg" />
<enclosure url="http://cdn.brettterpstra.com/media/newfirstyahoolink2.mp4" length="2168040" type="video/mp4" />
		</item>
		<item>
		<title>Is your URL too short? Try our system, free!</title>
		<link>http://brettterpstra.com/is-your-url-too-short-try-our-system-free/</link>
		<comments>http://brettterpstra.com/is-your-url-too-short-try-our-system-free/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 15:00:05 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[launchbar]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[url shortener]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=899</guid>
		<description><![CDATA[<p>I was sifting through my previous blog after Jeffery Zeldman kindly sent a lot of visitors in that direction for some TextMate starter tips. Whilst milling around, I stumbled upon an old trick I used to use in Quicksilver (before I gave up on it1), but had forgotten about since. It’s a very simple little shell command which uses curl&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/is-your-url-too-short-try-our-system-free/">Is your URL too short? Try our system, free!</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/08/urlextender_system.jpg?9d7bd4" alt="URL Extender System" border="0" width="300" height="260" class="alignright noshadow" />I was sifting through my <a href="http://blog.circlesixdesign.com">previous blog</a> after Jeffery Zeldman kindly <a href="http://www.zeldman.com/2010/08/13/how-to-use-textmate/">sent a lot of visitors</a> in that direction for some <a href="http://blog.circlesixdesign.com/2007/01/02/digging-in-to-textmate/">TextMate starter tips</a>. Whilst milling around, I stumbled upon an <a href="http://blog.circlesixdesign.com/2007/10/19/reverse-shortened-urls-with-quicksilver/">old trick I used to use</a> in <a href="http://www.blacktree.com/">Quicksilver</a> (before I gave up on it<sup id="fnref:quicksilver"><a href="#fn:quicksilver" rel="footnote">1</a></sup>), but had forgotten about since.</p>

<p>It’s a very simple little shell command which uses <code>curl</code> to track down the destination of a shortened url (or any link with a redirect). It works with an assortment of services, including bit.ly, tinyurl.com, ow.ly, etc. It returns the destination address (the original url), and you can pass that on to whatever you like!</p>

<p><strong>Side note</strong>: I’ve been working on a little site called <a href="http://justthelinks.com">JustTheLinks</a> which makes liberal use of url-lengthening. It grabs all of your tweets from your home timeline which contain links, and creates a live-updated list with expanded urls and titles. It uses PHP’s curl to do the trick, so it’s the same concept. It’s “in-progress,” but feel free to check it out at <a href="http://justthelinks.com">http://justthelinks.com</a>!</p>

<p>Anyway, I decided to update the Quicksilver action and adapt it for some other uses. I’m happy to report that it’s still quite useful as a command line script, a LaunchBar action or a System Service. This post has code for all three, so take your pick!</p>

<p><span id="more-899"></span></p>

<p>The <code>curl</code> command in this script has two options specified, –I and –s. –I tells it to fetch only the headers of the requested URI, and the –s tells it to suppress error messages (silent). The result is a short response which contains the location of the redirect, which is piped to <code>awk</code>. We look for the line in the response containing “Location” and print the second field of that line, which is the destination url. Here are a few ways I thought of to put it to use:</p>

<h3>Terminal</h3>

<p>The first thing I did was whip up a shell script to run from the command line. Just create a text file wherever you keep scripts<sup id="fnref:scripts"><a href="#fn:scripts" rel="footnote">2</a></sup>, or make a new directory somewhere for it. Paste in the code below, and name it something that makes sense to you. I went with <code>follow</code>, because it’s following the redirect path, and <code>expand</code> was taken (and lengthen didn’t seem as much fun to type…). The script looks for a single argument, which would be the shortened url, and if it doesn’t receive one it tries the clipboard. So, if you already have the url in your clipboard, which is a pretty safe bet in this case, you can just run the script with no arguments.</p>

<div markdown=0>
<pre><code class="bash">
#!/bin/bash

if [ $# -eq 0 ]; then
  curl -Is `pbpaste` | awk &#x27;/Location/ { print $2 }&#x27;  
else
  curl -Is $1 | awk &#x27;/Location/ { print $2 }&#x27;
fi
</code></pre>
</div>

<h3>LaunchBar</h3>

<p>I heart <a href="http://www.obdev.at/products/launchbar/index.html" title="LaunchBar 5">LaunchBar</a>. Like Quicksilver, you can easily build “actions” for it that act on different types of input. This one just acts on text you paste or send to it, and assumes it’s going to be a shortened URL. After it lengthens it, it just displays the result as large popup text. If you wanted to, you could easily have it <code>open location</code> or whatever, but the whole point is just to see where you’re going, right?</p>

<p>This just goes into <code>~/Library/Application Support/LaunchBar/Actions</code> as a compiled AppleScript (scpt) file. Open AppleScript Editor and paste in the code below (or just <a href="applescript://com.apple.scripteditor?action=new&amp;script=on%20handle_string%28message%29%0A%09%0A%09tell%20application%20%22LaunchBar%22%0A%09%09set%20_res%20to%20do%20shell%20script%20%22curl%20%2DIs%20%22%20%26%20message%20%26%20%22%20%7C%20awk%20%27%2FLocation%2F%20%7B%20print%20%242%20%7D%27%22%0A%09%09display%20in%20large%20type%20_res%0A%09end%20tell%0A%09%0Aend%20handle_string">click here to open it automatically</a> in your editor). Save the file to the Actions folder and give it a name you’ll recognize. Mine’s called ‘Expand Shortened URL.scpt’. Clever, I know. Here’s the code:</p>

<div markdown=0>
<pre><code class="as">
on handle_string(message)

    tell application &quot;LaunchBar&quot;
        set _res to do shell script &quot;curl -Is &quot; &amp; message &amp; &quot; | awk &#x27;/Location/ { print $2 }&#x27;&quot;
        display in large type _res
    end tell

end handle_string
</code></pre>
</div>

<h3>Snow Leopard Service</h3>

<p>Lastly, here’s a System Service that you can run on selected text in any Cocoa application. I’ve previously posted a <a href="http://brettterpstra.com/a-system-service-for-to-url-shortening/">Service for shortening urls</a>, so here’s the opposite. This one can actually take a whole block of text and will scan for any and all links in it, attempting to lengthen and replace any shortened urls in the text. Here’s how to build it:</p>

<ul>
<li>Open Automator.app</li>
<li>Select “Service” from the new file menu</li>
<li>Set “Service receives selected” to “text” in “any application”</li>
<li>Check the “Replaces selected text” box</li>
<li>Find the “Run Shell Script” action on the left and drag it into your workflow on the right</li>
<li>Set the Shell to Ruby (in this case)</li>
<li>Paste in the code below</li>
<li>Save the file to the <code>~/Library/Services</code> folder, named something like “Expand shortened urls in selection” (or something more interesting)</li>
</ul>

<p>Now, when you select text in any Cocoa application (Safari, Mail, TextEdit, etc.), you’ll be able to find your Service in the Services submenu of either the application menu in the menubar, or in the contextual menu that comes up when you right click (ctrl-click) the selected text. When you run it, it will replace your text with a new version with any shortened urls in it expanded.</p>

<div markdown=0>
<pre><code class="ruby">
#!/usr/bin/env ruby -rjcode -Ku

require &#x27;open-uri&#x27;

input = STDIN.read
links = input.scan(/\b((?:https?:\/\/)(?:www\.)?([^\/]+)\/[a-zA-Z0-9]+[^\s`!()\[\]{};:&#x27;&quot;.,&lt;&gt;?&laquo;&raquo;&ldquo;&rdquo;&lsquo;&rsquo;])/im)
links.each {|link|
  result = %x{curl -Is #{link[0]} | awk &#x27;/Location/ { print $2 }&#x27;}
  input = input.gsub(/#{link[0]}/,result.strip)
}
print input
</code></pre>
</div>

<p>How often will you need any of these little experiments? Probably not very often. Most of the time, I’m more than happy to just follow a shortened link and trust that the description it came with will hold true. Every once in a while, though, I come across a link of unknown origin that I’d prefer to run through something like this. Hopefully you’ll be able to find a use for it, too. It’s a cool little snippet.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:quicksilver">
<p>Sorry, Quicksilver fans. It used to be my absolute, must-have, favorite thing in the world, but it got too crashy on Snow Leopard, and then development just kind of died. <a href="http://www.obdev.at/products/launchbar/index.html" title="LaunchBar 5">LaunchBar</a> is way better these days. <a href="#fnref:quicksilver" rev="footnote">↩</a></p>
</li>

<li id="fn:scripts">
<p>I keep a ‘scripts’ folder in my home directory (~/scripts) and put that in my PATH environment variable in my .bash_profile. Then, I can run my scripts from anywhere but don’t have to muck around in <code>/usr/local/bin</code> or any such thing. <a href="#fnref:scripts" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/a-system-service-for-to-url-shortening/' rel='bookmark' title='A System Service for to. url shortening'>A System Service for to. url shortening</a></li>
<li><a href='http://brettterpstra.com/launchbar-actions-for-url-encoding-and-decoding/' rel='bookmark' title='LaunchBar actions for url encoding and decoding'>LaunchBar actions for url encoding and decoding</a></li>
<li><a href='http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/' rel='bookmark' title='A better System Service for Evernote clipping — with MultiMarkdown'>A better System Service for Evernote clipping — with MultiMarkdown</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/is-your-url-too-short-try-our-system-free/">Is your URL too short? Try our system, free!</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/is-your-url-too-short-try-our-system-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EverSave revisited, now with session restore!</title>
		<link>http://brettterpstra.com/eversave-revisited-now-with-session-restore/</link>
		<comments>http://brettterpstra.com/eversave-revisited-now-with-session-restore/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 01:50:46 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[System Service]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=744</guid>
		<description><![CDATA[<p>Safari 5 has brought several solutions for managing lists of open tabs, from the simple (like my TabLinks extension) to full session-management capabilities (see the beautiful Sessions extension). However, I’ve found I still like using my EverSave script in many situations, primarily because it allows me to annotate, tag and sync my important sessions for later retrieval. One thing’s been&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/eversave-revisited-now-with-session-restore/">EverSave revisited, now with session restore!</a></p>]]></description>
			<content:encoded><![CDATA[<p>Safari 5 has brought several solutions for managing lists of open tabs, from the simple (like my <a href="http://brettterpstra.com/2010/06/18/tablinks-safari-extension/">TabLinks extension</a>) to full session-management capabilities (see the beautiful <a href="http://dl.dropbox.com/u/8247646/sessions/index.html">Sessions extension</a>). However, I’ve found I still like using my <a href="http://brettterpstra.com/2010/03/06/saving-safari-browsing-sessions-to-evernote/">EverSave script</a> in many situations, primarily because it allows me to annotate, tag and sync my important sessions for later retrieval. One thing’s been bugging me, though, and that’s the inability to do a mass restore on a tab list (i.e. open them all at once).</p>

<p>When I decided to fix this, the first issue was that when EverSave creates the Evernote note, it lets Evernote convert the list from HTML to Rich Text. Once it’s stored in Rich Text Format (RTF), manipulating it via any shell language, including AppleScript, becomes quite difficult. It’s not impossible, but I quickly decided it wasn’t a route I wanted to wander down. Here’s what I <strong>did</strong> do…
<span id="more-744"></span></p>

<h3>Saving tabs to Evernote</h3>

<p>What I ended up doing was modifying what EverSave stored, and including the actual URL in the visible text of the note. It’s not the prettiest solution, but it’s the only way that this particular system will work. I did my best to minimize the visual presence of the URL using the rudimentary markup that Evernote actually pays attention to. The final product looks like this:</p>

<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/EverSaveRevisedBookmarks1.jpg?9d7bd4" alt="EverSaveRevisedBookmarks.jpg" border="0" width="650" height="93" /></p>

<p>The actual layout is still fully controlled by the _template property in the first line, which is the only line that’s changed from the original script. I’m posting the whole thing again, with this minor revision, for convenience. With a little bit of HTML (remember to escape your double quotes), you can modify the template to look however you like. Just keep in mind that Evernote strips 90% of markup out when it creates the note from your HTML, so stick with basic tags. See the <a href="http://brettterpstra.com/2010/03/06/saving-safari-browsing-sessions-to-evernote/">original EverSave post</a> for a breakdown of the script.</p>

<p>Be sure to continue reading after the script to see how we handle the “restore” functionality.</p>


<div class="wp_syntax"><div class="code"><pre class="applescript"><span class="kw3">property</span> _template : <span class="st0">&quot;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;</span><span class="re0">%url</span><span class="st0">&quot;&gt;&amp;uArr;&lt;/a&gt; %name&lt;/strong&gt; &lt; &lt;small&gt;%url&lt;/small&gt; &gt;&quot;</span>
&nbsp;
<span class="co1">--search and replace function for template</span>
<span class="kw3">on</span> snr<span class="br0">&#40;</span>tofind, toreplace, TheString<span class="br0">&#41;</span>
	<span class="kw3">set</span> ditd <span class="kw3">to</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span>
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> tofind
	<span class="kw3">set</span> textItems <span class="kw3">to</span> <span class="kw1">text</span> <span class="kw1">items</span> <span class="kw3">of</span> TheString
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> toreplace
	<span class="kw3">if</span> <span class="br0">&#40;</span>class <span class="kw3">of</span> TheString <span class="kw3">is</span> <span class="kw1">string</span><span class="br0">&#41;</span> <span class="kw3">then</span>
		<span class="kw3">set</span> res <span class="kw3">to</span> textItems <span class="kw2">as</span> <span class="kw1">string</span>
	<span class="kw3">else</span> <span class="co1">-- if (class of TheString is Unicode text) then</span>
		<span class="kw3">set</span> res <span class="kw3">to</span> textItems <span class="kw2">as</span> Unicode <span class="kw1">text</span>
	<span class="kw3">end</span> <span class="kw3">if</span>
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> ditd
	<span class="kw3">return</span> res
<span class="kw3">end</span> snr
&nbsp;
<span class="kw3">set</span> prettyDate <span class="kw3">to</span> <span class="kw1">do shell script</span> <span class="st0">&quot;date '+%A, %B %d, %Y at %l:%M %p'&quot;</span>
<span class="kw3">set</span> theTitle <span class="kw3">to</span> <span class="st0">&quot;Bookmarks &quot;</span> <span class="sy0">&amp;</span> prettyDate
<span class="kw3">set</span> urlList <span class="kw3">to</span> <span class="st0">&quot;&lt;ul&gt;&quot;</span>
&nbsp;
<span class="kw3">tell</span> <span class="kw1">application</span> <span class="st0">&quot;Safari&quot;</span>
	<span class="kw3">set</span> tabList <span class="kw3">to</span> <span class="kw2">every</span> <span class="kw1">tab</span> <span class="kw3">of</span> <span class="kw2">front</span> <span class="kw1">window</span>
	<span class="kw3">repeat</span> <span class="kw3">with</span> aTab <span class="kw3">in</span> tabList
		<span class="kw3">set</span> aLink <span class="kw3">to</span> _template
		<span class="kw3">set</span> aLink <span class="kw3">to</span> <span class="kw3">my</span> snr<span class="br0">&#40;</span><span class="st0">&quot;%name&quot;</span>, <span class="kw1">name</span> <span class="kw3">of</span> aTab, aLink<span class="br0">&#41;</span>
		<span class="kw3">set</span> aLink <span class="kw3">to</span> <span class="kw3">my</span> snr<span class="br0">&#40;</span><span class="st0">&quot;%url&quot;</span>, URL <span class="kw3">of</span> aTab, aLink<span class="br0">&#41;</span>
		<span class="kw3">set</span> urlList <span class="kw3">to</span> urlList <span class="sy0">&amp;</span> aLink <span class="sy0">&amp;</span> <span class="kw3">return</span>
	<span class="kw3">end</span> <span class="kw3">repeat</span>
<span class="kw3">end</span> <span class="kw3">tell</span>
<span class="kw3">set</span> urlList <span class="kw3">to</span> urlList <span class="sy0">&amp;</span> <span class="st0">&quot;&lt;/ul&gt;&quot;</span>
&nbsp;
<span class="kw3">tell</span> <span class="kw1">application</span> <span class="st0">&quot;Evernote&quot;</span>
	<span class="kw3">set</span> theNote <span class="kw3">to</span> create note <span class="kw3">with</span> html urlList title theTitle notebook <span class="st0">&quot;Bookmarks&quot;</span>
<span class="kw3">end</span> <span class="kw3">tell</span></pre></div></div>


<p>I have this script saved as “EverSave.scpt” in my <code>~/Library/Scripts/Applications/Safari</code> folder (create it if you don’t have it), and launch it using <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> with a Command-Shift-S shortcut. Safari doesn’t have anything bound to that key-combo, and it’s easy to remember (Save As in most programs).</p>

<h3>Restoring tabs</h3>

<p>This solution makes a few assumptions, but the script is easily customized to handle any differences in your setup. I went with a System Service (Snow Leopard) for the restore function, primarily because it allows me to act directly on selected text in Evernote. It’s a very simple Ruby script that parses the selected text for urls, and then opens any that it finds in sequential order using your default browser. There’s a commented out line if you want to always target Safari directly when opening them, which may be useful in some situations. I use <a href="http://www.choosyosx.com/">Choosy</a>, and have a rule that just directs all of these to Safari. If you have Safari set as your default browser, and that’s where you want to open your links, this will just work as is.</p>

<p>To set up the service:</p>

<ol>
<li>Open Automator and select “Service” as the new file type.</li>
<li>On the right hand side, tell it that “Service receives selected” <strong><em>text</em></strong> in <strong><em>Evernote.app</em></strong> (choose Other… and select Evernote).</li>
<li>Find “Run Shell Script” in the list on the left and drag it into the area on the right.</li>
<li>Set the Shell dropdown to /usr/bin/ruby</li>
<li>Insert the following code, and feel free to modify</li>
<li>Save the result as “EverRestore”</li>
<li>Assign a shortcut key, if desired, in System Preferences &gt; Keyboard &gt; Keyboard Shortcuts &gt; Services</li>
</ol>

<p>Here’s the code for the service:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">ARGF.<span class="me1">each</span> <span class="kw1">do</span> <span class="sy0">|</span>f<span class="sy0">|</span>
    links = f.<span class="me1">scan</span> <span class="sy0">/&lt;</span> <span class="br0">&#40;</span>https?:<span class="sy0">//</span>.<span class="sy0">*</span>?<span class="br0">&#41;</span> <span class="sy0">&gt;/</span>mi
    <span class="co1"># The above scans specifically for the angle brackets in my template. </span>
    <span class="co1"># If you remove those from the output of EverSave, be sure to update</span>
    <span class="co1"># the regular expression accordingly.</span>
    <span class="kw1">if</span> links.<span class="me1">empty</span>? <span class="kw1">then</span>
        <span class="kw3">exit</span>
    <span class="kw1">else</span>
        links.<span class="me1">each</span> <span class="br0">&#123;</span><span class="sy0">|</span>link<span class="sy0">|</span> <span class="sy0">%</span>x<span class="br0">&#123;</span>osascript <span class="sy0">-</span>e <span class="sy0">&amp;</span><span class="co1">#x27;open location &quot;#{link[0]}&quot;&amp;#x27;}}</span>
        <span class="co1"># links.each {|link| %x{osascript -e &amp;#x27;tell application &quot;Safari&quot; to open location &quot;#{link[0]}&quot;&amp;#x27;} }</span>
    <span class="kw1">end</span>
<span class="kw1">end</span></pre></div></div>


<p>The simple regular expression in line 2 does scan specifically for the angle brackets I used in the new EverSave template. That just relieves some complexity. If you want a regular expression that doesn’t require the angle brackets, try replacing line 2 with this:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">links = f.<span class="me1">scan</span> <span class="sy0">/</span><span class="br0">&#40;</span>https?:<span class="sy0">//</span><span class="br0">&#40;</span><span class="br0">&#91;</span>^s<span class="st0">&quot;,;]+)..{2,4}(/[^s&quot;</span>,;!<span class="br0">&#93;</span><span class="sy0">+</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">/</span>mi</pre></div></div>


<p>Once it’s saved in Automator, it should be available when you select text in Evernote. If there are visible URLs in the selected text, running this Service will open them in tabs in Safari (or your default browser). You can selectively open certain urls by only selecting the lines that contain the ones you want to open. Non-contiguous selections will require a little text editing, of course.</p>

<h3>Not as hard as it looks… really.</h3>

<p>The explanation got a little long, and probably seems unnecessarily complex. The fact is, I can save a Safari browsing session with one key combo, edit, annotate and tag it (if I want to), then restore it later by highlighting and typing a new command combination. It’s actually quite convenient, and fairly bulletproof. I’d love to hear how you use it, or what you’re doing instead!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/' rel='bookmark' title='Clippable to Evernote Snow Leopard Service'>Clippable to Evernote Snow Leopard Service</a></li>
<li><a href='http://brettterpstra.com/save-safari-tabs-to-instapaper/' rel='bookmark' title='Save Safari tabs to Instapaper'>Save Safari tabs to Instapaper</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/eversave-revisited-now-with-session-restore/">EverSave revisited, now with session restore!</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/eversave-revisited-now-with-session-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextExpander experiments</title>
		<link>http://brettterpstra.com/textexpander-experiments/</link>
		<comments>http://brettterpstra.com/textexpander-experiments/#comments</comments>
		<pubDate>Sat, 08 May 2010 02:48:15 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[textexpander]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=406</guid>
		<description><![CDATA[<p>A few unique tools and scripts for TextExpander to work with Markdown, url shorteners and some basic string operations.</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-experiments/">TextExpander experiments</a></p>]]></description>
			<content:encoded><![CDATA[<p>I’ve seen a few people around the ‘net sharing their <a href="http://smileonmymac.com/TextExpander/">TextExpander</a> snippets, so I thought I’d join in. Not familiar with TextExpander? It’s a Mac utility that expands short snippets into full text you’ve defined. There are quite a few programs that do text expansion (see <a href="http://www.ergonis.com/products/typinator/">Typinator</a>), but TextExpander currently holds my heart because of its extra features such as shell scripting, completion suggestion and a new Fill dialog for variable input.</p>

<p>Most of my snippets are specific only to me, such as email signoffs and abbreviations for companies I work for. I have a few more general snippets, though, so that’s what I’m sharing. For reference, I’m currently experimenting with triggering only after a Tab press, a la TextMate tab-triggers. That shouldn’t make a difference on many of these, they should work with whatever you have set up.</p>

<p>All of the snippets I’m sharing are <a href="#downloadlink">available for download</a>. For more detail, read on…</p>

<p><span id="more-406"></span></p>

<h4>Lorem Ipsum</h4>

<p>First, there are the Lipsums. This is a collection of my most-used <a href="http://www.lipsum.com/">Lorem Ipsum</a> snippets, great for filling in fields when testing forms, making quick HTML markup for CSS styling, or anywhere you just need to fill up some space. I have snippets for 1, 2, and 3 paragraphs of standard Lorem Ipsum text, as well as a few for HTML-specific lipsum. The king of these is a snippet I pulled from  <a href="http://html-ipsum.com/">http://html-ipsum.com/</a> that inserts all of the major elements of HTML markup. It’s great for giving your CSS stylesheet a quick test to make sure you’ve covered the basics.</p>

<p>The Tools collection is a sampling of scripts and snippets, some more useful than others, that I’ve been experimenting with (and, in some cases, making good use of). Some examples:</p>

<h4>Hyphenate clipboard</h4>

<p>I tend to write out very long, multi-word modifiers that need hyphenation. While it’s more effective to use a System Service, I’ve found that the Automator services are too slow for such simple operations. So I cut the needs-to-be-hyphenated text to the clipboard and type „-. When I hit tab, the hyphenated version is pasted, with proper attention to punctuation and leading/trailing spaces. It looks like this:</p>

<pre><code>#!/usr/bin/env ruby -wKU

# get the clipboard using pbpaste
clip = %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste}
# print it out, hyphenated
print clip.gsub(/\b\s\b/,'-')
</code></pre>

<h4>Encode email address</h4>

<p>This one takes an email address from the clipboard and returns a “mailto:” link with the email address itself encrypted, at least to the point where it’s not human readable anymore.</p>

<pre><code>#!/usr/bin/env ruby -wKU

clipboard = %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste}.strip
print "mailto:#{$2.gsub(/./) {sprintf("&amp;#x%02X;", $&amp;.unpack("U")[0])}}" if clipboard =~ /\A(mailto:)?(.*?@.*\..*)\z/
</code></pre>

<h4>Paste Markdown references</h4>

<p>This one parses the clipboard for any and all urls, pasting the resulting matches as a <a href="http://daringfireball.net/projects/markdown/">Markdown</a> reference list. It automatically names the references based on the url’s domain, strips duplicate urls and sorts the list alphanumerically by reference name. If the clipboard is already a reference list, it will sort it and remove duplicates before pasting it. You can then use the references in your Markdown to link to the associated URL, or just make the list look nice in an email or other non-rendered document.</p>

<pre><code>#!/usr/bin/env ruby -rjcode -Ku
clipboard = %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste}.strip
links = clipboard.scan /(?:\[([^\]]+)\]\: )?(https?:\/\/[^ \n\r"]+)/m
norepeat = []
output = []
exit if links.nil?

links.each {|url|
  fresh = true
  output.each {|a|
    fresh = false if a['link'] == url[1]
  }
  next unless fresh

    if url[0].nil?
        domain = url[1].match(/https?:\/\/([^\/]+)/)
        parts = domain[1].split('.')
        name = case parts.length
            when 1,2: parts[0]
            else parts[1]
        end
    else
        name = url[0]
    end

  name = "itunes" if url[1] =~ /(itunes|phobos).apple.com/

    while norepeat.include? name
        name = name =~ / ?[0-9]$/ ? name.next! : name = name + " 2"
    end
    output &lt;&lt; {'title' =&gt; name, 'link' =&gt; url[1] }
    norepeat.push name
}

output.sort {|a,b| a['title'] &lt;=&gt; b['title']}.each { |x| puts "[#{x['title']}]: #{x['link']}" }
</code></pre>

<h4>Shortening URLs</h4>

<p>There are 4 commands in the group for shortening URLs, using bit.ly, go., is.gd and tinyurl, respectively. There are some AppleScript-based commands already available which do this, but I like the string-handling flexibility of Ruby a little better (and it processes a tiny bit quicker, as well).</p>

<p>The basic command looks like this, with slight differences for each service:</p>

<pre><code>#!/usr/bin/env ruby -wKU

require 'open-uri'
require 'cgi'

def entity_escape(text)
  text.gsub(/&amp;(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)/, '&amp;amp;')
end

def make_link(text)
  case text
  when %r{\Ahttps?://.*?\.\w{2,4}.*?\z}:
    entity_escape(text)
  when %r{\A(www\..*|.*\.\w{2,4})\z}:
    "http://#{entity_escape text}"
  when %r{\A.*?\.\w{2,4}\/?.*\z}:
    "http://#{entity_escape text}"
  else
    nil
  end
end


url = make_link %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste}.strip

print open("http://bit.ly/api?url=#{CGI.escape(url)}").read unless url.nil?
</code></pre>

<p>I’ll stop there for now. The Tools set also contains:</p>

<ul>
<li><p><strong>Clipboard HTML link</strong></p>

<p>Makes an html hyperlink (code, not rich text) from a url in the clipboard. Uses the Fill feature to request the link text.</p></li>
<li><p><strong>Markdown Link</strong></p>

<p>Makes a Markdown format link from a url in the clipboard. Uses the Fill feature to request the link text.</p></li>
<li><p><strong>Rounded Corners</strong></p>

<p>Uses the Fill feature to request a pixel radius, and creates cross-browser CSS for rounded corners. There are 5 variations, one for each corner and one for all corners.</p></li>
<li><p><strong>CSS Reset</strong></p>

<p>Your typical CSS reset code, in Meyers and YUI flavors.</p></li>
<li><p><strong>Make URL</strong></p>

<p>Take whatever text is in the clipboard and provide a best-guess URL for it. Handy if you have a qualified domain and just need the protocol added, or if you have an email address and want it to be a mailto: link.</p></li>
<li><p><strong>Hashbang</strong></p>

<p>Instant hashbangs for ruby, osascript and bash.</p></li>
</ul>

<p>Feel free to download, explore and improve!</p>

<p><a id="downloadlink">
<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/TextExpanderBrett1.1.zip?9d7bd4" title="Download TextExpander Snippets (1897)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/textexpandericon.png?9d7bd4" alt="download image for TextExpander Snippets" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/TextExpanderBrett1.1.zip?9d7bd4" title="Download TextExpander Snippets (1897)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/TextExpanderBrett1.1.zip?9d7bd4" title="Download TextExpander Snippets (1897)">TextExpander Snippets</a> — A collection of TextExpander snippets including lots of Lipsum, improved URL shortening and other useful scripts. <a href="http://brettterpstra.com/2010/05/07/textexpander-experiments/">More Info</a></p></div></p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/' rel='bookmark' title='Markdown snippets for TextExpander touch'>Markdown snippets for TextExpander touch</a></li>
<li><a href='http://brettterpstra.com/textexpander-bit-ly-with-authentication/' rel='bookmark' title='TextExpander: bit.ly with authentication'>TextExpander: bit.ly with authentication</a></li>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-experiments/">TextExpander experiments</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textexpander-experiments/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>A System Service for to. url shortening</title>
		<link>http://brettterpstra.com/a-system-service-for-to-url-shortening/</link>
		<comments>http://brettterpstra.com/a-system-service-for-to-url-shortening/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 02:03:48 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[System Service]]></category>
		<category><![CDATA[url shortener]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=399</guid>
		<description><![CDATA[<p>I’m fascinated by http://to. It’s a url shortener with no TLD. Some browsers, and apparently some DNS setups, don’t like the urls it creates (they want a .com or .org or anything at the end), so it’s not exactly in heavy usage. Still, I wish they had an API. In lieu of that, here’s a quick Ruby script that will&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-system-service-for-to-url-shortening/">A System Service for to. url shortening</a></p>]]></description>
			<content:encoded><![CDATA[<p>I’m fascinated by <a href="http://to.">http://to</a>. It’s a url shortener with no <acronym title="Top Level Domain">TLD</acronym>. Some browsers, and apparently some DNS setups, don’t like the urls it creates (they want a .com or .org or <em>anything</em> at the end), so it’s not exactly in heavy usage. Still, I wish they had an API. In lieu of that, here’s a quick Ruby script that will run on a stock OS X install as a System Service. It’s so simple that I’m not even going to package it up… It’ll be a good chance to show the steps for creating your own utilities using <a href="http://macosautomation.com/services/index.html">Snow Leopard Services</a>:</p>

<ul>
<li>Open Automator and choose “Service” from the first menu.</li>
<li>Tell it that the service “receives text” in “any application”. </li>
<li>Drag the “Run Shell Script” action from the left side. </li>
<li>Set the Shell to Ruby</li>
<li>Paste in the code below (or something of your own, hopefully far more interesting)</li>
<li>Save it with an intuitive name</li>
<li>Use it.</li>
</ul>


<div class="wp_syntax"><div class="code"><pre class="ruby"><span class="kw3">require</span> <span class="st0">'net/http'</span>
<span class="kw3">require</span> <span class="st0">'cgi'</span>
&nbsp;
input = STDIN.<span class="me1">read</span>
http = <span class="re2">Net::HTTP</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">'to.'</span><span class="br0">&#41;</span>
path = <span class="st0">'/'</span>
&nbsp;
data = <span class="st0">&quot;url=#{CGI.escape(input.strip)}&quot;</span>
headers = <span class="br0">&#123;</span><span class="st0">'Content-Type'</span> <span class="sy0">=&gt;</span> <span class="st0">'application/x-www-form-urlencoded'</span><span class="br0">&#125;</span>
&nbsp;
resp, data = http.<span class="me1">post</span><span class="br0">&#40;</span>path, data, headers<span class="br0">&#41;</span>
&nbsp;
<span class="kw1">if</span> resp.<span class="me1">code</span>.<span class="me1">to_i</span> == <span class="nu0">200</span>
  <span class="kw3">print</span> data.<span class="kw3">split</span><span class="br0">&#40;</span><span class="sy0">/</span>value=<span class="st0">&quot;/)[1].split(/&quot;</span><span class="sy0">/</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>
<span class="kw1">else</span>
  <span class="kw3">print</span> input
<span class="kw1">end</span></pre></div></div>


<p>Basically, anything you can do to or with text or files using a major scripting language, you can make into a Snow Leopard service. Now that I’ve set the bar this low, I’d love to see what new Services everyone else is cooking up!</p>

<p><strong>Update:</strong> <del datetime="2010-04-29T03:34:55+00:00">Yeah, that didn’t work out so well. It works sometimes, but leaves url parameters in the shortened url half the time. I haven’t figured out why, but I’ll leave it up and see if someone can point out the error of my ways…</del><ins datetime="2010-04-29T03:34:55+00:00">Fixed it, just neglected to notice it needed a POST, not a GET</ins></p>

<p><strong>Update 2:</strong> Here, this one’s shorter and more useful :)</p>


<div class="wp_syntax"><div class="code"><pre class="ruby"><span class="kw3">require</span> <span class="st0">'open-uri'</span>
<span class="kw3">require</span> <span class="st0">'cgi'</span>
&nbsp;
input = STDIN.<span class="me1">read</span>
<span class="kw3">print</span> <span class="kw3">open</span><span class="br0">&#40;</span><span class="st0">&quot;http://is.gd/api.php?longurl=#{CGI.escape(input.strip)}&quot;</span><span class="br0">&#41;</span>.<span class="me1">read</span></pre></div></div>

<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/is-your-url-too-short-try-our-system-free/' rel='bookmark' title='Is your URL too short? Try our system, free!'>Is your URL too short? Try our system, free!</a></li>
<li><a href='http://brettterpstra.com/textexpander-bit-ly-with-authentication/' rel='bookmark' title='TextExpander: bit.ly with authentication'>TextExpander: bit.ly with authentication</a></li>
<li><a href='http://brettterpstra.com/textexpander-experiments/' rel='bookmark' title='TextExpander experiments'>TextExpander experiments</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-system-service-for-to-url-shortening/">A System Service for to. url shortening</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/a-system-service-for-to-url-shortening/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compress PDFs with Preview</title>
		<link>http://brettterpstra.com/compress-pdfs-with-preview/</link>
		<comments>http://brettterpstra.com/compress-pdfs-with-preview/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 20:15:25 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mactips]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=388</guid>
		<description><![CDATA[<p>It’s probably old news to most, but I just realized this today. Since Leopard, OS X’s multi-talented Preview.app can compress needlessly large PDF’s in a matter of seconds. My clients (and today, my mother) often export PDF’s from various programs that don’t flatten or compress images, ending up with files between 8M and 90M, in my experience. Obviously, when you’re&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/compress-pdfs-with-preview/">Compress PDFs with Preview</a></p>]]></description>
			<content:encoded><![CDATA[<p>It’s probably old news to most, but I just realized this today. Since Leopard, OS X’s multi-talented Preview.app <a href="http://docs.info.apple.com/article.html?path=Mac/10.5/en/9021.html">can compress needlessly large PDF’s</a> in a matter of seconds. My clients (and today, my mother) often export PDF’s from various programs that don’t flatten or compress images, ending up with files between 8M and 90M, in my experience. Obviously, when you’re building a website, you want to get filesize down as much as possible. I’ve always used Acrobat to shrink these, usually reducing the size to about 15% of the original. Here’s how to do it with just Preview, which is included with your Mac OS:</p>

<p><img style=' display: block; margin-right: auto; margin-left: auto;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/04/PreviewAppReduceFilesize.jpg?9d7bd4" alt="Preview.app Reduce File Size Screenshot" title="Preview.app Reduce File Size" width="400" height="167" class="aligncenter size-full wp-image-389" /></p>

<ul>
<li>Open the original PDF in Preview. If Preview is your default PDF application, just double-click the file, otherwise, right-click (control-click) and Open with… Preview.app.</li>
<li>Choose File -&gt; Save As…</li>
<li>Give the file a new name; I usually append _r to the filename.</li>
<li>Before you save, pull down the Quartz Filter menu at the bottom of the dialog and choose “Reduce File Size” from the options.</li>
<li>Save your file, and enjoy the slimmed-down version.</li>
</ul>

<p>Compressing PDF’s causes very, very little quality loss, and can make emailing or downloading PDF’s much less troublesome. If you’re not compressing your PDF’s before you share them, you should!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/marked-is-on-the-mac-app-store/' rel='bookmark' title='Marked is on the Mac App Store'>Marked is on the Mac App Store</a></li>
<li><a href='http://brettterpstra.com/scrivwatcher-droplet-an-easier-live-scrivener-preview/' rel='bookmark' title='ScrivWatcher droplet, an easier live Scrivener preview'>ScrivWatcher droplet, an easier live Scrivener preview</a></li>
<li><a href='http://brettterpstra.com/preview-a-full-scrivener-document-in-marked-live/' rel='bookmark' title='Preview a full Scrivener document in Marked, live'>Preview a full Scrivener document in Marked, live</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/compress-pdfs-with-preview/">Compress PDFs with Preview</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/compress-pdfs-with-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated: Songza Lucky Link Service</title>
		<link>http://brettterpstra.com/updated-songza-lucky-link-service/</link>
		<comments>http://brettterpstra.com/updated-songza-lucky-link-service/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:25:25 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[songza]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=338</guid>
		<description><![CDATA[<p>Songza.fm has moved to Songza.org, so I’ve rewritten the old Songza Lucky Link Service for Snow Leopard to match. This new version of the service runs without dependencies, so it should work for any Snow Leopard setup right out of the box. It’s a bit silly, but what it does is take your selected text and run it as a&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/updated-songza-lucky-link-service/">Updated: Songza Lucky Link Service</a></p>]]></description>
			<content:encoded><![CDATA[<p>Songza.fm has moved to Songza.org, so I’ve rewritten the <a href="http://brettterpstra.com/2009/11/12/songza-lucky-link-service/">old Songza Lucky Link Service</a> for Snow Leopard to match. This new version of the service runs without dependencies, so it should work for any Snow Leopard setup right out of the box. It’s a bit silly, but what it does is take your selected text and run it as a query on Songza.org, parse for the first result (if there are any), shorten that link and insert it after your selected text. A fast, easy way to punctuate your obscure music references in emails and on the web. Have fun, and join me in hoping for the Songza API to blossom into something we can really sink our scripts into!</p>

<p>To install, just download the file below, unzip it (double click), and move it into <code>[your username]/Library/Services</code>. To use it, select text in any Cocoa app (Safari, Mail, and most Mac apps) and look under the application menu in the menubar for the Services submenu. Trigger it from there, or just right click on your selected text and you should get the same services menu as a contextual menu item. If you’re feeling clever, go into the Keyboard preferences pane, choose Keyboard Shortcuts -&gt; Services and double click the blank space to the right of the service to assign a hotkey. As long as that hotkey isn’t already assigned by the application your using, you can trigger the service with it any time you have text selected.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/SongzaLuckyLinkSLService.zip?9d7bd4" title="Download Songza Lucky Link Service (83)"><img src="http://brettterpstra.com/wp-content/images/serviceicon.jpg?9d7bd4" alt="download image for Songza Lucky Link Service" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/SongzaLuckyLinkSLService.zip?9d7bd4" title="Download Songza Lucky Link Service (83)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/SongzaLuckyLinkSLService.zip?9d7bd4" title="Download Songza Lucky Link Service (83)">Songza Lucky Link Service</a> — A Snow Leopard Service to generate a shortened url to the first result of a Songza.org search for the selected text. The text will remain, but it will have the result in parenthesis after it. Uses a built-in html parser to scrape the results, at least until Songza provides an API. <a href="http://brettterpstra.com/2010/03/20/updated-songza-lucky-link-service/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/songza-lucky-link-service/' rel='bookmark' title='Songza Lucky Link Service'>Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/songza-is-back/' rel='bookmark' title='Songza is back!'>Songza is back!</a></li>
<li><a href='http://brettterpstra.com/auto-link-text-service-updated/' rel='bookmark' title='Auto-link text service updated'>Auto-link text service updated</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/updated-songza-lucky-link-service/">Updated: Songza Lucky Link Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/updated-songza-lucky-link-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A better System Service for Evernote clipping — with MultiMarkdown</title>
		<link>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/</link>
		<comments>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 00:02:09 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[multimarkdown]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=302</guid>
		<description><![CDATA[<p>Update: If you’re looking for a Markdown -&#62; Evernote, check this out. Another post, quickly and with less explanation… The fact that Evernote processes HTML so much better than it does plain or rich text got me thinking and tinkering. I use Markdown (actually, MultiMarkdown) constantly, and it does a great job of turning plain text into valid markup. With&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">A better System Service for Evernote clipping — with MultiMarkdown</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> If you’re looking for a Markdown -&gt; Evernote, <a href="http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/">check this out</a>.</p>

<p>Another post, quickly and with less explanation…</p>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/EvernoteIcon-300x300.png?9d7bd4" alt="Evernote Icon" title="EvernoteIcon" width="300" height="300" class="alignright size-medium wp-image-305" />The fact that Evernote processes HTML so much better than it does plain or rich text got me thinking and tinkering. I use <a href="http://daringfireball.net/projects/markdown/">Markdown</a> (actually, <a href="http://fletcherpenney.net/multimarkdown/">MultiMarkdown</a>) constantly, and it does a great job of turning plain text into valid markup. With (Multi)Markdown, even plain text becomes HTML that–when imported into Evernote–retains most of its formatting. To answer your question, no, I’m not obsessed with Evernote, I’m obsessed with problems I think I could solve. It’s unhealthy.</p>

<p><strong><em>Please note</em></strong>, this requires that you have <a href="http://fletcherpenney.net/">Fletcher Penney’s</a> MultiMarkdown installed in <code>~/Library/Application Support/MultiMarkdown</code>, and that the Perl files (MultiMarkdown.pl and SmartyPants.pl) are located in a ‘bin’ subdirectory (which is the default install). If you don’t have MultiMarkdown, you should get it anyway (all the cool kids have it), so head over to the <a href="http://fletcher.github.com/MultiMarkdown/">download page</a> and grab a copy. Now, on with the show.</p>

<p>I set this up originally as a <a href="http://macromates.com/">TextMate</a> command, intending just to be able to clip code snippets and free-form text to Evernote without thinking too much about it. That worked well, so I modified it to work as a System Service. Specifically, a Snow Leopard service, but I’m providing the Ruby script here and it can be modified for any Mac setup you want.</p>

<p>While it will work just fine on plain text with no markup, it does have a couple of “special” features. If you start a line with a <code>#</code> and a space (e.g.: # This is my header), which is a <a href="http://daringfireball.net/projects/markdown/syntax#header">Markdown convention</a> for a first-level heading, it will use that as the title for the note and strip it out of the text in processing. It only uses the first one it finds, but it will strip out any first-level headers in the selection. I’ll probably modify that later, or just have it leave them in. Also, a line that begins with “tags:” followed by a space and a comma-separated list of words will be split up and used to tag the new note. This is also stripped before processing. It handles spaces in multi-word tags, and odd marks at the beginning or end of a tag, <em>but only one punctuation character, and only at the beginning or end of a tag</em>. The code follows…</p>

<p><span id="more-302"></span></p>

<p>Here’s the Ruby code, messy as it may be:</p>

<div markdown=0>
<pre><code>
    #!/usr/bin/env ruby -rjcode -Ku
    # requires that MultiMarkdown be installed in ~/Library/Application Support/MultiMarkdown
    # That, or edit the script to point to yours :)

    ARGF.each do |f|
    input = f
    contents = &#x27;&#x27;
    tags = &#x27;&#x27;
    title = nil

    def e_as(str)
        str.to_s.gsub(/(?=[&quot;\\])/, &#x27;\\&#x27;)
    end
    input.each_line { |line| 
      if line =~ /^# (.*?)/
        title = line[2..-1]
        break
      end
    }
    title = %x{date &#x27;+Clipped note: %A, %B %d, %Y at %l:%M %p&#x27;|tr -s &quot; &quot;} if title.nil?

    input.each_line { |line| 
      if line =~ /^[Tt]ags: /
        tags = line[5..-1].split(&#x27;,&#x27;).map {|tag| tag = tag.strip.gsub(/^(.)?\b|\b(.)?$/,&quot;\\2\&quot;\\1&quot;) }
        break
      end
    }

    IO.popen(&#x27;&quot;$HOME/Library/Application Support/MultiMarkdown/bin/MultiMarkdown.pl&quot;|&quot;$HOME/Library/Application Support/MultiMarkdown/bin/SmartyPants.pl&quot;&#x27;, &quot;r+&quot;) do |io|
     input.each_line { |line| 
        io &lt;&lt; line unless line =~ /^# |[Tt]ags\: /
     }; io.close_write
     io.each_line do |line|
       contents &lt;&lt; line
     end
    end
    tags = &quot; tags {#{tags.join(&quot;,&quot;)}}&quot; unless tags.empty?
    %x{osascript -e &#x27;tell application &quot;Evernote&quot; to create note with html &quot;#{e_as contents}&quot; title &quot;#{title}&quot; notebook &quot;Unfiled&quot;#{tags}&#x27;}
    end
</code></pre>
</div>

<p>You can create a System Service in Automator with it, set up a command in TextMate, or do whatever else you can think of. If you just want to download the service and try it out, I’ve made it <a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4">available here</a>. Unzip and copy it to ~/Library/Services (in your home folder). If you set it up as a System Service, assign a shortcut key in the Keyboard pane of System Preferences.</p>

<p>It does choke once in a while, apparently on Markdown-generated code snippets, but I haven’t quite narrowed down why, yet. I’ll update the code if I figure that one out. Overall, though, it makes pretty clippings and allows you to use some Markdown syntax to spice up your text without having to touch the (regrettably abominable) Evernote editor.</p>

<hr />

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)"><img src="http://brettterpstra.com/wp-content/images/serviceicon.jpg?9d7bd4" alt="download image for Markdown To Evernote Service" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)">Markdown To Evernote Service</a> — A Snow Leopard System Service that grabs selected text, processes it with MultiMarkdown and clips the resulting HTML to Evernote, creating a nicely formatted note. Uses the first (and hopefully only) Markdown first-level heading (# My headline) as the title for the note, and will look for a line starting with “tags: ” followed by a comma-separated list of tags as well.

Requires that MultiMarkdown be installed in ~/Library/Application Support/MultiMarkdown. <a href="http://brettterpstra.com/2010/03/06/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
<li><a href='http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/' rel='bookmark' title='Evernote Site Memory tagger for WordPress'>Evernote Site Memory tagger for WordPress</a></li>
<li><a href='http://brettterpstra.com/a-service-for-writing-multimarkdown-footnotes-inline/' rel='bookmark' title='A Service for writing MultiMarkdown footnotes inline'>A Service for writing MultiMarkdown footnotes inline</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">A better System Service for Evernote clipping — with MultiMarkdown</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A (fairly) simple equation evaluation service for Snow Leopard</title>
		<link>http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/</link>
		<comments>http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 14:33:05 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=215</guid>
		<description><![CDATA[<p>Download the Evaluate Expression Snow Leopard service: EvaluateExpressionService.zip This is a stripped down version of a command I have in the TextMate bundle we use at TUAW. It allows you to select any basic numeric equation and evaluate it, replacing the selected text with the results. It will ignore your text if it contains anything but numbers and basic mathematical&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/">A (fairly) simple equation evaluation service for Snow Leopard</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0; display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/12/equationevalheader.jpg?9d7bd4" alt="Expressionevalheader" height="187" width="650" class="alignleft headerimg" />Download the Evaluate Expression Snow Leopard service: <a href="http://brettterpstra.com/share/EvaluateExpressionService.zip?9d7bd4">EvaluateExpressionService.zip</a></p>

<p>This is a stripped down version of a command I have in the <a href="http://macromates.com/">TextMate</a> bundle we use at <a href="http://www.tuaw.com/">TUAW</a>. It allows you to select any basic numeric equation and evaluate it, replacing the selected text with the results. It will ignore your text if it contains anything but numbers and basic mathematical symbols. Sure, there are plenty of ways to do calculations in OS X (<a href="http://www.mactropolis.com/how-tos/leopard-tip-spotlight-calculator/">Spotlight</a>, <a href="http://www.obdev.at/products/launchbar/index.html">Launchbar</a>, <a href="http://www.blacktree.com/">Quicksilver</a>), but I’ve had more and more incidents lately where I just wanted to do quick calculations inline, so I whipped this up. A little explanation…</p>

<p><span id="more-215"></span>
The service is built for Snow Leopard only, but I’m including the code here because it could be wrapped up in <a href="http://wafflesoftware.net/thisservice/">ThisService</a> or <a href="http://www.xendai.com/">Bellhop</a> pretty quickly for Leopard. It’s built in Ruby and uses the eval function to process text such as <code>20*(3.5/2)</code> and return the result. It will add commas to numbers longer than 3 digits, but I stripped out the part of the original command that trimmed decimal places; I figured the accuracy might be important and the results are easy to edit manually in this case. I also added a silly feature that I actually find quite useful: it evaluates +/- percentage strings, such as <code>23.99-15%</code>, which I find most useful for calculating savings during sales or quickly handling markup or tax on services and goods. It can’t get too complex, but for most everyday purposes, it does a good job.</p>

<h3>The code:</h3>

<div markdown="0">
<pre><code>
def ts( st )
  # Adds commas to longer numbers
  # Removes .00 left over from % calculations
  mynum = st.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
  dec = mynum.split('.')
  return dec[0] if dec[1].to_i == 0
  mynum
end

ARGF.each do |f|
    # check if the text passed is actually an equation
    if f.match(/^[\%\$\d\*\/\+\-,\. \(\)]+$/)
        # add a preceding 0 to decimals passed for floating point calculation
        num = f.gsub(/(^|[^\d])(\.\d+)/,'\10\2')
        # convert basic percentage equations for eval
        num = num.gsub(/([\d\.]+)(?:\s+?)?([+-])(?:\s+?)?([\d\.]+)%([^\d]|$)/,'\1\2(\1*(\3.to_f * 0.01))\4')
        # process the result to add commas, trim unnecessary decimal places
        print ts(eval(num).to_s)
    # if it's not an equation, return the input (no effect)
    else
        print f
    end
end
</code></pre>
</div>

<p>You can <a href="http://brettterpstra.com/downloads/EvaluateExpressionService.zip?9d7bd4">download a ready-to-go Snow Leopard service</a>, or build your own with the code above. Don’t forget to use the Keyboard preference panel to assign a keyboard shortcut to it (I’m using Control-Shift-=). I’d love to hear back if you find it useful!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/' rel='bookmark' title='Clippable to Evernote Snow Leopard Service'>Clippable to Evernote Snow Leopard Service</a></li>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/sms-from-the-command-line-with-google-voice/' rel='bookmark' title='SMS from the command line with Google Voice'>SMS from the command line with Google Voice</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/">A (fairly) simple equation evaluation service for Snow Leopard</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Songza Lucky Link Service</title>
		<link>http://brettterpstra.com/songza-lucky-link-service/</link>
		<comments>http://brettterpstra.com/songza-lucky-link-service/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 23:41:42 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[songza]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=148</guid>
		<description><![CDATA[<p>This is a quick and dirty Snow Leopard Service that scrapes Songza.fm to find a song related to your selected text in most applications. It replaces the selected text with an is.gd shortened link and the name of the first song it found (just to be sure you’re on the same page… literally). The code is also available as a&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/songza-lucky-link-service/">Songza Lucky Link Service</a></p>]]></description>
			<content:encoded><![CDATA[<p>This is a quick and dirty Snow Leopard Service that scrapes <a href="http://songza.fm">Songza.fm</a> to find a song related to your selected text in most applications. It replaces the selected text with an is.gd shortened link and the name of the first song it found (just to be sure you’re on the same page… literally). The code is also available as a <a href="http://gist.github.com/233120">TextMate command</a> for those interested. <ins datetime="2009-11-13T01:12:47+00:00">Update: <a href="http://gist.github.com/233486">TextMate command with link selection popup</a>.</ins></p>

<p>The service (and TextMate command) require the Hpricot gem for ruby. In most cases, this should be installable from the command line with <code>sudo gem install hpricot</code>. If you see errors, you may need to update some Ruby components. Once that’s set, just install the <a href="http://brettterpstra.com/share/SongzaLinkSLService.zip?9d7bd4">workflow</a> in ~/Library/Services and it should immediately start showing up in your services menu. Add a shortcut for it in Preferences -&gt; Keyboard -&gt; Shortcuts -&gt; Services. Next time you’re tweeting or writing an email about a song, why not send a Songza link to back up your point?</p>

<p><span id="more-148"></span></p>

<p><a href="http://brettterpstra.com/share/SongzaLinkSLService.zip?9d7bd4">Download the service</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/auto-link-text-service-updated/' rel='bookmark' title='Auto-link text service updated'>Auto-link text service updated</a></li>
<li><a href='http://brettterpstra.com/automated-search-and-link-text-service/' rel='bookmark' title='Automated search and link text Service'>Automated search and link text Service</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/songza-lucky-link-service/">Songza Lucky Link Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/songza-lucky-link-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Clippable to Evernote Snow Leopard Service</title>
		<link>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/</link>
		<comments>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 05:55:06 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[clippable]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=109</guid>
		<description><![CDATA[<p>Clippable to Evernote will allow you to trigger the Clippable bookmarklet in Safari and copy the result directly to your "Unfiled" notebook in Evernote. This service is Snow Leopard-only.</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/">Clippable to Evernote Snow Leopard Service</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/clippabletoevernote110309.jpg?9d7bd4" alt="clippabletoevernote110309" title="clippabletoevernote110309" width="440" height="187" class="alignnone size-full wp-image-121 headerimg" />
Clippable to Evernote will allow you to trigger the <a href="http://brettterpstra.com/2009/11/03/clippable/">Clippable bookmarklet</a> in Safari and copy the result directly to your “Unfiled” notebook in Evernote. This service is Snow Leopard-only. If you need it modified for Leopard and aren’t sure how, let me know. If there’s some interest, I’ll just work one up and post it.</p>

<p>To install in Snow Leopard, just unzip (double-click the zip file) the file and move the resulting .workflow file to [your home directory]/Library/Services. It should now appear in your Safari-&gt;Services menu, in Safari only. To add a keyboard shortcut to the Service, go to the Keyboard pane in System Preferences, choose the Keyboard Shortcuts tab, select Services on the left and find the Clippable… service on the right. Double click on the right side of the listing to enter a hotkey. I currently have mine bound to control-command-E, which works well for me in Safari.</p>

<p>Download <a href="http://brettterpstra.com/share/clippable-to-evernote.zip?9d7bd4">here</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/' rel='bookmark' title='A (fairly) simple equation evaluation service for Snow Leopard'>A (fairly) simple equation evaluation service for Snow Leopard</a></li>
<li><a href='http://brettterpstra.com/clippable-updated-goes-mobile/' rel='bookmark' title='Clippable updated, goes mobile'>Clippable updated, goes mobile</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/">Clippable to Evernote Snow Leopard Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 25/129 queries in 0.300 seconds using xcache
Object Caching 3277/3412 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-05-23 04:27:46 -->
