<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brett Terpstratextmate - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/textmate/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Thu, 09 Feb 2012 15:01:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>An average morning</title>
		<link>http://brettterpstra.com/an-average-morning/</link>
		<comments>http://brettterpstra.com/an-average-morning/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 17:00:34 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2622</guid>
		<description><![CDATA[<p>I was looking at some numbers on a web page. A wide variety of fairly large numbers. The web page didn’t provide any kind of average for the numbers, and I was curious. Curious, of course, meant writing a script to solve the problem. Yes, I could have copied the numbers out, punched them into a calculator one by one,&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/an-average-morning/">An average morning</a></p>]]></description>
			<content:encoded><![CDATA[<p>I was looking at some numbers on a web page. A wide variety of fairly large numbers. The web page didn’t provide any kind of average for the numbers, and I was curious. Curious, of course, meant writing a script to solve the problem. Yes, I could have copied the numbers out, punched them into a calculator one by one, or opened up Numbers and pasted them into cells… bah. I wanted to be able to copy text with all kinds of other junk in it and just get the average of all the values in contained quickly and easily (even if that meant wasting twice as much time up front).</p>

<p>I wrote the basic script in Ruby to run as a TextMate command:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">input = STDIN.<span class="me1">read</span>
&nbsp;
<span class="co1"># Quick function to add commas to long values</span>
<span class="kw1">def</span> add_commas<span class="br0">&#40;</span> number <span class="br0">&#41;</span>
  number.<span class="me1">to_s</span>.<span class="me1">reverse</span>.<span class="me1">scan</span><span class="br0">&#40;</span><span class="sy0">/</span><span class="br0">&#40;</span>?:\d<span class="sy0">*</span>\.<span class="br0">&#41;</span>?\d<span class="br0">&#123;</span><span class="nu0">1</span>,<span class="nu0">3</span><span class="br0">&#125;</span><span class="sy0">-</span>?<span class="sy0">/</span><span class="br0">&#41;</span>.<span class="me1">join</span><span class="br0">&#40;</span><span class="st0">','</span><span class="br0">&#41;</span>.<span class="me1">reverse</span>
<span class="kw1">end</span>
&nbsp;
<span class="co1"># Scan for numbers in the text</span>
arr = input.<span class="me1">scan</span><span class="br0">&#40;</span><span class="sy0">/</span>\.?\d<span class="br0">&#91;</span>\d,<span class="br0">&#93;</span><span class="sy0">+</span><span class="br0">&#40;</span>?:\.\d<span class="sy0">+</span><span class="br0">&#41;</span>?<span class="sy0">/</span><span class="br0">&#41;</span>.<span class="me1">map</span><span class="br0">&#123;</span><span class="sy0">|</span>line<span class="sy0">|</span>
  <span class="co1"># remove non-decimal characters from results and convert to float</span>
  line.<span class="kw3">gsub</span><span class="br0">&#40;</span><span class="sy0">/</span><span class="br0">&#91;</span>^\d\.<span class="br0">&#93;</span><span class="sy0">/</span>,<span class="st0">''</span><span class="br0">&#41;</span>.<span class="me1">to_f</span>
<span class="br0">&#125;</span>.<span class="me1">sort</span>
&nbsp;
<span class="kw3">print</span> input <span class="co1"># output the original text</span>
&nbsp;
<span class="co1"># if there were 2 or more numbers found, output the additional information</span>
<span class="kw3">print</span> <span class="st0">&quot;<span class="es0">\n</span> - Average of #{arr.size} numbers ranging from #{arr[0]} to #{arr[arr.size-1]}: &quot;</span> <span class="sy0">+</span> add_commas<span class="br0">&#40;</span>arr.<span class="me1">inject</span><span class="br0">&#40;</span><span class="nu0">0.0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="sy0">|</span>sum,el<span class="sy0">|</span> sum <span class="sy0">+</span> el <span class="br0">&#125;</span> <span class="sy0">/</span> arr.<span class="me1">size</span> <span class="br0">&#41;</span> <span class="kw1">unless</span> arr.<span class="me1">empty</span>? <span class="sy0">||</span> arr.<span class="me1">size</span> == <span class="nu0">1</span></pre></div></div>


<p>The script is simple enough that it should be easily adjustable to perform any kind of basic math on the array of numbers found in the text. The numbers don’t have to be in any order in the input; they can be listed vertically or horizontally or can just be scattered throughout text or messy table code. The regular expression should find them.</p>

<p>The TextMate command suited my needs just fine, but then I started thinking about sharing it. What format would make the most sense? A System Service that accepted text and appended a line with the average? A TextExpander snippet that ran on the clipboard? A LaunchBar action that worked with Instant Send or Copy/Paste? I couldn’t decide, and since the script was the only time-consuming part, I went ahead and made all of the above.</p>

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

<p>The TextExpander snippet is now in the Tools group of my TextExpander projects. If you’re subscribed to that group via URL, your group already updated with the “Average numbers in clipboard” snippet. Otherwise, go ahead and <a href="http://brettterpstra.com/share/te-snippets/index.php?group=Tools&amp;prefix=,,">download it or set up a new subscription</a>.</p>

<p>The other two versions (and the script) are in the download below, and I threw in the original TextMate command, too. The LaunchBar action is actually a Script Bundle with the Ruby script packaged inside. If you’ve ever wondered how to reference a self-contained script in AppleScript, it’s a decent example. It installs to <code>~/Library/Application Support/LaunchBar/Actions</code>. The System Service is a standard Automator action using the script above, and installs to <code>~/Library/Services</code>.</p>

<p>Want to see a video of it? Really? Why? I’m in that semi-asleep state where I thought it would be easier to show what it does than explain it. Since I doubt anyone else really has a need for this script, the video is a tribute to my ability to waste time in the early morning.</p>


  <!-- Begin Video.js -->
  <video class="video-js vjs-default-skin" width="600" height="338" poster="/share/video/average/averagePoster.jpg" controls 0 data-setup="{}">
    <source src="/share/video/average/average.mp4" type='video/mp4' />
    <source src="/share/video/average/average.webm" type='video/webm; codecs="vp8, vorbis"' />
    <source src="/share/video/average/average.ogv" type='video/ogg; codecs="theora, vorbis"' />
  </video>
  <!-- End Video.js -->


<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AverageNumbers.zip?9d7bd4" title="Download Average Numbers in Selection (44)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2011/09/AverageIcon.png?9d7bd4" alt="download image for Average Numbers in Selection" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AverageNumbers.zip?9d7bd4" title="Download Average Numbers in Selection (44)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AverageNumbers.zip?9d7bd4" title="Download Average Numbers in Selection (44)">Average Numbers in Selection</a> — A Ruby script, an OS X System Service and a LaunchBar action for finding any numbers in a block of text and returning the average. Also see the <a href="http://brettterpstra.com/share/te-snippets/index.php?group=Tools">Tools group</a> of the TextExpander Tools for a snippet version. <a href="http://brettterpstra.com/an-average-morning/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/geeklet-1-minute-average-cpu-load/' rel='bookmark' title='Geeklet: 1-minute average CPU load'>Geeklet: 1-minute average CPU load</a></li>
<li><a href='http://brettterpstra.com/seriously-easy-html5-video-encoding/' rel='bookmark' title='Seriously easy HTML5 video encoding'>Seriously easy HTML5 video encoding</a></li>
<li><a href='http://brettterpstra.com/fog-in-the-valley/' rel='bookmark' title='Fog In The Valley'>Fog In The Valley</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/an-average-morning/">An average morning</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/an-average-morning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A couple of TextMate Macros for Markdown lists</title>
		<link>http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/</link>
		<comments>http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/#comments</comments>
		<pubDate>Sun, 24 Apr 2011 17:59:51 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[multimarkdown]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2238</guid>
		<description><![CDATA[<p>I was playing with the new TextMate Markdown bundle for MultiMarkdown 3 when I remembered an old nit I had with the list commands: no single-keystroke way to move list items up and down. Unless I’m completely forgetting about a shortcut, moving list items around involves selecting the entire line and using Control-Command-Up/Down to move it. Obviously, not a big&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/">A couple of TextMate Macros for Markdown lists</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/getting_out_of_order.jpg?9d7bd4" alt="That's funny. If you can't see this picture, you're missing out." class="alignright"/>I was playing with the new <a href="http://macromates.com">TextMate</a> Markdown bundle for <a href="https://github.com/fletcher/peg-multimarkdown">MultiMarkdown 3</a> when I remembered an old nit I had with the list commands: no single-keystroke way to move list items up and down. Unless I’m completely forgetting about a shortcut, moving list items around involves selecting the entire line and using Control-Command-Up/Down to move it. Obviously, not a big deal, but 5 minutes with the Macro recorder in TextMate saves the time.</p>

<p>Control-Right and Control-Left are already set up in the Markdown bundle to indent and outdent lines within lists. These two macros just add Control-Up and Control-Down for quickly shifting the order of a list. They only work with single lines; if you want to move a chunk of lines, you’ll want to use the old select and hit Control-Command-Up/Down method.</p>

<p>You can <a href="http://brettterpstra.com/downloads/MarkdownListMacros.zip?9d7bd4">download the TextMate List Macros</a> from here, but for more details, check out the video I added to the <a href="http://bundle.weblogzinc.com/video/?p=123">Blogsmith Bundle Video Site</a>.</p>

<p>Here’s a quick, semi-related tip: TextMate’s Web Preview running through MultiMarkdown 3 is wicked fast. There’s no visible latency. It’s practically an nvALT killer for people who primarily use nvALT for its MultiMarkdown preview. Definitely give it a shot. Fletcher Penney’s <a href="http://fletcherpenney.net/2011/04/multimarkdown_in_textmate_preview">video on setup and usage</a> is all you need. Well, that and <a href="https://github.com/fletcher/peg-multimarkdown/downloads/">MultiMarkdown 3</a>. By the way, the next release of <a href="http://brettterpstra.com/project/nvalt/">nvALT</a> deals much better with custom MultiMarkdown 3 installs. Coming soon.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/' rel='bookmark' title='AutoTag2: smarter tagging for TextMate and WordPress'>AutoTag2: smarter tagging for TextMate and WordPress</a></li>
<li><a href='http://brettterpstra.com/nvalt-2-1-progress-report/' rel='bookmark' title='nvALT 2.1 progress report'>nvALT 2.1 progress report</a></li>
<li><a href='http://brettterpstra.com/new-markdown-service-tool-html-to-clipboard/' rel='bookmark' title='New Markdown Service tool: HTML to Clipboard'>New Markdown Service tool: HTML to Clipboard</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/">A couple of TextMate Macros for Markdown lists</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>AutoTag2: smarter tagging for TextMate and WordPress</title>
		<link>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/</link>
		<comments>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 20:11:53 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[tagging]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2154</guid>
		<description><![CDATA[<p>I was tooling around the Vim website looking at blogging plugins this morning. I noticed that one of them, Vimpress, had linked to an old project of mine that allowed you to work with Ultimate Tag Warrior tags through XML-RPC. Since the inclusion of tagging support in WordPress, Ultimate Tag Warrior has been defunct, and so have the UTW-RPC plugin&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/">AutoTag2: smarter tagging for TextMate and WordPress</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/autotag_add_tags_panel.jpg?9d7bd4" alt="Autotag Add Tags panel" height="469" width="349" class="alignright">I was tooling around the <a href="http://www.vim.org">Vim website</a> looking at blogging plugins this morning. I noticed that one of them, <a href="http://www.vim.org/scripts/script.php?script_id=1953">Vimpress</a>, had linked to an old <a href="http://blog.circlesixdesign.com/download/utw-rpc-autotag/">project of mine</a> that allowed you to work with Ultimate Tag Warrior tags through <a href="http://en.wikipedia.org/wiki/XML-RPC">XML-RPC</a>. Since the inclusion of tagging support in WordPress, Ultimate Tag Warrior has been defunct, and so have the UTW-RPC plugin and associated AutoTag TextMate bundle.</p>

<p>Thinking about it for a minute, I realized I really did miss the functionality that AutoTag had given me. While I’ve toyed around with blogging from Vim, I still primarily use TextMate, not least because of the <a href="http://bundle.weblogzinc.com/docs/index.php">Blogsmith Blogging Bundle</a>. Until that kind of functionality is ported to Vim, I’m happy right here. Thus, I spent my Sunday afternoon reviving the AutoTag bundle.</p>

<p>If you use <a href="http://blog.macromates.com/2006/blogging-from-textmate/">TextMate to blog on a WordPress site</a>, you’ll want to see this.</p>

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

<p>There are two parts to this: a WordPress plugin that adds an XML-RPC call for getting all of the tags in use on the blog, and a small TextMate bundle for making good use of it. The TextMate bundle cribs off of my previous AutoTag project, and borrows most of the remote functionality from the original TextMate blogging bundle. Why reinvent the wheel? I’m bundling both together in the download, so if you want to use the WordPress plugin to port the functionality elsewhere (say, Vim?), you can just pull out the parts you need.</p>

<p>[<a href="#download">Skip to download</a>]</p>

<h2>AutoTagging in TextMate</h2>

<p>What the bundle does (short version) is find the most appropriate tags for your content based on <em>tags you’ve already used</em> before. This helps you easily keep your tag collection trim and <em>useful</em>. No disparate tags because of inconsistent capitalization, plurals or conjugation. Things that are related stay related. This can be especially difficult blogging from TextMate because you can’t quickly see “all tags” the way you can from the WordPress editor. This solves the problem.</p>

<h3>Install the WordPress plugin</h3>

<p>Standard install, like any other (manually-installed) plugin:</p>

<ul>
<li>Upload the gettags-rpc folder from the zip download to your <code>wp-content/plugins</code> folder on your server.</li>
<li>Open your admin page and go to the Plugins panel.</li>
<li>Activate the GetTags-RPC plugin in the plugin list.</li>
</ul>

<p>If the plugin activates without error, you should be ready to go. It’s a very simple plugin without a lot of error checking, so let me know if you have any trouble with it.</p>

<h3>Install the AutoTag bundle</h3>

<p>To install AutoTag in TextMate, double click on the bundle in the download zip file. It should open TextMate, pop up the Bundle Editor and show you the installed bundle and its commands. Done.</p>

<p>Assuming you have AutoTag installed in TextMate and the GetTags-RPC plugin installed in WordPress, you’re ready to go. Well, you’ll need to have your blog set up (Bundles &gt; Blogging &gt; Setup Blogs) in TextMate, but we’ll assume you’ve done that by now.</p>

<h3>Using the commands</h3>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/04/autotag_tab_trigger.jpg?9d7bd4" alt="AutoTag Tab Trigger" height="166" width="287" class="alignright shadow">The AutoTag commands can be triggered in two ways. First, you can just put your cursor one space after the colon in the “Keywords:” line of the template headers. If you don’t have that line in your template, you can just type “Keywords: ” on a line before the end of the headers, or add it permanently by editing the template in the Bundle Editor. Hit tab from there and you’ll get a menu of the three commands in the bundle. You can trigger that from the same point even if you already have tags on the line; it will add appropriate commas automatically. Second, you can use Control-Option-T to get the same menu at any point in the file, although I’m not sure why you’d call it from anywhere <em>other</em> than the “Keywords” line.</p>

<h4>Commands</h4>

<p><strong>AutoTag:</strong> This is the primary command, or at least my favorite in the bundle. It’s only good when you run it <em>after</em> you write your post; it doesn’t have anything to work with on a blank template. Finish your post (or open an existing one) and trigger the command. It will grab all existing tags on your blog and compare them to your text, resulting in a dialog with a list of the best matches ranked by relevance. If you’re curious, here’s what it does when processing:</p>

<ul>
<li>Strips out all punctuation from the content of your post and creates an array of words</li>
<li>Uses the Porter Stemming algorithm to get the stem of each word. This makes plurals, adjective, adverb and verb forms all represent the same word.</li>
<li>Compares the list of stemmed words to the stems of each tag returned by your blog, keeping matches.</li>
<li>Measures the frequency of each match in the content and sorts the list accordingly.</li>
</ul>

<p><strong>Common Words:</strong> This command ignores the tags on your blog and just gives you the most common words from your post for selection as tags. It’s a good way to figure out what new tags might be worth adding. Again, it’s not very useful if you don’t have your content written yet.</p>

<p><strong>All Tags:</strong> If you’re not finding the AutoTag results satisfactory on a given post, or you want to tag before you have any content, this command will simply return your entire list of available tags. You can use it to check what form or casing you used on an existing tag, and it can be run at any time.</p>

<p>That’s it. If you use WordPress and TextMate together, I know you’re going to love this. Let me know how it goes! By the way, I’ll probably (eventually) build similar functionality right into the WordPress editor, and I’d love to see this ported to Vim, too. Any Vim plugin writers want a challenge?</p>

<h2>Download</h2>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (239)"><img src="http://brettterpstra.com/wp-content/plugins/download-monitor/page-addon/thumbnail.gif?9d7bd4" alt="download image for AutoTag2 and GetTags-RPC" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (239)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AutoTag2_1.0.1.zip?9d7bd4" title="Download AutoTag2 and GetTags-RPC (239)">AutoTag2 and GetTags-RPC</a> — A combination WordPress plugin and TextMate bundle to provide additional tag functionality when blogging from TextMate to WordPress. <a href="http://brettterpstra.com/?p=2154">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-quicktags-wordpress-plugin/' rel='bookmark' title='Markdown QuickTags: WordPress plugin for Markdown lovers'>Markdown QuickTags: WordPress plugin for Markdown lovers</a></li>
<li><a href='http://brettterpstra.com/textmate-as-writeroom-for-free/' rel='bookmark' title='TextMate as WriteRoom, for free'>TextMate as WriteRoom, for free</a></li>
<li><a href='http://brettterpstra.com/getting-back-into-real-textmate-blogging/' rel='bookmark' title='Getting back into real TextMate blogging'>Getting back into real TextMate blogging</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/">AutoTag2: smarter tagging for TextMate and WordPress</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate as WriteRoom, for free</title>
		<link>http://brettterpstra.com/textmate-as-writeroom-for-free/</link>
		<comments>http://brettterpstra.com/textmate-as-writeroom-for-free/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 14:41:26 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[minimalism]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2084</guid>
		<description><![CDATA[<p>I use TextMate for editing most of my Markdown. I could name a dozen reasons why this is the case, but let’s leave it at auto-pairing, wrapping and the Blogsmith Bundle features. Anyhow, I got a bug yesterday to make TextMate work in “concentration” mode (ala WriteRoom). Not because I think that will improve my writing habits, I just wanted&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-as-writeroom-for-free/">TextMate as WriteRoom, for free</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2011/03/TextMateWriteRoom.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/03/TextMateWriteRoom-300x168.jpg?9d7bd4" alt="" title="TextMate as WriteRoom" width="300" height="168" class="alignright size-medium wp-image-2085" /></a>I use TextMate for editing most of my Markdown. I could name a dozen reasons why this is the case, but let’s leave it at auto-pairing, wrapping and the <a href="http://bundle.weblogzinc.com">Blogsmith Bundle</a> features. Anyhow, I got a bug yesterday to make TextMate work in “concentration” mode (ala <a href="http://www.hogbaysoftware.com/products/writeroom">WriteRoom</a>). Not because I think that will improve my writing habits, I just wanted to see if it was possible. A few Google searches later, I have a pretty good solution.</p>

<p>There are a few things we need to pull off:</p>

<ul>
<li>Hide other windows, desktop and icons</li>
<li>Match the background to our TextMate theme background</li>
<li>Maximize the TextMate window, preferably remove top bar</li>
<li>Hide scrollbar when not needed</li>
</ul>

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

<p>The first step is easy. I used <a href="http://willmore.eu/software/isolator/">Isolator</a>, which can hide everything but the foreground window and let you specify a background color (taking care of the second point as well). There are a few apps that do this well, Isolator is just simple and free. It’s great for screencasting, too.</p>

<p>Now we need to maximize the TextMate window, but only vertically. The most effective way to do this is with a <a href="http://culater.net/software/SIMBL/SIMBL.php">SIMBL</a>  plugin called Megazoomer, which will remove the top bar, too. There’s a <a href="http://sadilek.blogspot.com/2009/01/fullscreen-editing-in-textmate-la.html">hack of Megazoomer</a> available which only maximizes vertically. If you maximize the window to the full width of a widescreen monitor, editing is less than friendly, so this is important. If you’re not into installing SIMBL (and if you’re not using it for anything else<sup id="fnref:fn1"><a href="#fn:fn1" rel="footnote">1</a></sup>, I wouldn’t), stick with zooming or take a look at the <a href="https://github.com/mads379/TextMate-Fullscreen-Plugin">Fullscreen Plugin</a> on GitHub.</p>

<p>Finally, some adjustments to the “chrome” in TextMate. The <a href="http://jason-evers.com/projects/green-moleskine">Green Moleskine</a> mod for TextMate is worth downloading for many reasons, and I’ve used it without issue on multiple Macs. I’d recommend just doing it. It will give you a cooler icon, nicer Bundle Editor, HUD “Go to line” and more. It will also hide the scrollbars when they’re not needed, taking care of the last point. Turn off all of the “Gutter” options under the view menu.</p>

<p>Now, with a few clicks, you’ve got a WriteRoom-style editing space in TextMate.</p>

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

<li id="fn:fn1">
<p>Visor makes SIMBL worthwhile to me, and I use it for Leech as well, but that’s about all. SIMBL on Snow Leopard isn’t as annoying as it was on Leopard, but still a chance I wouldn’t take if I didn’t feel it was worth the consequences. <a href="#fnref:fn1" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/getting-back-into-real-textmate-blogging/' rel='bookmark' title='Getting back into real TextMate blogging'>Getting back into real TextMate blogging</a></li>
<li><a href='http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/' rel='bookmark' title='A couple of TextMate Macros for Markdown lists'>A couple of TextMate Macros for Markdown lists</a></li>
<li><a href='http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/' rel='bookmark' title='TextMate drag command for Base64 encoding images'>TextMate drag command for Base64 encoding images</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-as-writeroom-for-free/">TextMate as WriteRoom, for free</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textmate-as-writeroom-for-free/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Natural language date conversion for TextMate</title>
		<link>http://brettterpstra.com/natural-language-date-conversion-for-textmate/</link>
		<comments>http://brettterpstra.com/natural-language-date-conversion-for-textmate/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 22:31:20 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[natural language]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1962</guid>
		<description><![CDATA[<p>I’ve been flirting with a plain-text to-do system again. The biggest problem for me is that a plain text system opens up so many possibilities for fiddling and scripting. I always end up fiddling more than working when I try it. I don’t see any reason this time would be different, but it’s Sunday and I have some extra time&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/natural-language-date-conversion-for-textmate/">Natural language date conversion for TextMate</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/02/natural_language_examples.jpg?9d7bd4" class="alignright shadow" />I’ve been flirting with a plain-text to-do system again. The biggest problem for me is that a plain text system opens up so many possibilities for fiddling and scripting. I always end up fiddling more than working when I try it. I don’t see any reason this time would be different, but it’s Sunday and I have some extra time on my hands after being snowed in today. So I’m fiddling.</p>

<p>In the process, I wrote a quick <a href="http://macromates.com/">TextMate</a> command which lets me enter a date in natural language and have it converted to whatever format I need for my system. It has variables at the top of the command for defining the date format and output string template. I packaged it up in its own little bundle for people to play with. The command is similar to what I built as a <a href="http://brettterpstra.com/a-few-scripts-for-taskpaper-users/" title="A few scripts for TaskPaper users - Brett Terpstra">TaskPaper script</a> a while back. Just <a href="#download">download</a> at the end of the post, unzip and double-click to install.</p>

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

<h2>Customizing</h2>

<p>The output format of the command defaults to a full date in the system’s preferred format. This makes it easy to see the effect of various strings. For most purposes, you’ll want something more along the lines of “2011–02-22″ instead. To change the format, you just need to edit the <code>dateformat</code> variable at the top of the command’s script.</p>

<p>To edit the command, just go to <strong>Bundles &gt; Bundle Editor &gt; Show Bundle Editor</strong> and find the Date Entry bundle. Select the <strong>Natural Date Entry</strong> command and edit it in the field on the right.</p>

<h3>Date Format</h3>

<p>There’s a commented-out <code>dateformat</code> replacement above the current variable, and you can modify it to fit whatever you need. Don’t forget to comment out or remove the current variable if you uncomment the one above it. The % format elements use Ruby’s <a href="http://www.ruby-doc.org/core/classes/Time.src/M000392.html" title="strftime (Time) [ruby-doc.org]">strftime format</a>. I built the command to work with <a href="http://skiadas.dcostanet.net/afterthought/2006/06/25/details-on-the-gtdalt-bundle/">GTDAlt</a> and <a href="http://www.hogbaysoftware.com/products/taskpaper">TaskPaper</a>, and on my system both use the YYYY-MM-DD format, so that’s what the secondary option is set to.</p>

<h3>Output Template</h3>

<p>To be practical, you probably also need to output some delimiters with the date. In GTDAlt, it would look like “due:[2011–02-22]”, and in TaskPaper it would look like “@due(2010–02-22)”. You can set this up using the <code>outputtemplate</code> variable below <code>dateformat</code>. It uses <code>%date%</code> as a placeholder which will be replaced with the date in the format you specified above. As an example, if you wanted to use the command with TaskPaper files, you would set it to <code>'@due(%date%)'</code>.</p>

<h3>Usage</h3>

<p>The command uses Command-Shift-D by default, but you can change that to whatever’s clever when you’re in the Bundle Editor. When run, it pops up an input dialog courtesy of TextMate’s built-in dialog system. You can enter text in an intuitive natural language format and it will output the date based on the variables you’ve defined. Here are some example strings:</p>

<ul>
<li>tomorrow</li>
<li>tomorrow 3pm</li>
<li>wednesday</li>
<li>wednesday morning</li>
<li>wed</li>
<li>next thursday</li>
<li>in one week</li>
<li>in three days</li>
<li>in 3 days</li>
</ul>

<p>You get the idea. I also set it up to take “+” modifiers. You can add any number of days at the end of a string, or just use the plus modifier to add days to today. For example:</p>

<ul>
<li>thu+7</li>
<li>+2</li>
<li>tomorrow + 3</li>
</ul>

<p>It will roll with any of those punches. Abbreviated days have to be three characters, i.e. mon, tue, wed, thu, fri, sat, or sun.</p>

<h2>Moving the command</h2>

<p>This command has to be distributed in a bundle because it requires the Ruby library <a href="http://rubyforge.org/projects/chronic/" title="RubyForge: Chronic: Project Info">“Chronic”</a> for the date conversion. The library is included in the Support/lib folder of the bundle. If you happen to have RubyGems installed, you can install the Chronic gem (<code>sudo gem install chronic</code>) and then modify the command to allow you to put it wherever you like without needing the support folder at all. To make the command use the gem instead of the bundled library, change the require statements in the command to look like this:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">SUPPORT = ENV<span class="br0">&#91;</span><span class="st0">'TM_SUPPORT_PATH'</span><span class="br0">&#93;</span>
BSUPPORT = ENV<span class="br0">&#91;</span><span class="st0">'TM_BUNDLE_SUPPORT'</span><span class="br0">&#93;</span>
DIALOG = ENV<span class="br0">&#91;</span><span class="st0">'DIALOG'</span><span class="br0">&#93;</span>
<span class="kw3">require</span> SUPPORT <span class="sy0">+</span> <span class="st0">'/lib/ui'</span>
<span class="kw3">require</span> SUPPORT <span class="sy0">+</span> <span class="st0">'/lib/exit_codes'</span>
<span class="kw3">require</span> <span class="st0">'rubygems'</span>
<span class="kw3">require</span> <span class="st0">'chronic'</span></pre></div></div>


<p>It would also be pretty easy to port to any other system, including an OS X system service. You’d just need to make sure you include the Chronic library, either bundled or install the gem, and find a way to get the text input without using TextMate’s dialog. <a href="http://cocoadialog.sourceforge.net/">CocoaDialog</a> or a service that acts on selected text would fit the bill.</p>

<p>I think this will be handy for more than just to-do lists. Let me know if you find a use for it elsewhere!</p>

<p><em>Man, it took me twice as long to write that post as it did to put together the command and the bundle. Like I said: Sunday.</em></p>

<h2>Download</h2>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/DateEntryBundle.zip?9d7bd4" title="Download Date Conversion for TextMate (76)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/06/TextMateIcon.png?9d7bd4" alt="download image for Date Conversion for TextMate" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/DateEntryBundle.zip?9d7bd4" title="Download Date Conversion for TextMate (76)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/DateEntryBundle.zip?9d7bd4" title="Download Date Conversion for TextMate (76)">Date Conversion for TextMate</a> — A TextMate bundle which contains one command: Natural Date Entry. When triggered, it requests a natural-language date string (e.g. “tomorrow 3pm”), converts it to a configurable date format, and outputs it with a customizable template. <a href="">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/os-x-service-for-natural-language-dates/' rel='bookmark' title='OS X Service for natural language dates'>OS X Service for natural language dates</a></li>
<li><a href='http://brettterpstra.com/natural-language-dates-for-textexpander/' rel='bookmark' title='Natural language dates for TextExpander'>Natural language dates for TextExpander</a></li>
<li><a href='http://brettterpstra.com/a-couple-of-textmate-macros-for-markdown-lists/' rel='bookmark' title='A couple of TextMate Macros for Markdown lists'>A couple of TextMate Macros for Markdown lists</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/natural-language-date-conversion-for-textmate/">Natural language date conversion for TextMate</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/natural-language-date-conversion-for-textmate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Notational Velocity ALT expatiation (and roadmap)</title>
		<link>http://brettterpstra.com/notational-velocity-alt-expatiation-and-roadmap/</link>
		<comments>http://brettterpstra.com/notational-velocity-alt-expatiation-and-roadmap/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 17:00:42 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Write]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[multimarkdown]]></category>
		<category><![CDATA[notational velocity]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1493</guid>
		<description><![CDATA[<p>I’d just like to put it out there, as someone will eventually: Notational Velocity ALT (henceforth referred to as nvALT) is turning into something antithetical to the original premise of Notational Velocity. I understand that, and I accept it. Notational Velocity is an amazing note-taking tool, elegant in its simplicity and without much need for expansion. I love it. nvALT&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/notational-velocity-alt-expatiation-and-roadmap/">Notational Velocity ALT expatiation (and roadmap)</a></p>]]></description>
			<content:encoded><![CDATA[<p>I’d just like to put it out there, as someone will eventually: <a href="http://brettterpstra.com/code/notational-velocity-alt/">Notational Velocity ALT</a> (henceforth referred to as nvALT) is turning into something antithetical to the original premise of <a href="http://notational.net/">Notational Velocity</a>. I understand that, and I accept it.</p>

<p>Notational Velocity is an amazing note-taking tool, elegant in its simplicity and without much need for expansion. I love it. nvALT is the result of my desire to get back into Objective-C and begin by reverse-engineering an application I adored. That’s how I learn, working backward from the desired result. Notational Velocity happened to be Open Source, so that’s where I dug in. I didn’t believe that I was going to make NV <em>better</em>, I thought I could build something <em>from</em> it. What follows is my vision as it stands today, some elements more concrete than others.</p>

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

<p>I’m hoping that as I develop nvALT, it will become its own application, viewed not as an evolution of Notational Velocity, but as a grandchild. Something with roots in the original application, but serving a different purpose (and yes, I’m pondering new names).</p>

<p>What do I see it developing into? A writing app. A Markdown-specific, minimalist application for gathering and developing ideas, indexing them, making them portable and cross-platform and then sharing and publishing them. The basic elements are already there: widescreen view, collapsible notes panel, MultiMarkdown integration, preview and source output, and Dropbox and SimpleNote sync. I see incorporating the full-screen mode that other forks have already accomplished, but I also see creating a nearly-invisible text editing system which stays out of the way but which makes editing Markdown as easy and efficient as possible. It will always work in plain text, so editing in SimpleNote, or in any of the numerous iPad apps with Dropbox or SimpleNote support will be a given.</p>

<p>I’ve already built this system <a href="http://brettterpstra.com/code/markdown-quicktags/">for WordPress</a> (soon to be a Safari extension), but need to rebuild it for Cocoa. It involves <em>no</em> buttons, just features that manifest as you type, and in an intuitive way that you don’t have to think twice about. It’s basically the <a href="http://macromates.com/">TextMate</a> <a href="http://fletcherpenney.net/multimarkdown/multimarkdown_bundle_for_textm/">MultiMarkdown bundle</a> for text views. The essential elements:</p>

<ul>
<li>Auto-pairing of brackets, parenthesis and quotes</li>
<li>Auto-completion of reference link titles</li>
<li>Automatic list creation, continuation and conversion</li>
<li>Wrapping selections in any auto-paired characters</li>
<li>Shortcut keys for bold and italics insert Markdown syntax</li>
<li>Pasting links on their own line creates references automatically, title determined by elements of the url</li>
<li>Typewriter mode (current editing line vertically centered)</li>
</ul>

<p>I’d like a “Publish” menu, in addition to (or in combination with) the aforementioned sharing feature. WordPress, Blogger, Tumblr (if it’s up), etc., and sending of HTML messages through your default email client.</p>

<p>I’m also thinking about making the HTML preview inline, so that you click a button and the main editing area <em>becomes</em> the preview, and clicking the source button opens the HUD. That seems more fluid to me, especially for full-screen editing. The ultimate goal is to retain the absolute minimal interface it began with, but make it as powerful as possible.</p>

<p>It should also be able to create beautiful documents. <a href="http://fletcherpenney.net/">Fletcher Penney</a> has already built excellent XSL files for converting MMD files to PDF and Word documents, and the next version of nvALT already has Table of Contents rendering built into it, so the tools are already there.</p>

<p>So, that’s the roadmap right now. I don’t claim any of these ideas to be terribly original, I just want to build what seems like the ideal combination for me. I’m always open to feedback and suggestions, so leave a comment or <a href="http://brettterpstra.com/contact">contact me directly</a>. The timeline is long, as I have painfully little time for development, but I’ll keep it moving. Let’s have some fun creating a useful tool that fulfills a need that Notational Velocity doesn’t already have well-covered.</p>


<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/notational-velocity-alt-1-0-release/' rel='bookmark' title='Notational Velocity ALT 1.0 release'>Notational Velocity ALT 1.0 release</a></li>
<li><a href='http://brettterpstra.com/notational-velocity-alternative-multimarkdown-version/' rel='bookmark' title='Notational Velocity alternative MultiMarkdown version'>Notational Velocity alternative MultiMarkdown version</a></li>
<li><a href='http://brettterpstra.com/notational-velocity-alt-5-3/' rel='bookmark' title='Notational Velocity ALT 5.3'>Notational Velocity ALT 5.3</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/notational-velocity-alt-expatiation-and-roadmap/">Notational Velocity ALT expatiation (and roadmap)</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/notational-velocity-alt-expatiation-and-roadmap/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Quick Link: Sparkup rocks my world a little</title>
		<link>http://brettterpstra.com/quick-link-sparkup-rocks-my-world-a-little/</link>
		<comments>http://brettterpstra.com/quick-link-sparkup-rocks-my-world-a-little/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 15:47:42 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1141</guid>
		<description><![CDATA[<p>I just discovered Sparkup (via NetTuts+). It adds the one thing I find lacking in Zen Coding: the ability to traverse backward in a shortcut (among several other improvements). Background: Zen Coding is a Python script that can run in various extensible editors, my favorite being TextMate. It turns strings like div#branding&#62;h1#header+ul#nav&#62;li*5&#62;a into a fully marked up HTML branding div&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/quick-link-sparkup-rocks-my-world-a-little/">Quick Link: Sparkup rocks my world a little</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just discovered <a href="http://github.com/rstacruz/sparkup#readme">Sparkup</a> (via <a href="http://net.tutsplus.com/articles/general/quick-tip-even-quicker-markup-with-sparkup/">NetTuts+</a>). It adds the one thing I find lacking in <a href="http://code.google.com/p/zen-coding/">Zen Coding</a>: the ability to traverse backward in a shortcut (among several other improvements).</p>

<p>Background: Zen Coding is a Python script that can run in various extensible editors, my favorite being <a href="http://www.macromates.com/" title="TextMate">TextMate</a>. It turns strings like <code>div#branding&gt;h1#header+ul#nav&gt;li*5&gt;a</code> into a fully marked up HTML branding div with a single shortcut. It’s immensely useful, and if you haven’t tried it, you’re missing out. Skip it, though, and jump straight to Sparkup.</p>

<p>I use Zen Coding constantly in TextMate. It’s replaced 75% of my HTML snippets with one shortcut. What Sparkup adds is the ability to move back up levels using the “&lt;” symbol, as well as the ability to add attributes (like an href for a link) and content to elements from within the shortcut string. See the <a href="http://github.com/rstacruz/sparkup#readme">Sparkup readme</a> for examples. Awesome stuff.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/testing-from-vim/' rel='bookmark' title='Testing from Vim'>Testing from Vim</a></li>
<li><a href='http://brettterpstra.com/textmate-keybinding-tip/' rel='bookmark' title='A quick TextMate KeyBindings tip'>A quick TextMate KeyBindings tip</a></li>
<li><a href='http://brettterpstra.com/quick-tip-extracting-mac-app-store-reviews-as-text/' rel='bookmark' title='Quick Tip: Extracting Mac App Store reviews as text'>Quick Tip: Extracting Mac App Store reviews as text</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/quick-link-sparkup-rocks-my-world-a-little/">Quick Link: Sparkup rocks my world a little</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/quick-link-sparkup-rocks-my-world-a-little/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A TextMate Command for fast abbr tags</title>
		<link>http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/</link>
		<comments>http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 22:45:08 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=935</guid>
		<description><![CDATA[<p>I'm on a roll with stupid scripts today, but it's Saturday... so, whatever. This is a quick command for creating semantic &#60;abbr&#62; tags in TextMate. It's short, but pretty smart: if your text is a mix of upper and lowercase letters, it will take the uppercase letters, in order, and create an acronym from them and insert an &#60;abbr&#62; tag,&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/">A TextMate Command for fast abbr tags</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/09/AbbreviateCommandInBundleEditor.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/09/AbbreviateCommandInBundleEditor-300x190.jpg?9d7bd4" alt="" title="AbbreviateCommandInBundleEditor" width="300" height="190" class="alignright size-medium wp-image-937" /></a>I’m on a roll with stupid scripts today, but it’s Saturday… so, whatever. This is a quick command for creating semantic &lt;abbr&gt; tags in TextMate. It’s short, but pretty smart: if your text is a mix of upper and lowercase letters, it will take the uppercase letters, in order, and create an acronym from them and insert an &lt;abbr&gt; tag, using the original input as the title attribute. If it’s one of a couple other scenarios, it will give you the &lt;abbr&gt; tag setup with your cursor in a logical place to fill in the blanks.</p>

<p>In case you’re wondering why I’m using the wrong tag for my acronyms, the HTML5 spec pretty much does away with the &lt;acronym&gt; tag, and &lt;abbr&gt; appears to be the new, all-purpose solution. It’s not perfectly semantic, but there doesn’t seem to be an ideal solution for acronyms in the spec. This command is really geared toward using the &lt;abbr&gt; for acronyms, but you could easily alter it to insert an &lt;acronym&gt; tag (especially if your doctype is anything other than ‘html’), and it works pretty well for just quickly creating an actual abbreviation, too. It just doesn’t try to guess how to abbreviate anything other than apparent acronyms, but it gives you Snippet tab stops for quick manual editing. If you run it with no selection, it will create a blank &lt;abbr&gt; tag you can tab through and fill in.</p>

<p><span id="more-935"></span>
To use the command, just create a new TextMate Command in the Bundle Editor, preferably in your own personal bundle (create a new bundle with your name, if you need to). Set the Input to “Selected Text” or “Word”, and the output to Insert as Snippet. Assign a key equivalent if you like. Since it’s outputting HTML, it probably makes sense to set the Scope Selector field to “text.html”, but who knows, you may prefer to use it outside of normal HTML source documents. Once it’s set up, add the code below.</p>

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

input = STDIN.read

if input =~ /^[A-Z]+$/
  print %Q{&lt;abbr title=&quot;$1&quot;&gt;#{input}&lt;/abbr&gt;$0}
else
  acronym = input.scan(/[A-Z]/).join()
  if acronym.length &lt; 2
    print %Q{&lt;abbr title=&quot;${1:#{input}}&quot;&gt;$2&lt;/abbr&gt;$0}
  else
    print %Q{&lt;abbr title=&quot;#{input}&quot;&gt;${1:#{acronym}}&lt;/abbr&gt;$0}
  end
end
</code></pre>
</div>

<p>It’s probably not useful on a frequent enough basis be memorable in cases where you’d actually need it, but there it is. It’s actually a small part of a larger experiment I played with today. I’ll probably post about it this weekend, as it’s useful not just with &lt;abbr&gt; tags, but with any tag with a descriptive attribute. Just a few lines of jQuery which can make the <abbr title="Products of Totally Wasted Weekends">PTWW</abbr> be more immediately useful, accessible and, well, look cooler.</p>

<p>And yes, I did just make that acronym markup with the above TextMate Command. I feel like a salesman who sells people things which seem perfect for situations they’ll never find themselves in.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/a-system-service-for-to-url-shortening/' rel='bookmark' title='A System Service for to. url shortening'>A System Service for to. url shortening</a></li>
<li><a href='http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/' rel='bookmark' title='TextMate drag command for Base64 encoding images'>TextMate drag command for Base64 encoding images</a></li>
<li><a href='http://brettterpstra.com/natural-language-date-conversion-for-textmate/' rel='bookmark' title='Natural language date conversion for TextMate'>Natural language date conversion for TextMate</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/">A TextMate Command for fast abbr tags</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick TextMate KeyBindings tip</title>
		<link>http://brettterpstra.com/textmate-keybinding-tip/</link>
		<comments>http://brettterpstra.com/textmate-keybinding-tip/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 19:19:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[keybindings]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=891</guid>
		<description><![CDATA[<p>I love the keyboard, and I love keyboard shortcuts. It’s one of the reasons TextMate and I get along so well. There’s one thing that bothers me any time I’m editing text (in any application), though: having to move my right hand all the way over to the arrow keys just to move forward a couple of characters, say, after&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-keybinding-tip/">A quick TextMate KeyBindings tip</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/08/keybindingstypewriter1.jpg?9d7bd4" alt="Typewriter Image" border="0" width="318" height="301" class="alignright noshadow" />I love the keyboard, and I love keyboard shortcuts. It’s one of the reasons TextMate and I get along so well. There’s one thing that bothers me any time I’m editing text (in any application), though: having to move my right hand <em>all</em> the way over to the arrow keys just to move forward a couple of characters, say, after an auto-paired set of parenthesis that I want to get out of.</p>

<p>I know, it’s stupid for two reasons: first, it’s just not that big a deal, and second, I could just use the Emacs keybindings (^F,^B,^P,^N, etc.). Well, to that I say “phooey” on both counts. It <em>is</em> a big deal; I’ve probably lost hours of my life to that motion. As to the latter, I didn’t grow up on Emacs, and those shortcuts have just never nestled into my muscle memory. In related news, I already have some of those keys bound elsewhere.</p>

<p>I used to use <a href="http://pqrs.org/macosx/keyremap4macbook/">KeyRemap4Macbook</a> to map control-j,i,l and m to the cursor keys, but haven’t installed it since my last clean wipe (just in case it was part of the reason I had to do the clean wipe to begin with). I missed that convenience, though, so after 15 minutes of Googling, here’s the answer…</p>

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

<p>Allan Odgaard, creator of TextMate, offers the beginning of the solution <a href="http://blog.macromates.com/2005/key-bindings-for-switchers/">on the TextMate blog</a>. I found a little <a href="http://xahlee.org/emacs/osx_keybinding.html">more detailed information</a> around the net, too. Basically, you can add or edit a file called <code>DefaultKeyBinding.dict</code> in <code>~/Library/KeyBindings/</code> to add the keystrokes to all Cocoa applications. Mine looks like this now:</p>

<div markdown=0>
<pre><code>
{
  "^j" = "moveBackward:";
  "^l" = "moveForward:";
  "^m" = "moveDown:";
  "^i" = "moveUp:";
  "^E" = "\"editInTextMate:\"";
}
</code></pre>
</div>

<p>The first part of each pair is the keystroke, and the second part is the action. To find a list of the available actions, I just looked at <code>/System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict</code>, which has all of the default OS X keybindings in it. You’ll need Property List Editor to view the file in its default state. To view the file in a text editor, you have to convert it to an XML (old school and plain text) plist. If you’re curious, copy the file to your Desktop and, in Terminal, run <code>plutil -convert xml1 ~/Desktop/StandardKeyBinding.dict</code>.</p>

<p>After editing <code>DefaultKeyBinding.dict</code> and restarting your Cocoa apps, your new keyboard shortcuts will be available. That’s when I found the next problem. TextMate has ^J mapped to “Reformat and Justify” under the Text menu. I never, ever use that command, so that was just annoying. I first tried to just override it in System Preferences-&gt;Keyboard-&gt;Application Shortcuts, but that didn’t do anything. Next I found a <a href="http://www.macosxhints.com/article.php?story=20040618093419348">post on macosxhints</a> that offered a Terminal (<code>defaults</code>) command for changing default Application shortcuts. For example:</p>

<div markdown=0>
<pre><code>
defaults write com.macromates.textmate NSUserKeyEquivalents -dict-add "Reformat and Justify" "nil"
</code></pre>
</div>

<p>Guess what? That didn’t do it. TextMate was still pwning the ^J shortcut. Next stop, the Resources folder of the TextMate application. There I found <code>KeyBindings.dict</code>, where it was easy to locate the offending shortcut. I commented out the line (//) and restarted TextMate. Ta. Dum. My new keyboard shortcuts now function perfectly.</p>

<p>By the way, the reason I didn’t use “k” for down is I actually do regularly use the <code>kill</code> keybinding to delete to the end of the line (as well as ^a to move to beginning and ^e to the end). Also, you might skip mapping “m” to down, as “n” right next to it is already mapped to moveDown:, as mentioned while complaining about Emacs keybindings. I have them both mapped now, so I can have lazy fingers if I want to. Further, note that these keybindings will not work when selecting text; once you press the shift key, you’re in a whole new world. You’d have map those as well if you wanted that functionality.</p>

<p>I’m happy now, and so are my fingers. Have any other brilliant keybinding stories? I’d love to hear them.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/keybindings-new-improved-surround-commands/' rel='bookmark' title='KeyBindings: new, improved “surround” commands'>KeyBindings: new, improved “surround” commands</a></li>
<li><a href='http://brettterpstra.com/keybinding-madness/' rel='bookmark' title='KeyBinding madness'>KeyBinding madness</a></li>
<li><a href='http://brettterpstra.com/the-keys-that-bind-keybinding-madness-part-2/' rel='bookmark' title='The keys that bind: KeyBinding Madness part 2'>The keys that bind: KeyBinding Madness part 2</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-keybinding-tip/">A quick TextMate KeyBindings tip</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textmate-keybinding-tip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Placeholder image TextMate Snippet</title>
		<link>http://brettterpstra.com/placeholder-image-textmate-snippet/</link>
		<comments>http://brettterpstra.com/placeholder-image-textmate-snippet/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 00:40:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=868</guid>
		<description><![CDATA[<p>Yesterday, I posted a quick TextExpander snippet for inserting placeholder images into an HTML layout using placehold.it. I took a minute today to convert this to a TextMate snippet as well, and wanted to share it as I find it immensely useful. If you’ve never created a TextMate Snippet before, read on. If you’re an old pro, skip down to&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/placeholder-image-textmate-snippet/">Placeholder image TextMate Snippet</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://placehold.it/200x150/333333/dddddd&#038;text=TextMate!" alt="Placehold.it" width="200" height="150" class="alignright noshadow" />Yesterday, <a href="http://brettterpstra.com/2010/08/04/instant-placeholder-images-with-textexpander/">I posted a quick TextExpander snippet</a> for inserting placeholder images into an HTML layout using <a href="http://placehold.it">placehold.it</a>. I took a minute today to convert this to a <a href="http://www.macromates.com/">TextMate</a> snippet as well, and wanted to share it as I find it immensely useful.</p>

<p><span id="more-868"></span>
If you’ve never created a TextMate Snippet before, read on. If you’re an old pro, skip down to the <a href="#thecode">code below</a>.</p>

<h3>Creating a TextMate Snippet</h3>

<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/08/BundleEditorPlaceholderImage.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/08/BundleEditorPlaceholderImage-300x210.jpg?9d7bd4" alt="Bundle Editor" title="BundleEditorPlaceholderImage" width="300" height="210" class="alignright size-medium wp-image-870 noshadow" /></a>To create a Snippet in TextMate, go to Bundles-&gt;Bundle Editor-&gt;Show Bundle Editor. If you don’t already have a “personal” Bundle, you should create one to keep your custom Snippets and Commands separate from other bundles. Just use the plus sign button in the bottom left and choose New Bundle, then name it with your own name (or whatever you like).</p>

<p>Select that bundle in the left column and use the plus sign button at the bottom again, this time choosing New Snippet. Name the new Snippet “Placeholder Image” and set the Activation to Tab Trigger and enter your preferred shortcut in the field next to it. I’m using “dummy,” which is the same as my TextExpander snippet, but I have TextExpander disabled in TextMate, so it overlaps nicely.</p>

<p>Next, insert the following code in the main text area for the snippet…</p>

<h3 id="thecode">The Placeholder Image Snippet</h3>

<div markdown=0><pre><code>
&#x3C;img src=&#x22;http://placehold.it/${1:width}x${2:height}/${3:333333}/${4:dddddd}&#x26;text=${5/ /+/g}${6:+($1x$2)}&#x22; alt=&#x22;${5:Placeholder} $1x$2&#x22; width=&#x22;$1&#x22; height=&#x22;$2&#x22; /&#x3E;
</code></pre></div>

<h3>Using the Placeholder Image Snippet</h3>

<p>Snippets in TextMate don’t save until you select another one or close the Bundle Editor, so change your sidebar selection before you try it out. You should be able to create or edit any HTML or PHP file now, and type your shortcut, followed by a tab, and get a placeholder image. After it’s inserted, you can tab through and change the attributes.</p>

<p>This Snippet gives you a full image tag with tab stops<sup id="fnref:tabstops"><a href="#fn:tabstops" rel="footnote">1</a></sup> for width, height, background color, foreground color and title text. The title text is entered in the alt attribute, and mirrored into the query string so that you can just type alphanumeric characters with natural spaces and it will substitute the necessary plus signs in the mirrored version. The width and height are included as mirrors in the title, but you can delete that in the final tab stop.</p>

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

<li id="fn:tabstops">
<p>Tab stops allow you to have multiple editable parts in the inserted code. The first one is highlighted automatically when you insert the snippet, and you can edit it and press tab to go to the next one. You can also skip editing and just tab to the next one, or delete the entire selection and tab on. <a href="#fnref:tabstops" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/instant-placeholder-images-with-textexpander/' rel='bookmark' title='Instant placeholder images with TextExpander'>Instant placeholder images with TextExpander</a></li>
<li><a href='http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/' rel='bookmark' title='A TextMate Command for fast abbr tags'>A TextMate Command for fast abbr tags</a></li>
<li><a href='http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/' rel='bookmark' title='AutoTag2: smarter tagging for TextMate and WordPress'>AutoTag2: smarter tagging for TextMate and WordPress</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/placeholder-image-textmate-snippet/">Placeholder image TextMate Snippet</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/placeholder-image-textmate-snippet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An ode to Twilight, and a TextMate tip</title>
		<link>http://brettterpstra.com/an-ode-to-twilight-and-a-textmate-tip/</link>
		<comments>http://brettterpstra.com/an-ode-to-twilight-and-a-textmate-tip/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:39:24 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=729</guid>
		<description><![CDATA[<p>A good friend of mine, Christina Warren, just published a piece on Mashable / Dev &#38; Design about TextMate themes, and it warms my heart to know there are other people as dedicated to this aging text editor as I am. She also made her collection available on GitHub, so check that out if you’re in the market for a&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/an-ode-to-twilight-and-a-textmate-tip/">An ode to Twilight, and a TextMate tip</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/twilightpostheader.jpg?9d7bd4" alt="" title="twilightpostheader" width="650" height="187" class="alignnone size-full wp-image-730 headerimg" /></p>

<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/twothemes.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/twothemes-300x234.jpg?9d7bd4" alt="" title="twothemes" width="300" height="234" class="alignright size-medium wp-image-731" /></a></p>

<p>A good friend of mine, <a href="http://www.christinawarren.com/">Christina Warren</a>, just published a piece on <a href="http://mashable.com/dev-design/">Mashable / Dev &amp; Design</a> about <a href="http://mashable.com/2010/07/07/textmate-themes-list/">TextMate themes</a>, and it warms my heart to know there are other people as dedicated to this aging text editor as I am. She also made her <a href="http://github.com/filmgirl/TextMate-Themes/">collection available</a> on GitHub, so check that out if you’re in the market for a new look.</p>

<p>Despite the lack of any major TextMate update for <em>years</em> now, it’s still my absolute favorite editor. I’ve tried to let go of it. I played with Coda when it came out, and even tried to port some of my favorite TextMate bundles (without much success), but in the end it turned out that I really <em>like</em> having multiple windows taking advantage of my multi-monitor setup. At least when it comes to Terminal (which, thanks to <a href="http://docs.blacktree.com/visor/visor">Visor</a>, is never further away than a double-tap on my control key), FTP programs and my editor. So that was a wash.</p>

<p><span id="more-729"></span>Espresso came out a while after, and it was (and is) hands-down the sexiest text editor out there. I still use it whenever I can, but I just haven’t found it to be as extensible and comfortable for me as TextMate. I can make TextMate do <em>anything</em>. Seriously, it made the coffee I’m drinking.</p>

<p>And now, I’d like to pay tribute to one of the original TextMate themes which, in my opinion, is still the greatest theme ever. I’m not alone in this, people espouse its virtues <a href="http://www.google.com/search?client=safari&amp;rls=en&amp;q=textmate+twilight+theme&amp;ie=UTF-8&amp;oe=UTF-8">throughout the search engines</a>, it’s been ported to Espresso, Coda, even Notepad++ on Windows, and you can often find online code rendered in its pleasing pallete. I like light on dark themes in general, and I do, on occasion, like to switch to something high-contrast like Succulent or Vibrant Ink. I even like dark brown backgrounds with mellow foregrounds, sometimes. But I always end up back at Twilight, with its slate background and perfectly contrasted colors. It’s detailed and effective in just about every possible syntax, and I find it perfect for readability. I just wish they hadn’t gone and named a tale of girly vampires after it.</p>

<p>I <em>will</em> offer a bit of a tip to try to bring this post around to being… interesting? Did you know that you can actually pull off multiple themes in one? If you look at the screenshot in this post, you’ll see two different color schemes, one for my MultiMarkdown files, and one for my PHP code. It’s a customization of the Twilight theme, with custom colors added for Markdown-specific scopes. In the Preferences, under Fonts &amp; Colors, you’ll note that every color definition has a related scope. You can add new scopes and define colors by pressing the plus button on the left.</p>

<p>You can use a simple TextMate command to find the scope for a particular item. Create a new command in the Bundle Editor, set it to Save Nothing, Input: None, Output: Show as Tool Tip. In the Command field, enter:</p>

<div markdown=0>
<pre><code>
echo "$TM_SCOPE" | pbcopy
echo "$TM_SCOPE copied"
</code></pre>
</div>

<p>Then assign a key equivalent to it and you can just stick your cursor inside whatever you want to know the scope of, and press your key combination. The scope is in your clipboard now, and you can do what you want with it (like add new color definitions). Enjoy!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textmate-keybinding-tip/' rel='bookmark' title='A quick TextMate KeyBindings tip'>A quick TextMate KeyBindings tip</a></li>
<li><a href='http://brettterpstra.com/placeholder-image-textmate-snippet/' rel='bookmark' title='Placeholder image TextMate Snippet'>Placeholder image TextMate Snippet</a></li>
<li><a href='http://brettterpstra.com/textmate-as-writeroom-for-free/' rel='bookmark' title='TextMate as WriteRoom, for free'>TextMate as WriteRoom, for free</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/an-ode-to-twilight-and-a-textmate-tip/">An ode to Twilight, and a TextMate tip</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/an-ode-to-twilight-and-a-textmate-tip/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TextMate drag command for Base64 encoding images</title>
		<link>http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/</link>
		<comments>http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 14:00:29 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[drag command]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=659</guid>
		<description><![CDATA[<p>Just a quick hit on this one… when hacking away at the styles of things one probably shouldn’t be hacking away at, embedding images right in the CSS is a handy trick. It’s done by Base64 encoding the image, removing line breaks from the resulting string, and using it to set the background property for the CSS rule. It looks&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/">TextMate drag command for Base64 encoding images</a></p>]]></description>
			<content:encoded><![CDATA[<p>Just a quick hit on this one… when hacking away at the styles of things one probably shouldn’t be hacking away at, embedding images right in the CSS is a handy trick. It’s done by <a href="http://en.wikipedia.org/wiki/Base64">Base64</a> encoding the image, removing line breaks from the resulting string, and using it to set the background property for the CSS rule.</p>

<p>It looks something like this (truncated):</p>

<p><code>background:url(data:image/png;base64,iVBORw0KG...AAAAASUVORK5CYII=);</code></p>

<p>The image/png changes depending on the filetype that’s encoded, becoming image/jpg or image/gif, etc. Anyway, I got tired of shelling out to encode the images, so here’s a very simple command I set up in TextMate which allows me to drag any JPEG, PNG or GIF file into a CSS rule and get the background property with encoded image all at once. Don’t try it with <em>big</em> images, but for the kind of thing you’d actually put into a CSS file, it works great.</p>

<p>The command itself is this (it’s a one-liner):</p>

<div markdown=0><pre><code>
# Drag command set to handle: jpg,png,gif
# scoped to: text.html.basic source.css.embedded.html, source.css meta.scope.property-list.css

openssl base64 -in "$TM_DROPPED_FILE" | awk -v ext="${TM_DROPPED_FILE#*.}" '{ str1=str1 $0 }END{ print "background:url(data:image/"ext";base64,"str1");" }'
</code></pre></div>

<p>It uses the <code>openssl</code> command that’s on a Mac by default. It encodes the file and outputs it to STDOUT, which is passed to awk. The extension of the dropped file is grabbed via Bash parameter substitution (<code>${TM_DROPPED_FILE#*.}</code>) and passed to awk where it’s subbed in and all of the line breaks are removed. Presto.</p>

<p>Here’s the actual TextMate command if you want to try it out and aren’t sure how to create a new one. Assuming you’re running TextMate (kind of a prerequisite for a TextMate command), just unzip and double click the file.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/InsertBase64image.tmDragCommand.zip?9d7bd4" title="Download Base64 Image Encoder TextMate Drag Command (351)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/06/TextMateIcon.png?9d7bd4" alt="download image for Base64 Image Encoder TextMate Drag Command" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/InsertBase64image.tmDragCommand.zip?9d7bd4" title="Download Base64 Image Encoder TextMate Drag Command (351)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/InsertBase64image.tmDragCommand.zip?9d7bd4" title="Download Base64 Image Encoder TextMate Drag Command (351)">Base64 Image Encoder TextMate Drag Command</a> — Encodes a dropped image and inserts a CSS background property with the result in TextMate. Works in embedded CSS and in CSS files. <a href="http://brettterpstra.com/2010/06/19/textmate-drag-command-for-base64-encoding-images/">More Info</a></p></div>

<hr style="clear:both;visibility:hidden" />
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/a-textmate-command-for-fast-abbr-tags/' rel='bookmark' title='A TextMate Command for fast abbr tags'>A TextMate Command for fast abbr tags</a></li>
<li><a href='http://brettterpstra.com/textmate-as-writeroom-for-free/' rel='bookmark' title='TextMate as WriteRoom, for free'>TextMate as WriteRoom, for free</a></li>
<li><a href='http://brettterpstra.com/placeholder-image-textmate-snippet/' rel='bookmark' title='Placeholder image TextMate Snippet'>Placeholder image TextMate Snippet</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/">TextMate drag command for Base64 encoding images</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textmate-drag-command-for-base64-encoding-images/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Songza Lucky Link Service</title>
		<link>http://brettterpstra.com/songza-lucky-link-service/</link>
		<comments>http://brettterpstra.com/songza-lucky-link-service/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 23:41:42 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[songza]]></category>
		<category><![CDATA[textmate]]></category>

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

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

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

<p><a href="http://brettterpstra.com/share/SongzaLinkSLService.zip?9d7bd4">Download the service</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/auto-link-text-service-updated/' rel='bookmark' title='Auto-link text service updated'>Auto-link text service updated</a></li>
<li><a href='http://brettterpstra.com/automated-search-and-link-text-service/' rel='bookmark' title='Automated search and link text Service'>Automated search and link text Service</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/songza-lucky-link-service/">Songza Lucky Link Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/songza-lucky-link-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting back into real TextMate blogging</title>
		<link>http://brettterpstra.com/getting-back-into-real-textmate-blogging/</link>
		<comments>http://brettterpstra.com/getting-back-into-real-textmate-blogging/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 06:49:20 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[bundle]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=115</guid>
		<description><![CDATA[<p>It may take me a while to convert my setup back to the old days of TextMate blogging. I’ve primarily been blogging for TUAW, which uses a blogging system with very poor XMLRPC support. The end result of this, for me, was the development of an elaborate TextMate bundle which emulated the ease-of-use that TextMate provides to bloggers on WordPress&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/getting-back-into-real-textmate-blogging/">Getting back into real TextMate blogging</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/textmateblogging110409.jpg?9d7bd4" alt="textmateblogging110409" title="textmateblogging110409" width="440" height="187" class="headerimg alignnone size-full wp-image-119" />
It may take me a while to convert my setup back to the old days of TextMate blogging. I’ve primarily been blogging for <a href="http://tuaw.com">TUAW</a>, which uses a blogging system with very poor <a href="http://en.wikipedia.org/wiki/XMLRPC" title="Wikipedia Entry: XML-RPC">XMLRPC</a> support. The end result of this, for me, was the development of <a href="http://github.com/ttscoff/blogsmith-tmbundle">an elaborate TextMate bundle</a> which emulated the ease-of-use that TextMate provides to bloggers on WordPress (and other platforms). I have, I guess, forgotten how to do this. So this post is going to begin as a test, to be continued with some ideas, some tools, and some discoveries I’ve made in my time away from the glory of TextMate blogging.</p>

<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/textmateicon_1601.jpg?9d7bd4" alt="Textmateicon 160" height="160" width="160" class="alignleft"  />This paragraph is just to see if I can get an XMLRPC image upload to float left without additional Markdown code.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/autotag2-smarter-tagging-for-textmate-and-wordpress/' rel='bookmark' title='AutoTag2: smarter tagging for TextMate and WordPress'>AutoTag2: smarter tagging for TextMate and WordPress</a></li>
<li><a href='http://brettterpstra.com/wordpress-custom-taxonomy-and-xml-rpc/' rel='bookmark' title='WordPress, custom taxonomy, and XML-RPC'>WordPress, custom taxonomy, and XML-RPC</a></li>
<li><a href='http://brettterpstra.com/multimarkdown-in-marsedit/' rel='bookmark' title='MultiMarkdown in MarsEdit'>MultiMarkdown in MarsEdit</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/getting-back-into-real-textmate-blogging/">Getting back into real TextMate blogging</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/getting-back-into-real-textmate-blogging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 32/181 queries in 0.845 seconds using xcache
Object Caching 4248/4431 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-02-09 17:49:53 -->
