<?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>tanniespace &#187; textexpander</title>
	<atom:link href="http://tanniespace.com/tag/textexpander/feed/" rel="self" type="application/rss+xml" />
	<link>http://tanniespace.com</link>
	<description>geekery, drawing and then some</description>
	<lastBuildDate>Sun, 25 Jul 2010 21:50:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
			<title>tanniespace</title>
			<url>http://tanniespace.com/robots-feed.png</url>
			<link>http://tanniespace.com</link>
			<width>65</width>
			<height>88</height>
			<description>geekery, drawing and then some</description>
		</image>		<item>
		<title>Bit.ly + TextExpander + Applescript = WIN!</title>
		<link>http://tanniespace.com/bitly-textexpander-applescript-win/</link>
		<comments>http://tanniespace.com/bitly-textexpander-applescript-win/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 14:49:02 +0000</pubDate>
		<dc:creator>tannie</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[omniweb]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://tanniespace.com/?p=777</guid>
		<description><![CDATA[I wanted an easy way to shorten my URLs through one of the URL-shorteners out there. I liked bit.ly, because it's nice and short, has an easy to navigate web-interface (without a mouse) and I can use its magic with my terminal (cURL). I also very much like TextExpander and after googling a bit, I [...]<br class="clearer" style="clear:both;" />]]></description>
			<content:encoded><![CDATA[<p>I wanted an easy way to shorten my <span class="caps">URL</span>s through one of the <span class="caps">URL</span>-shorteners out there. I liked <a href="http://bit.ly/">bit.ly</a>, because it's nice and short, has an easy to navigate web-interface (without a mouse) and I can use its magic with my terminal (cURL).</p>

<p>I also very much like <a href="http://www.smileonmymac.com/TextExpander/">TextExpander</a> and after googling a bit, I ofcourse found an <a href="http://www.livedigitally.com/2008/07/23/how-to-automatic-url-shortening-with-bitly-and-textexpander/">Applescript for TextExpander and Bit.ly</a>. That link also shows how to set it up in TextExpander, very handy!<br />
The script does not however use your actual bit.ly account so you can keep track of the <span class="caps">URL</span>s you shorten. I tweaked it and made adjustments and it took hours and ofcourse, then I find <a href="http://snipplr.com/view/13743/bitly-urlshortening-script-for-textexpander-that-associates-urls-with-your-bitly-account/">this</a> which is almost exactly what I had, except with <span class="caps">URL</span>-encoding (yummy).<br />
The only problem with that one was that I couldn't get it to have the <span class="caps">URL</span>s show up in my recent history. The 'history=1' didn't seem to work.</p>

<p>I tweaked some more and came up with something that completely does what I want. I use <a href="http://www.omnigroup.com/applications/omniweb/">OmniWeb</a> so I replaced the</p>

<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">set</span> <span style="color: #ff0033;">the</span> PageURL <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">the clipboard</span> <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span></div></div>

<p>with</p>

<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;OmniWeb&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> PageURL <span style="color: #ff0033; font-weight: bold;">to</span> address <span style="color: #ff0033; font-weight: bold;">of</span> active <span style="color: #0066ff;">tab</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #000000;">1</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></div></div>

<p>If you use safari, use</p>

<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Safari&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> PageURL <span style="color: #ff0033; font-weight: bold;">to</span> URL <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #ff0033;">front</span> <span style="color: #0066ff;">document</span><br />
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></div></div>






<p><span id="more-777"></span><br />
I've made this as readable as possible, the '&not;' do matter in Applescript.</p>

<div class="codecolorer-container applescript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><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;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;OmniWeb&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> PageURL <span style="color: #ff0033; font-weight: bold;">to</span> address <span style="color: #ff0033; font-weight: bold;">of</span> active <span style="color: #0066ff;">tab</span> <span style="color: #ff0033; font-weight: bold;">of</span> browser <span style="color: #000000;">1</span><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;">set</span> login <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;YOUR LOGIN&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> api_key <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;YOUR API KEY&quot;</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #ff0033;">the</span> EncodedURL <span style="color: #ff0033; font-weight: bold;">to</span> urlencode<span style="color: #000000;">&#40;</span>PageURL<span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #0066ff;">me</span><br />
<br />
<span style="color: #ff0033; font-weight: bold;">set</span> curlCMD <span style="color: #ff0033; font-weight: bold;">to</span> ¬<br />
&nbsp; &nbsp; <span style="color: #009900;">&quot;curl --stderr /dev/null <span style="color: #000000; font-weight: bold;">\&quot;</span>http://api.bit.ly/shorten?longUrl=&quot;</span> ¬<br />
&nbsp; &nbsp; <span style="color: #000000;">&amp;</span> EncodedURL <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&amp;history=1&amp;version=2.0.1&amp;login=&quot;</span> <span style="color: #000000;">&amp;</span> login ¬<br />
&nbsp; &nbsp; <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;&amp;apiKey=&quot;</span> <span style="color: #000000;">&amp;</span> api_key ¬<br />
&nbsp; &nbsp; <span style="color: #000000;">&amp;</span> <span style="color: #009900;">&quot;<span style="color: #000000; font-weight: bold;">\&quot;</span>| grep shortUrl | grep -o http.*[/a-zA-Z0-9]&quot;</span><br />
<br />
<br />
<span style="color: #808080; font-style: italic;">-- Run the script and get the result:</span><br />
<span style="color: #ff0033; font-weight: bold;">set</span> bitlyURL <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">do shell script</span> curlCMD<span style="color: #000000;">&#41;</span><br />
<br />
<span style="color: #ff0033; font-weight: bold;">return</span> bitlyURL<br />
<br />
<span style="color: #ff0033; font-weight: bold;">on</span> urlencode<span style="color: #000000;">&#40;</span>theText<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> theTextEnc <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #009900;">&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">repeat</span> <span style="color: #ff0033; font-weight: bold;">with</span> eachChar <span style="color: #ff0033; font-weight: bold;">in</span> characters <span style="color: #ff0033; font-weight: bold;">of</span> theText<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> useChar <span style="color: #ff0033; font-weight: bold;">to</span> eachChar<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> eachCharNum <span style="color: #ff0033; font-weight: bold;">to</span> ASCII <span style="color: #0066ff;">number</span> <span style="color: #ff0033; font-weight: bold;">of</span> eachChar<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> eachCharNum <span style="color: #000000;">=</span> <span style="color: #000000;">32</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> useChar <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;">else</span> <span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>eachCharNum ≠ <span style="color: #000000;">42</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span>eachCharNum ≠ <span style="color: #000000;">95</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span>eachCharNum <span style="color: #000000;">&lt;</span> <span style="color: #000000;">45</span> <span style="color: #ff0033;">or</span> eachCharNum &gt; <span style="color: #000000;">46</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span>eachCharNum <span style="color: #000000;">&lt;</span> <span style="color: #000000;">48</span> <span style="color: #ff0033;">or</span> eachCharNum &gt; <span style="color: #000000;">57</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span>eachCharNum <span style="color: #000000;">&lt;</span> <span style="color: #000000;">65</span> <span style="color: #ff0033;">or</span> eachCharNum &gt; <span style="color: #000000;">90</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033;">and</span> <span style="color: #000000;">&#40;</span>eachCharNum <span style="color: #000000;">&lt;</span> <span style="color: #000000;">97</span> <span style="color: #ff0033;">or</span> eachCharNum &gt; <span style="color: #000000;">122</span><span style="color: #000000;">&#41;</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> firstDig <span style="color: #ff0033; font-weight: bold;">to</span> round <span style="color: #000000;">&#40;</span>eachCharNum <span style="color: #000000;">/</span> <span style="color: #000000;">16</span><span style="color: #000000;">&#41;</span> rounding down<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> secondDig <span style="color: #ff0033; font-weight: bold;">to</span> eachCharNum <span style="color: #ff0033;">mod</span> <span style="color: #000000;">16</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">if</span> firstDig &gt; <span style="color: #000000;">9</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> aNum <span style="color: #ff0033; font-weight: bold;">to</span> firstDig <span style="color: #000000;">+</span> <span style="color: #000000;">55</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> firstDig <span style="color: #ff0033; font-weight: bold;">to</span> ASCII character aNum<br />
&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;">if</span> secondDig &gt; <span style="color: #000000;">9</span> <span style="color: #ff0033; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> aNum <span style="color: #ff0033; font-weight: bold;">to</span> secondDig <span style="color: #000000;">+</span> <span style="color: #000000;">55</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">set</span> secondDig <span style="color: #ff0033; font-weight: bold;">to</span> ASCII character aNum<br />
&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;">set</span> numHex <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;%&quot;</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>firstDig <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span> ¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span>secondDig <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><span style="color: #000000;">&#41;</span><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; <span style="color: #ff0033; font-weight: bold;">set</span> useChar <span style="color: #ff0033; font-weight: bold;">to</span> numHex<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> theTextEnc <span style="color: #ff0033; font-weight: bold;">to</span> theTextEnc <span style="color: #000000;">&amp;</span> useChar <span style="color: #ff0033;">as</span> <span style="color: #0066ff;">string</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">repeat</span><br />
&nbsp; &nbsp; <span style="color: #ff0033; font-weight: bold;">return</span> theTextEnc<br />
<span style="color: #ff0033; font-weight: bold;">end</span> urlencode</div></div><br class="clearer" style="clear:both;" /><br class="clearer" style="clear:both;" />]]></content:encoded>
			<wfw:commentRss>http://tanniespace.com/bitly-textexpander-applescript-win/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
