<?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/"
	xmlns:media="http://search.yahoo.com/mrss/">

<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>Sat, 24 Dec 2011 08:32:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bit.ly + TextExpander + Applescript = WIN!</title>
		<link>http://tanniespace.com/2009/bitly-textexpander-applescript-win/</link>
		<comments>http://tanniespace.com/2009/bitly-textexpander-applescript-win/#comments</comments>
		<pubDate></pubDate>
		<dc:creator>tanja</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&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted an easy way to shorten my URLs through one of the URL-shorteners out there. I liked <a href="http://bit.ly/">bit.ly</a>, because it&#8217;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!
The script does not however use your actual bit.ly account so you can keep track of the URLs 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 URL-encoding (yummy).
The only problem with that one was that I couldn&#8217;t get it to have the URLs show up in my recent history. The &#8216;history=1&#8242; didn&#8217;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;"><span style="color: #ff0033;">the</span> 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>
I&#8217;ve made this as readable as possible, the &#8216;&not;&#8217; 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/v3/shorten?format=txt&amp;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;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>&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>

<p>ETA (2010.09.30): bit.ly changed a few things so I changed the script above to reflect that</p>
]]></content:encoded>
			<wfw:commentRss>http://tanniespace.com/2009/bitly-textexpander-applescript-win/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

