<?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>A Tasty Pixel » Blog &#187; Scripts</title>
	<atom:link href="http://atastypixel.com/blog/tag/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://atastypixel.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 15:08:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Supporting WordPress shortcodes and captions in MarsEdit preview</title>
		<link>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/</link>
		<comments>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 17:50:49 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[MarsEdit]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=2211</guid>
		<description><![CDATA[I noticed that WordPress these days uses a shortcode to define image captions, of the form: &#91;caption id="" align="aligncenter" width="630" caption="Image title goes here"&#93;&#60;img src=&#34;http://domain.com/imgpath/../image.jpg&#34; width=&#34;630&#34; height=&#34;420&#34; /&#62;&#91;/caption&#93; I&#8217;ve recently redone our blog template at Technomadics, and while setting up the new preview template in MarsEdit, thought I&#8217;d take a stab at implementing support for [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that WordPress these days uses a shortcode to define image captions, of the form:</p>

<p><tt>&#91;caption id="" align="aligncenter" width="630" caption="Image title goes here"&#93;&lt;img src=&quot;http://domain.com/imgpath/../image.jpg&quot; width=&quot;630&quot; height=&quot;420&quot; /&gt;&#91;/caption&#93;</tt></p>

<p>I&#8217;ve recently redone our blog template at <a href="http://technomadics.net">Technomadics</a>, and while setting up the new preview template in MarsEdit, thought I&#8217;d take a stab at implementing support for captions, too, via some javascript in the template.</p>

<p>I was successful!  Here&#8217;s how I did it:</p>

<p>Added the following to the &#8220;head&#8221; section:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> prior_content<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> watch_for_changes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> check <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> elt <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> elt.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">!=</span> prior_content <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       elt.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span>elt.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   prior_content <span style="color: #339933;">=</span> elt.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    setTimeout<span style="color: #009900;">&#40;</span>check<span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  setTimeout<span style="color: #009900;">&#40;</span>check<span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> apply_shortcode<span style="color: #009900;">&#40;</span>source<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> source.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>['</span> <span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>s*([^<span style="color: #000099; font-weight: bold;">\\</span>]]*)<span style="color: #000099; font-weight: bold;">\\</span>]((.|[<span style="color: #000099; font-weight: bold;">\s</span><span style="color: #000099; font-weight: bold;">\n</span>])*?)<span style="color: #000099; font-weight: bold;">\\</span>[/'</span> <span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>]'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'g'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                         <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>match<span style="color: #339933;">,</span> paramString<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                           params <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           reg <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/([a-z]+)=&quot;((:?=&quot;[^&quot;]+&quot;|[^&quot;])*)&quot;/gi</span><span style="color: #339933;">;</span>
                           <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>match <span style="color: #339933;">=</span> reg.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span>paramString<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                             params<span style="color: #009900;">&#91;</span>match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                           <span style="color: #009900;">&#125;</span>
                           <span style="color: #000066; font-weight: bold;">return</span> callback<span style="color: #009900;">&#40;</span>params<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                         <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> apply_filters<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  html <span style="color: #339933;">=</span> apply_shortcode<span style="color: #009900;">&#40;</span>html<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;caption&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&lt;div '</span><span style="color: #339933;">+</span>
               <span style="color: #3366CC;">'class=&quot;wp-caption '</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>args.<span style="color: #660066;">align</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">?</span> args.<span style="color: #660066;">align</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; '</span><span style="color: #339933;">+</span>
               <span style="color: #3366CC;">'style=&quot;width: '</span> <span style="color: #339933;">+</span> args.<span style="color: #660066;">width</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'px;&quot;&gt;'</span> <span style="color: #339933;">+</span> content <span style="color: #339933;">+</span>
             <span style="color: #3366CC;">'&lt;p class=&quot;wp-caption-text&quot;&gt;'</span> <span style="color: #339933;">+</span> args.<span style="color: #660066;">caption</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/p&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> html<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>


<p>…changed to &#8216;body&#8217; tag to…</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body onload=&quot;watch_for_changes();&quot;&gt;</pre></div></div>


<p>…And wrapped a div around the main &#8220;#body#, #extended#&#8221; content with an <code>id</code> of <code>content</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;content&quot;&gt;
#body#
#extended#
&lt;/div&gt;</pre></div></div>


<p>Basically, it polls the content area for changes, and when triggered, runs it though a filter.  The above is extensible, and by adding additional &#8220;<code>apply_shortcode</code>&#8221; calls from &#8220;<code>apply_filters</code>&#8220;, more shortcodes can be simulated.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2211" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Xcode 4&#8242;s symbolicate utility to get comprehensible crash logs</title>
		<link>http://atastypixel.com/blog/fixing-xcode-4s-symbolicate-utility-to-get-comprehensible-crash-logs/</link>
		<comments>http://atastypixel.com/blog/fixing-xcode-4s-symbolicate-utility-to-get-comprehensible-crash-logs/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 19:30:58 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/fixing-xcode-4s-symbolicate-utility-to-get-comprehensible-crash-logs/</guid>
		<description><![CDATA[&#8216;symbolicatecrash&#8217; is the Developer Tools utility which replaces all those meaningless addresses from crash logs with actual symbol names and source code references. It lives at some obscure folder within /Developer &#8211; use find to dig it up and symlink it into /usr/local/bin if you wanna use it conveniently from the command line. Anyway, after [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;symbolicatecrash&#8217; is the Developer Tools utility which replaces all those meaningless addresses from crash logs with actual symbol names and source code references.  It lives at some obscure folder within <code>/Developer</code> &#8211; use <code>find</code> to dig it up and symlink it into <code>/usr/local/bin</code> if you wanna use it conveniently from the command line.</p>

<p>Anyway, after plenty of frustration, I noticed some chatter about the damn thing being busted in Xcode 4.  Figures!</p>

<p>There&#8217;s an <a href="https://github.com/fourdman/symbolicatecrash-fix">alternate third party version</a> on GitHub, but this didn&#8217;t really help me &#8211; I still got inscrutable errors, so I took a look at the original.</p>

<p>The version that comes with Xcode 4 appears to have some problems distinguishing, say, an iPhone Simulator build of the app from a native build sitting in the Archives folder.  I&#8217;d just see an error about otool and some binary living in the iPhone Simulator folder.</p>

<p>Digging into the errant symbolicatecrash source, I noticed that the code that finds the executable path tests each candidate using otool, but doesn&#8217;t seem to be able to comprehend the output from otool caused by running it on the wrong architecture.</p>

<p>So, replacing the rather unhelpful &#8216;die&#8217; statement on line 323:</p>

<p><code>die "Can't understand the output from otool ($TEST_uuid -&gt; '$otool -arch $arch -l $path')";</code></p>

<p>With a &#8220;No, it ain&#8217;t this executable&#8221; response:</p>

<p><code>return 0;</code></p>

<p>&#8230;solves the problem immediately.  Now I can drag crash logs straight into the Organizer in Xcode, and it&#8217;ll symbolicate correctly.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2199" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/fixing-xcode-4s-symbolicate-utility-to-get-comprehensible-crash-logs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Objective-C + Cocoa on the Command Line</title>
		<link>http://atastypixel.com/blog/objective-c-cocoa-on-the-command-line/</link>
		<comments>http://atastypixel.com/blog/objective-c-cocoa-on-the-command-line/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 21:04:58 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/objective-c-cocoa-on-the-command-line/</guid>
		<description><![CDATA[Sometimes there&#8217;s just one tiny snippet of Cocoa code that you want to test &#8212; maybe to find out the output of NSDateFormatter for various cases, testing out some text replacement routine, or testing out some image drawing code. It&#8217;s often too much trouble to create a new XCode project and set up the framework [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes there&#8217;s just one tiny snippet of Cocoa code that you want to test &#8212; maybe to find out the output of NSDateFormatter for various cases, testing out some text replacement routine, or testing out some image drawing code.</p>

<p>It&#8217;s often too much trouble to create a new XCode project and set up the framework to do one simple test, which is why I put together this little shell script that lets you run Cocoa code from the command line:</p>

<p><tt>$ runcocoa 'NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setDateFormat:@"d MMM, h:mm a"]; NSLog(@"%@", [formatter stringFromDate:[NSDate date]]);'</p>

<p>2011-02-23 20:02:10.313 runcocoa-output[28025:903] 23 Feb, 8:02 PM</tt></p>

<p><strong>You have full access to all Cocoa libraries, and in iOS mode, access to most iOS stuff too, straight from the command line.</strong></p>

<p><strong>Update</strong>: This is now available as a <a href="https://github.com/michaeltyson/Commandline-Cocoa">GitHub project</a><span id="more-2143"></span></p>

<p></p>

<p>You can invoke it either by specifying the code to execute on the command line as a parameter, or through standard input, so you can pipe stuff to it.  This is particularly convenient for use with TextMate: Type some code, hit <em>Cmd-Option-R</em>, type &#8220;runcocoa&#8221;, hit enter, and the result appears as a tooltip.</p>

<p>Awesome, no?</p>

<p>You can include other frameworks (use &#8220;<code>-include AudioToolbox/AudioToolbox.h -framework AudioToolbox"</code> as command line arguments, for example), and run the code in gdb (with <code>-gdb</code> as a command-line argument).</p>

<p>You can also run it as iOS code by supplying the <code>-ios</code> commandline parameter &#8212; try this:</p>

<p><code>runcocoa -ios 'UIGraphicsBeginImageContext(CGSizeMake(100,100)); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(ctx,[[UIColor whiteColor] CGColor]); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, 50, 0); CGContextAddArc(ctx, 50, 50, 50, M_PI/2.0, M_PI/2.0 + (2*M_PI), 0); CGContextFillPath(ctx); UIImage *icon = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://atastypixel.com/favicon.ico"]]]; [icon drawAtPoint:CGPointMake((100-[icon size].width)/2.0,(100-[icon size].height)/2.0)]; UIImage *i = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [UIImagePNGRepresentation(i) writeToFile:@"output.png" atomically:NO];'; open output.png;</code></p>

<p>Any other libraries to link in can be specified &#8212; command line arguments will be passed on unmolested to GCC.   Add <code>#import</code>s with the <code>-include</code> parameter.</p>

<p>Grab the script from the <a href="https://github.com/michaeltyson/Commandline-Cocoa">Commandline-Cocoa GitHub project</a> &#8212; make it executable (<code>chmod +x runcocoa.sh</code>), and move it to <code>/usr/local/bin/runcocoa</code>.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2143" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/objective-c-cocoa-on-the-command-line/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Resuming ADC downloads (&#8216;cos Safari sucks)</title>
		<link>http://atastypixel.com/blog/resuming-adc-downloads-cos-safari-sucks/</link>
		<comments>http://atastypixel.com/blog/resuming-adc-downloads-cos-safari-sucks/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 21:27:48 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/resuming-adc-downloads-cos-safari-sucks/</guid>
		<description><![CDATA[So, Safari&#8217;s resume facility is just awful &#8212; it&#8217;ll randomly restart downloads from the beginning, clobbering anything that&#8217;s already been downloaded, and the resume button will frequently disappear entirely and mysteriously from the downloads window. And if the session has expired, it&#8217;ll cause all kinds of havoc. Anyone downloading the gazillion-gb iOS/Mac SDK + XCode [...]]]></description>
			<content:encoded><![CDATA[<p>So, Safari&#8217;s resume facility is just awful &#8212; it&#8217;ll randomly restart downloads from the beginning, clobbering anything that&#8217;s already been downloaded, and the resume button will frequently disappear entirely and mysteriously from the downloads window.  And if the session has expired, it&#8217;ll cause all kinds of havoc.</p>

<p>Anyone downloading the gazillion-gb iOS/Mac SDK + XCode on a slow and/or expensive connection will know the sheer fisticuffs-inspiring irritation this creates &#8212; speaking personally, living on a mobile broadband connection that&#8217;s usually changed at £3 per gig and often runs about as fast as I could send the data via carrier pigeon, this usually makes me want to storm Cupertino with a pitchfork.</p>

<p>Okay, so I could probably use Firefox or something else, but instead I figured I&#8217;d whip up<sup>*</sup> a shell script that lets me use my favoured long-haul download tool &#8211; curl.  And in case there were any other sufferers of insanely-priced broadband and Safari&#8217;s antisocial behaviour, I thought I&#8217;d share it.</p>

<p>It&#8217;ll ask for your Apple ID and password, and store it in the keychain for you, and it&#8217;ll resume from the current working directory.</p>

<p>Chuck it somewhere like <code>/usr/local/bin</code>, make sure it&#8217;s executable (<code>chmod +x /usr/local/bin/adc_download.sh</code>) and call it from Terminal like:</p>

<p><code>adc_download.sh https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_gm_seed/xcode_4_gm_seed_.dmg</code></p>

<p>If you&#8217;ve already started the download in Safari, just grab the partially-downloaded file from within the <em>.download</em> package Safari creates.</p>

<p>Here &#8217;tis:</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2011/11/adc_download.sh" title="adc_download.sh" alt="Adc download">adc_download.sh</a></p>

<p><em>Update: Now includes team support, thanks to <a href="http://cbowns.com/">Christopher Bowns</a> &#8212; see the comments at the top of the script for usage instructions.</em></p>

<p>P.S. I&#8217;d be interested to see how incremental updates fare when transferred from an intermediate server with rsync. It&#8217;s rather bizarre that Apple reissue the whole 3.x gb SDK with each update, rather than offering a &#8216;patch&#8217; (I guess Apple lives blithely in the world of cheap bandwidth!), and it makes me wonder whether there&#8217;d be sufficient correlation between versions to save some bandwidth by avoiding transferring the similarities&#8230;</p>

<p><small><sup>*</sup> read: spend hours on, as is my way.</small></p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2134" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/resuming-adc-downloads-cos-safari-sucks/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>OS X service to filter selected text through a shell command</title>
		<link>http://atastypixel.com/blog/os-x-service-to-filter-selected-text-through-a-shell-command/</link>
		<comments>http://atastypixel.com/blog/os-x-service-to-filter-selected-text-through-a-shell-command/#comments</comments>
		<pubDate>Sun, 23 May 2010 13:50:07 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/os-x-service-to-filter-selected-text-through-a-shell-command/</guid>
		<description><![CDATA[The UNIX shell provides a host of extremely useful utilities for modifying text. This Automator service makes all of them available for filtering text in all OS X applications.]]></description>
			<content:encoded><![CDATA[<p>The UNIX shell provides a host of extremely useful utilities for modifying text. This OS X Automator service makes all of them available for filtering text in all OS X applications.</p>

<p>This can be handy for performing quick operations, like replacing text with regular expressions, sorting lists or swapping fields around.</p>

<p>When triggered, the service requests a command to use for filtering, then runs the command and replaces the selected text with the result.</p>

<p>Some sample operations:</p>

<ul>
<li>Sort lines alphabetically/numerically: <tt>sort</tt> or <tt>sort -n</tt></li>
<li>Change to lowercase: <tt>tr "[:upper:]" "[:lower:]"</tt></li>
<li>Replace a spelling mistake, taking care of case: <tt>sed -E 's/([tT])eh/\1he/g'</tt></li>
<li>Re-order elements in a tab- or comma-separated list: <tt>awk '{print $2 $1}'</tt> or <tt>awk -F, '{print $2 "," $1}'</tt>
</ul>

<p><img src="http://atastypixel.com/blog/wp-content/uploads/2010/05/filter-service.jpg" width="400" height="397" alt="Filter through Shell Command service" class="aligncenter" /></p>

<p>Put it in <code>Library/Services</code>, and it should appear in the &#8216;Services&#8217; menu.</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2010/05/Filter-through-Shell-Command.zip" title="Filter through Shell Command.zip">Filter through Shell Command.zip</a></p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1913" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/os-x-service-to-filter-selected-text-through-a-shell-command/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Browsing Core Data databases using F-Script</title>
		<link>http://atastypixel.com/blog/browsing-core-data-databases-using-f-script/</link>
		<comments>http://atastypixel.com/blog/browsing-core-data-databases-using-f-script/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 12:00:37 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[F-Script]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1887</guid>
		<description><![CDATA[F-Script's new Core Data browser lets you open up and query any Core Data database, an invaluable debugging tool. Actually opening databases is a lengthy process through.  No longer: This Applescript app provides an easy interface to quickly open a Core Data database in F-Script's object browser.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fscript.org/">F-Script</a>, the Cocoa-based scripting environment, now provides some great tools for exploring Core Data databases.</p>

<p>I couldn&#8217;t figure out how to easily open up my databases, other than manually creating a managed object model, then a persistent store coordinator, then a managed object context on the console.  I couldn&#8217;t find any existing tools, and I wanted a quick workflow for opening up my databases, so I put together a script that prompts for the application bundle or <code>.xcdatamodel(d)</code> data model file, then prompts for the XML (<code>.xml</code>), binary (<code>.binary</code>) or SQLite (<code>.sql</code> or anything else) database file, and opens up the inspector.</p>

<p>I wrote it as an Applescript that just calls upon F-Script to evaluate the script, and saved it in an application bundle so I can pull it up quickly.</p>

<p>Here it is:</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2011/11/Core-Data-Browser.zip" title="Core Data Browser.zip" alt="Core Data Browser">Core Data Browser.app</a></p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2010/04/201004101417.jpg" rel="lightbox[1887]"><img src="http://atastypixel.com/blog/wp-content/uploads/2010/04/201004101417-tm.jpg" width="400" height="194" alt="201004101417.jpg" class="aligncenter" /></a></p>

<p>It just needs the F-Script app to be available.</p>

<p>Upon opening, the managed object context is available on the console as &#8220;<code>context</code>&#8220;. So, aside from using F-Script&#8217;s object browser, you can also do things like:</p>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">&gt; request <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSFetchRequest</span> alloc<span style="color: #002200;">&#41;</span> init
&gt; request setEntity<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEntityDescription</span> entityForName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'MyEntity'</span> inManagedObjectContext<span style="color: #002200;">:</span>context<span style="color: #002200;">&#41;</span>
&gt; request setPredicate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSPredicate</span> predicateWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'type = 3'</span><span style="color: #002200;">&#41;</span>
&gt; result <span style="color: #002200;">:=</span> context executeFetchRequest<span style="color: #002200;">:</span>request error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>
&gt; result
_PFArray <span style="color: #002200;">&#123;</span>&lt;NSManagedObject<span style="color: #002200;">:</span> 0x2006cf740&gt; <span style="color: #002200;">&#40;</span>entity<span style="color: #002200;">:</span> MyEntity; <span style="color: #a61390;">id</span><span style="color: #002200;">:</span> 0x20064c9e0 &lt;x<span style="color: #002200;">-</span>coredata<span style="color: #002200;">:</span><span style="color: #11740a; font-style: italic;">//BAC82A67-CC41-48C2-8A96-693B67A501D6/MyEntity/p1&gt; ; data: &lt;fault&gt;), </span>
&lt;NSManagedObject<span style="color: #002200;">:</span> 0x2006bdc80&gt; <span style="color: #002200;">&#40;</span>entity<span style="color: #002200;">:</span> MyEntity; <span style="color: #a61390;">id</span><span style="color: #002200;">:</span> 0x20064c9c0 &lt;x<span style="color: #002200;">-</span>coredata<span style="color: #002200;">:</span><span style="color: #11740a; font-style: italic;">//BAC82A67-CC41-48C2-8A96-693B67A501D6/MyEntity/p2&gt; ; data: &lt;fault&gt;), </span>
&lt;NSManagedObject<span style="color: #002200;">:</span> 0x2006bc680&gt; <span style="color: #002200;">&#40;</span>entity<span style="color: #002200;">:</span> MyEntity; <span style="color: #a61390;">id</span><span style="color: #002200;">:</span> 0x200651180 &lt;x<span style="color: #002200;">-</span>coredata<span style="color: #002200;">:</span><span style="color: #11740a; font-style: italic;">//BAC82A67-CC41-48C2-8A96-693B67A501D6/MyEntity/p3&gt; ; data: &lt;fault&gt;)</span>
...</pre></div></div>


<p><strong>Update</strong>: Now has better error reporting, and the option to load classes from a bundle.</p>

<p>For those interested, here&#8217;s the original F-Script:<span id="more-1887"></span></p>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">panel <span style="color: #002200;">:=</span> <span style="color: #400080;">NSOpenPanel</span> openPanel.
panel setAllowedFileTypes<span style="color: #002200;">:</span><span style="color: #002200;">&#123;</span><span style="color: #bf1d1a;">'xcdatamodel'</span>, <span style="color: #bf1d1a;">'app'</span>, <span style="color: #bf1d1a;">'framework'</span><span style="color: #002200;">&#125;</span>;setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Data model'</span>;setMessage<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Select a data model file or bundle containing a data model'</span>.
classesButton <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSButton</span> alloc<span style="color: #002200;">&#41;</span> initWithFrame<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>&lt;&gt;<span style="color: #2400d9;">0</span> extent<span style="color: #002200;">:</span><span style="color: #2400d9;">200</span>&lt;&gt;<span style="color: #2400d9;">30</span><span style="color: #002200;">&#41;</span>.
classesButton setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Load classes in bundle'</span>;setButtonType<span style="color: #002200;">:</span>NSSwitchButton.
panel setAccessoryView<span style="color: #002200;">:</span>classesButton.
model <span style="color: #002200;">:=</span> <span style="color: #a61390;">nil</span>.
<span style="color: #002200;">&#91;</span>model <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> whileTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
	error <span style="color: #002200;">:=</span> FSPointer objectPointer.
	<span style="color: #002200;">&#40;</span>panel runModal <span style="color: #002200;">=</span> NSFileHandlingPanelCancelButton<span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSException</span> exceptionWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'CancelException'</span> reason<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Cancelled'</span> userInfo<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">raise</span> <span style="color: #002200;">&#93;</span> .
	<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span> absoluteString<span style="color: #002200;">&#41;</span> hasSuffix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'xcdatamodel'</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
		model <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSManagedObjectModel</span> alloc<span style="color: #002200;">&#41;</span> initWithContentsOfURL<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#93;</span> ifFalse<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
		bundle <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSBundle</span> bundleWithURL<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>.
		<span style="color: #002200;">&#40;</span>bundle <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> ifFalse<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
			model <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSManagedObjectModel</span> mergedModelFromBundles<span style="color: #002200;">:</span><span style="color: #002200;">&#123;</span>bundle<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>.
			<span style="color: #002200;">&#40;</span>model ~~ <span style="color: #a61390;">nil</span> <span style="color: #002200;">&amp;</span> <span style="color: #002200;">&#40;</span>FSBoolean booleanWithBool<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>classesButton state<span style="color: #002200;">&#41;</span> <span style="color: #002200;">=</span> NSOnState<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
				<span style="color: #002200;">&#40;</span>FSBoolean booleanWithBool<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>bundle loadAndReturnError<span style="color: #002200;">:</span>error<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> ifFalse<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
					model <span style="color: #002200;">:=</span> <span style="color: #a61390;">nil</span>.
					<span style="color: #002200;">&#40;</span><span style="color: #400080;">NSAlert</span> alertWithMessageText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Could not load bundle'</span> defaultButton<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'OK'</span> alternateButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> informativeTextWithFormat<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>error at<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> localizedDescription<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> runModal
				<span style="color: #002200;">&#93;</span>
			<span style="color: #002200;">&#93;</span>
		<span style="color: #002200;">&#93;</span>
	<span style="color: #002200;">&#93;</span>.
	<span style="color: #002200;">&#40;</span>model <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span> <span style="color: #002200;">&amp;</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>error at<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSAlert</span> alertWithMessageText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Could not load model from file or bundle'</span> defaultButton<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'OK'</span> alternateButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> informativeTextWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">''</span><span style="color: #002200;">&#41;</span> runModal <span style="color: #002200;">&#93;</span>
<span style="color: #002200;">&#93;</span>.
panel setAccessoryView<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>.
store <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSPersistentStoreCoordinator</span> alloc<span style="color: #002200;">&#41;</span> initWithManagedObjectModel<span style="color: #002200;">:</span>model<span style="color: #002200;">&#41;</span>.
panel setAllowedFileTypes<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>; setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Database file'</span>;setMessage<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Select Core Data SQLite database'</span>.
opened <span style="color: #002200;">:=</span> <span style="color: #a61390;">nil</span>.
<span style="color: #002200;">&#91;</span>opened <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> whileTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>
	<span style="color: #002200;">&#40;</span>panel runModal <span style="color: #002200;">=</span> NSFileHandlingPanelCancelButton<span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSException</span> exceptionWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'CancelException'</span> reason<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Cancelled'</span> userInfo<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">raise</span> <span style="color: #002200;">&#93;</span> .
	type <span style="color: #002200;">:=</span> NSSQLiteStoreType.
	<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span> absoluteString<span style="color: #002200;">&#41;</span> lowercaseString<span style="color: #002200;">&#41;</span> hasSuffix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'xml'</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>type <span style="color: #002200;">:=</span> NSXMLStoreType<span style="color: #002200;">&#93;</span>.
	<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span> absoluteString<span style="color: #002200;">&#41;</span> lowercaseString<span style="color: #002200;">&#41;</span> hasSuffix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'binary'</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>type <span style="color: #002200;">:=</span> NSBinaryStoreType<span style="color: #002200;">&#93;</span>.
	error <span style="color: #002200;">:=</span> FSPointer objectPointer.
	opened <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span>store addPersistentStoreWithType<span style="color: #002200;">:</span>type configuration<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> URL<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>panel URL<span style="color: #002200;">&#41;</span> options<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> error<span style="color: #002200;">:</span>error<span style="color: #002200;">&#41;</span>.
	<span style="color: #002200;">&#40;</span>opened <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> ifTrue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSAlert</span> alertWithMessageText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'Could not load database'</span> defaultButton<span style="color: #002200;">:</span><span style="color: #bf1d1a;">'OK'</span> alternateButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> otherButton<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> informativeTextWithFormat<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>error at<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> localizedDescription<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> runModal <span style="color: #002200;">&#93;</span>
<span style="color: #002200;">&#93;</span>.
context <span style="color: #002200;">:=</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSManagedObjectContext</span> alloc<span style="color: #002200;">&#41;</span> init<span style="color: #002200;">&#41;</span>.
context setPersistentStoreCoordinator<span style="color: #002200;">:</span>store.
context inspectWithSystem<span style="color: #002200;">:</span>sys</pre></div></div>

 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1887" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/browsing-core-data-databases-using-f-script/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Searching through Subversion history</title>
		<link>http://atastypixel.com/blog/searching-through-subversion-history/</link>
		<comments>http://atastypixel.com/blog/searching-through-subversion-history/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 15:55:21 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1863</guid>
		<description><![CDATA[Occasionally I need to search back through old versions of projects to find a piece of code I want to resurrect or just use as reference &#8212; I haven&#8217;t found any easy built-in way to do this, so I adapted this useful script to allow me to grep through all history from within a Subversion [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I need to search back through old versions of projects to find a piece of code I want to resurrect or just use as reference &#8212; I haven&#8217;t found any easy built-in way to do this, so I adapted <a href="http://svn.haxx.se/users/archive-2006-09/1062.shtml">this useful script</a> to allow me to grep through all history from within a Subversion working directory, like:</p>


<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ svngrep SecItemCopyMatching *
LSAddAccountController.m @r7: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r4: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r2: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
LSAddAccountController.m @r1: SecItemCopyMatching((CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:</pre></div></div>


<p>Here&#8217;s the script:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">pattern</span>=<span style="color: #007800;">$1</span>
<span style="color: #7a0874; font-weight: bold;">shift</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #000000; font-weight: bold;">@</span>; 
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #c20cb9; font-weight: bold;">svn</span> log <span style="color: #660033;">-q</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'print &quot;$1\n&quot; if /^r(\d+)/'</span> <span style="color: #000000; font-weight: bold;">|</span> 
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> r 
  <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">match</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$r</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pattern</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">result</span>=<span style="color: #007800;">$?</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$result</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$file</span> @r<span style="color: #007800;">$r</span>: &quot;</span>
      <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$match</span>;
    <span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$result</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span>;</pre></div></div>

 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1863" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/searching-through-subversion-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using custom DNS servers from the iPhone and over Internet Tethering</title>
		<link>http://atastypixel.com/blog/using-custom-dns-servers-from-the-iphone-and-over-internet-tethering/</link>
		<comments>http://atastypixel.com/blog/using-custom-dns-servers-from-the-iphone-and-over-internet-tethering/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 21:01:17 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2010/01/24/using-custom-dns-servers-from-the-iphone-and-over-internet-tethering-3/</guid>
		<description><![CDATA[For those of us the roam around on network connections, OpenDNS and Google Public DNS provide public DNS servers which offer better security than using arbitrary DNS that&#8217;s assigned to us when we connect to a network. This means that rather than trusting the assigned DNS server &#8212; which could be a malicious third party [...]]]></description>
			<content:encoded><![CDATA[<p>For those of us the roam around on network connections, <a href="http://www.opendns.com">OpenDNS</a> and <a href="http://code.google.com/speed/public-dns/">Google Public DNS</a> provide public DNS servers which offer better security than using arbitrary DNS that&#8217;s assigned to us when we connect to a network.  This means that rather than trusting the assigned DNS server &#8212; which could be a malicious third party that&#8217;s attempting a man-in-the-middle attack &#8212; we always use a trusted server.</p>

<p>In OS X, normally, one can specify custom DNS servers in Network Preferences, but when using Internet Tethering with the iPhone, no options are available.</p>

<p>It&#8217;s possible to set DNS configuration on the command line, though, as mentioned in <a href="http://www.macosxhints.com/article.php?story=20050621051643993">this MacOSXHints article</a>.</p>

<p>This technique can be used within a <a href="http://stackoverflow.org/wiki/Set_the_DNS_server_under_OS_X">shell script</a> to make things easier.</p>

<p>As it happens, if you have a jailbroken iPhone, the trick works there too &#8212; just <code>ssh</code> in as root, copy the script over, and run it from the iPhone.</p>

<p>The one caveat is that the DHCP client both on the iPhone and on Mac OS X will routinely reset the servers &#8212; I haven&#8217;t found a way to combat this yet, other than routinely re-running the script.</p>

<p>We have been using mobile broadband from my iPhone while we&#8217;ve been <a href="http://michael.tyson.id.au/about">travelling</a>; our current <a href="http://michael.tyson.id.au/dk2oa">provider</a> seems to go offline almost every evening &#8212; a quirk which I&#8217;ve just discovered is related to their faulty DNS server.</p>

<p>Using Google&#8217;s public DNS servers instead fixes this problem, so I was after a way to configure both the iPhone and OS X to use the servers.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1844" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/using-custom-dns-servers-from-the-iphone-and-over-internet-tethering/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Textmate: &#8216;git diff&#8217; in FileMerge</title>
		<link>http://atastypixel.com/blog/textmate-git-diff-in-filemerge/</link>
		<comments>http://atastypixel.com/blog/textmate-git-diff-in-filemerge/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 18:50:01 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Textmate]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2010/01/04/textmate-git-diff-in-filemerge/</guid>
		<description><![CDATA[I found myself wanting to pick through some changes I made under a git repository recently, discarding some and adapting others. The FileMerge utility that comes with the Mac OS X Developer Tools is great for this purpose, but in TextMate, there&#8217;s currently no way to compare uncommitted changes in a git repository using FileMerge. [...]]]></description>
			<content:encoded><![CDATA[<p>I found myself wanting to pick through some changes I made under a git repository recently, discarding some and adapting others.  The FileMerge utility that comes with the Mac OS X Developer Tools is great for this purpose, but in TextMate, there&#8217;s currently no way to compare uncommitted changes in a git repository using FileMerge.</p>

<p>Now there is!</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2010/01/View-Uncommitted-Changes-in-FileMerge.tmCommand.zip" title="View Uncommitted Changes in FileMerge.tmCommand.zip">View Uncommitted Changes in FileMerge.tmCommand.zip</a></p>

<p>Double click to install it in Textmate; it appears under the &#8216;Git&#8217; bundle.  I suggest you then select the &#8216;Git&#8217; bundle group header, and drag this command (&#8216;<em>View Uncommitted Changes in FileMerge</em>&#8216;) up to the top of the menu list on the right, so it&#8217;s accessible via Control-Shift-G, 1.</p>

<p>It&#8217;s based on <a href="http://github.com/textmate/filemerge.tmbundle">filemerge.tmbundle</a>.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1738" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/textmate-git-diff-in-filemerge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Align comments in Textmate</title>
		<link>http://atastypixel.com/blog/align-comments-in-textmate/</link>
		<comments>http://atastypixel.com/blog/align-comments-in-textmate/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 12:30:02 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/03/27/align-comments-in-textmate/</guid>
		<description><![CDATA[A Textmate command script to align comments in a block]]></description>
			<content:encoded><![CDATA[<p>Unless I&#8217;m using Objective-C, which is fantastically self-documenting, I often like to add comments to parameters to remind me of what they do.  For example:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">imagecopy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$frame</span><span style="color: #339933;">,</span> 
          <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #990000;">max</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topLeftCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Destination x</span>
          <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Destination y</span>
          <span style="color: #000088;">$x</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Source x</span>
          <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Source y</span>
          <span style="color: #990000;">min</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topLeftCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Source width</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapHeight<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Source height</span></pre></div></div>


<p>The only thing is, it looks terrible and is very hard to read.  I usually carefully insert spaces before the comments so they line up, but that&#8217;s really hard to maintain.</p>

<p>I use <a href="http://macromates.com/">Textmate</a>, and found an &#8216;Align Assignments&#8217; script by Chris Poirier which applies very nice formatting to a block of assignments.</p>

<p>Some trivial modifications resulted in a similar script to align comments. Hit <em>Ctrl-Option-Command-/</em>, and:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">imagecopy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$frame</span><span style="color: #339933;">,</span> 
          <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #990000;">max</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topLeftCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Destination x</span>
          <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>                                                                            <span style="color: #666666; font-style: italic;">// Destination y</span>
          <span style="color: #000088;">$x</span><span style="color: #339933;">,</span>                                                                           <span style="color: #666666; font-style: italic;">// Source x</span>
          <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>                                                                            <span style="color: #666666; font-style: italic;">// Source y</span>
          <span style="color: #990000;">min</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">-</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topLeftCap</span><span style="color: #009900;">&#91;</span>kCapWidth<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>      <span style="color: #666666; font-style: italic;">// Source width</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">topRightCap</span><span style="color: #009900;">&#91;</span>kCapHeight<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                              <span style="color: #666666; font-style: italic;">// Source height</span></pre></div></div>


<p>Here it is:</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2009/03/align-commentstmcommand1.zip" title="Align Comments.tmCommand.zip">Align Comments.tmCommand.zip</a></p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1559" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/align-comments-in-textmate/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Facebook News Feed RSS</title>
		<link>http://atastypixel.com/blog/facebook-news-feed-rss/</link>
		<comments>http://atastypixel.com/blog/facebook-news-feed-rss/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 22:26:13 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/02/19/facebook-news-feed-rss/</guid>
		<description><![CDATA[A PHP script to crawl the Facebook news items and create an RSS feed from them]]></description>
			<content:encoded><![CDATA[<p>Tired of either logging into Facebook frequently, or being entirely oblivious to friends&#8217; activities, I was searching for a way to view the Facebook front page news feed as RSS, so I could load it into my news reader and forget about it.</p>

<p><a href="http://blog.nemik.net/2006/09/06/facebook-news-feed-rss/">&#8216;Nemik&#8217;</a> has created such a thing and kindly made it available.  It was a bit elderly, and didn&#8217;t work with the new Facebook, so I jazzed it up a bit.</p>

<p>Put it on a webserver, configure it, and access the URL to view the RSS feed. Probably a very good idea to provide <a href="http://www.google.com/search?hl=en&amp;q=htaccess%20password&amp;btnG=Search&amp;meta=">password protection</a>, as well.</p>

<p>Use at your own risk, and Facebook, please don&#8217;t sue me.</p>

<p><a href="http://atastypixel.com/blog/wp-content/uploads/2009/02/facebook-rss.zip" title="facebook-rss.zip">Download the script here</a></p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1439" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/facebook-news-feed-rss/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Counting words in LaTeX documents with TextMate</title>
		<link>http://atastypixel.com/blog/counting-words-in-latex-documents-with-textmate/</link>
		<comments>http://atastypixel.com/blog/counting-words-in-latex-documents-with-textmate/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 01:06:51 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/01/23/counting-words-in-latex-documents-with-textmate/</guid>
		<description><![CDATA[When working on LaTeX documents in TextMate, the default word count feature isn&#8217;t too helpful, as it also includes all of the LaTeX control sequences in the count. There are plenty of suggestions out there, but this is one I came up with, which works the same way as the default word count facility (Ctrl-Shift-N): [...]]]></description>
			<content:encoded><![CDATA[<p>When working on LaTeX documents in TextMate, the default word count feature isn&#8217;t too helpful, as it also includes all of the LaTeX control sequences in the count.  There are plenty of suggestions out there, but this is one I came up with, which works the same way as the default word count facility (<em>Ctrl-Shift-N</em>):</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby -wKU</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> pretty<span style="color:#006600; font-weight:bold;">&#40;</span>number<span style="color:#006600; font-weight:bold;">&#41;</span>
  number.<span style="color:#9900CC;">to_s</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">1</span>,<span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#40;</span>?=\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span>?!\d<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">'<span style="color:#000099;">\0</span>,'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
counts = <span style="color:#996600;">`detex -l | wc -lwc`</span>.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">+/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
counts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> = counts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1</span> <span style="color:#008000; font-style:italic;"># increase one to the line count</span>
&nbsp;
<span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#91;</span> line word byte <span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>unit<span style="color:#006600; font-weight:bold;">|</span>
  cnt    = counts.<span style="color:#9900CC;">shift</span>
  plural = cnt.<span style="color:#9900CC;">to_i</span> != <span style="color:#006666;">1</span> ? <span style="color:#996600;">'s'</span> : <span style="color:#996600;">''</span>
  <span style="color:#CC0066; font-weight:bold;">printf</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;%11.11s %s%s<span style="color:#000099;">\n</span>&quot;</span>, pretty<span style="color:#006600; font-weight:bold;">&#40;</span>cnt<span style="color:#006600; font-weight:bold;">&#41;</span>, unit, plural<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>This is just a copy of the default statistics action from the Text bundle, but with the &#8216;detex&#8217; utility added into the pipeline to remove all LaTeX control sequences.</p>

<p>Put this in a new command in the LaTeX bundle, with &#8216;Selected Text&#8217; for input, and &#8216;Show as Tool Tip&#8217; for output. I assigned <em>Ctrl-Shift-N</em> as the key equivalent.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1296" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/counting-words-in-latex-documents-with-textmate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apple iTunes Connect Trend/Transaction Report Processor</title>
		<link>http://atastypixel.com/blog/apple-itunes-connect-trendtransaction-report-processor/</link>
		<comments>http://atastypixel.com/blog/apple-itunes-connect-trendtransaction-report-processor/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 18:34:52 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/01/01/apple-itunes-connect-trendtransaction-report-processor/</guid>
		<description><![CDATA[A droplet for Mac OS X to calculate a single total earnings figure from a Trend/Transaction Report from Apple's iTunes Connect.]]></description>
			<content:encoded><![CDATA[<p><a href="http://atastypixel.com/blog/wp-content/uploads/2009/01/process-transaction-reports.zip"><img src="http://atastypixel.com/blog/wp-content/uploads/2009/01/processtransactionreports.png" width="256" height="256" alt="Process Transaction Reports" title="Process Transaction Reports" style="float: right;" class="noframe" /></a></p>

<p>I&#8217;ve written a droplet which takes a transaction report, as downloaded from iTunes Connect and containing a summary of sales, and produces a single figure representing the total earnings, in a particular currency.</p>

<p>Because the report shows sales for each separate region, a bit of work is required to get a total earnings figure, involving multiplying royalties by number of sales for each region, and then converting each currency type and adding all results together.  This droplet does it all for you &#8211; just drop the downloaded text file from iTunes Connect onto it and it&#8217;ll bring up a summary.  A preferences window allows configuration of the currency.</p>

<p>Currency conversion information provided by <a href="http://www.timegenie.com/" title="foreign exchange rates courtesy of timegenie.com">timegenie.com</a>.</p>

<p>&lt;</p>

<p>p>Download it here: <a href="http://atastypixel.com/blog/wp-content/uploads/2009/01/process-transaction-reports.zip">Process Transaction Reports droplet</a></p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1258" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/apple-itunes-connect-trendtransaction-report-processor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A OS X service to encode HTML characters</title>
		<link>http://atastypixel.com/blog/a-os-x-service-to-encode-html-characters/</link>
		<comments>http://atastypixel.com/blog/a-os-x-service-to-encode-html-characters/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 02:08:13 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2008/11/14/a-os-x-service-to-encode-html-characters/</guid>
		<description><![CDATA[I find myself frequently writing HTML code in comment forms which support use of HTML formatting, which means that I have to encode the html entities if I want them to show up (as in representing '&#62;' with '&#38;gt;', for example).  ...  I used the always-useful  ThisService  app with a short PHP script which does a  htmlspecialchars()  on whatever's passed to it, to create a OS X service called 'Encode HTML'.]]></description>
			<content:encoded><![CDATA[<p>I find myself frequently writing HTML code in comment forms which support use of HTML formatting, which means that I have to encode the html entities if I want them to show up (as in representing &#8216;&gt;&#8217; with &#8216;&amp;gt;&#8217;, for example).</p>

<p>This gets rather tiresome, particularly if there&#8217;s a fair chunk of text to encode by hand.</p>

<p>I used the always-useful <a href="http://wafflesoftware.net/thisservice/">ThisService</a> app with a short PHP script which does a <em>htmlspecialchars()</em> on whatever&#8217;s passed to it, to create a OS X service called &#8216;<a href="http://atastypixel.com/blog/wp-content/uploads/2008/11/encodehtmlservice.zip" title="EncodeHtml.service.zip">Encode HTML</a>&#8216;. Put it in your <i>Library/Services</i> directory, possibly log out and back in again, and you&#8217;ll be set.</p>

<p>Select the text to encode, click the system menu, Services, Encode HTML, and it&#8217;ll be automatically encoded in place.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1158" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/a-os-x-service-to-encode-html-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping iChat and Adium status in sync with Twitter</title>
		<link>http://atastypixel.com/blog/keeping-ichat-and-adium-status-in-sync-with-twitter/</link>
		<comments>http://atastypixel.com/blog/keeping-ichat-and-adium-status-in-sync-with-twitter/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 02:39:58 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2008/10/10/keeping-ichat-and-adium-status-in-sync-with-twitter/</guid>
		<description><![CDATA[A script which takes the latest tweet from Twitter and sets it as the status message in iChat and/or Adium. Use crontab to run it regularly to stay in sync.]]></description>
			<content:encoded><![CDATA[<p>I’ve been using Twitter for a while now, and I’ve just started doing ‘global’ status updates across Twitter, Facebook, and my instant messenger account statuses for iChat and Adium. Usually I use <a href="http://blog.circlesixdesign.com/download/moodswing/">MoodBlast</a>, a really nice application which lets me use a global keyboard shortcut to quickly enter a tweet and hit enter to update everything simultaneously.</p>

<p>However, if I want to update from, say, <a href="http://tapulous.com/twinkle/">Twinkle</a> on my iPhone (<small>side-note: Wow, Tapulous need to do some serious SEO &#8211; their Twitter site isn’t even on the first page of Google hits. <em>I’m</em> on the first page of Google hits for it, ferchrissake</small>) the sync won’t happen. This Ruby script will do the trick.</p>

<p><span id="more-867"></span>Download: <a href="http://atastypixel.com/blog/wp-content/uploads/2009/03/sync-status-with-twitterrb2.zip" title="sync-status-with-twitter.rb.zip">Sync Status With Twitter</a></p>

<p>To use it:</p>

<ol>
    <li>Extract the <em>.rb</em> file to ~/Library/Scripts</li>
    <li>Open it in, say, TextEdit and edit ‘Username’ at the top of the file to match your username</li>
    <li>Open Terminal (in <em>Applications, Utilities</em>)</li>
    <li>Make the script executable: <tt>chmod +x ~/Library/Scripts/sync-status-with-twitter.rb</tt></li>
    <li>Open your crontab: <tt>crontab -e</tt></li>
    <li>Add a line to crontab to run the script regularly:
<ul>
    <li>Press ‘<tt>o</tt>’ to insert a new line</li>
    <li>Paste the following line:
<blockquote><tt>*/30 * * * * ~/Library/Scripts/sync-status-with-twitter.rb</tt></blockquote>
The ‘30’ here means run every 30 minutes. Change it if you want. Some alternatives are:
<blockquote><tt>*/10 * * * *…</tt> &#8211; Every 10 minutes
<tt>0 * * * *…</tt> &#8211; Hourly, on the hour
<tt>0 */2 * * *…</tt> &#8211; Every second hour, on the hour</blockquote>
</li>
    <li>Press escape to stop editing</li>
    <li>Hold down shift and press ZZ (Z key twice) to save and quit</li>
</ul>
</li>
    <li>You’re done. Wait a little bit and it’ll update, or if you like, run it immediately from Terminal (<tt>~/Library/Scripts/sync-status-with-twitter.rb</tt>).</li>
</ol>

<p>If you want to update Facebook too, you have two options: <del>Either use the excellent Facebook plugin for Adium (comes with the latest version), and it’ll happen all by default</del> [<em><strong>Edit</strong>: Looks like I'm wrong; Adium won't update Facebook</em>] , or add the Twitter application to Facebook itself.</p>

<p>This script was inspired by a <a href="http://railstips.org/2008/5/2/update-your-friends-ichat-status-with-a-twitter-direct-message-simply-because-you-can">similar script by John Nunemaker over at RailsTips.org</a>. Thanks, John.</p>

<p><b>Update:</b> <a href="http://abednarz.net/">Bed</a> has made some changes which will <a href="http://abednarz.net/wp/twitter-adium-status-syncing-ignoring-replies/">ignore @reply messages</a>.</p>

<p><b>Update:</b> I&#8217;ve also added an implementation to ignore @reply messages</p>

<p><b>Update:</b> I&#8217;ve added a provision to only update the status if you&#8217;re not set as away &#8211; if you&#8217;re away, the status message will remain unchanged.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=867" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/keeping-ichat-and-adium-status-in-sync-with-twitter/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

