<?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 Terpstratextexpander page  - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/textexpander/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Tue, 22 May 2012 02:49:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Auto-pairing for MarsEdit and TextEdit using TextExpander</title>
		<link>http://brettterpstra.com/auto-pairing-for-marsedit-and-textmate-using-textexpander/</link>
		<comments>http://brettterpstra.com/auto-pairing-for-marsedit-and-textmate-using-textexpander/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:00:42 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3674</guid>
		<description><![CDATA[<p>Chetan Kunte recently sent me a TextExpander experiment he was working on, and I thought I’d post it and my explorations of it. It’s designed to add auto-pairing for bracket and quote characters to MarsEdit, and it’s based on a bit of information that I hadn’t been aware of before. The basis for the script is the fact that–little to&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/auto-pairing-for-marsedit-and-textmate-using-textexpander/">Auto-pairing for MarsEdit and TextEdit using TextExpander</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/2012/02/TextExpanderBracketed.jpg?9d7bd4" alt="TextExpander Auto-Pairing" title="TextExpander Bracketed" width="250" height="232" class="alignright size-full wp-image-3675" />Chetan Kunte recently sent me <a href="http://log.ckunte.net/post/17868016173/char-pair-marsedit">a TextExpander experiment</a> he was working on, and I thought I’d post it and my explorations of it. It’s designed to add auto-pairing for bracket and quote characters to MarsEdit, and it’s based on a bit of information that I hadn’t been aware of before.</p>

<p>The basis for the script is the fact that–little to my knowledge–TextExpander traps a delimiter sequence and leaves the selection in place while it expands it. This means that if your shell/AppleScript snippet wants to access the selected text after a single-character trigger, it can. It doesn’t store this information within TextExpander, so it takes some AppleScript shenanigans to get the selection from any given program. This is hugely frustrating because “selected text” is handled differently in almost every app, leading to a thousand permutations if you want a universally-capable snippet. However, it works, and the solution that Chetan came up with is a great start on this.</p>

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

<p>The experiment also makes use of a trick I learned from <a href="http://joeworkman.net/">Joe Workman</a> which allows you to call a “library” shell snippet within other snippets to create a “require” statement and reuse code within other snippets. In this case, it’s calling an AppleScript to get the selection from MarsEdit and insert it between characters. If there’s no selection, you get paired characters.</p>

<p>Chetan’s first version is <a href="https://github.com/ckunte/Character-pair-autocompletion">available on github</a>. My first addition to this script was to add a “%|” cursor placement so that your cursor was between the paired characters after expansion. I also added a block to check the frontmost app and allow the script to be expanded to any AppleScript-able application. TextEdit is the only additional app I’ve worked out so far. My version is available as a <a href="https://github.com/ttscoff/Character-pair-autocompletion">fork of Chetan’s</a> on github. You can download or subscribe to it using <a href="https://raw.github.com/ttscoff/Character-pair-autocompletion/master/character-pair-autocomplete.textexpander">the raw version of the TextExpander group</a>. Set up the group so that it only expands in the applications you have scripted for; by default this is just MarsEdit and TextEdit. The application-specific settings are available when you select the group’s folder icon after installing it in TextExpander.</p>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2012/02/charpairscreenshot.jpg?9d7bd4" alt="Screenshot of the Auto Pair group in TextExpander" title="TextExpander screenshot" width="366" height="209" class="shadow alignright size-full wp-image-3677" />As you can see in the screenshot to the right, the group consists of one AppleScript for gathering the selection (load the TextExpander group to see the actual script), and a series of plain text snippets that call the AppleScript snippet using the <code>%snippet:triggername%</code> syntax. In mine (shown), the <code>%|</code> places the cursor before the right character of the pair after expansion. Each snippet is triggered with the left character; in the case of square brackets, you would select text and type <code>[</code>. If no text is selected, you’ll just get “[]”, otherwise your selection will be wrapped in square brackets.</p>

<p>Then I went down a rabbit hole… I really wanted more intelligent pairing so that it wouldn’t pair if there was a character to the right, and would skip a character right if the adjacent character was already a quote. TextMate style. This proved to be nearly impossible, but you can find my experiments in this area in a <a href="https://github.com/ttscoff/Character-pair-autocompletion/tree/scripted">branch off my main repo</a>. The biggest issue is that I can’t control cursor placement from an AppleScript snippet. I could probably rewrite the whole thing to include a repeat AppleScript for each set of pairing characters, then call them from another set of plain text snippets, but I pulled myself out of the hole before I got too invested in it. If anyone finds a solution before I dive back in, I’d love to see it!</p>

<p>I’m not adding these to the TextExpander Tools project at this point, but feel free to download, play with, fork and make pull requests on <a href="https://github.com/ckunte/Character-pair-autocompletion">Chetan’s</a> and <a href="https://github.com/ttscoff/Character-pair-autocompletion">my repos</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</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/auto-pairing-for-marsedit-and-textmate-using-textexpander/">Auto-pairing for MarsEdit and TextEdit using TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/auto-pairing-for-marsedit-and-textmate-using-textexpander/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextExpander tools for AppleScript editing</title>
		<link>http://brettterpstra.com/textexpander-tools-for-applescript-editing/</link>
		<comments>http://brettterpstra.com/textexpander-tools-for-applescript-editing/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 18:21:30 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3666</guid>
		<description><![CDATA[<p>I added a new group to the TextExpander Tools collection this morning: a set of snippets for working in AppleScript editor. The group is pretty barebones right now, but handy nonetheless. Feel free to submit any additions or expansions you come up with, I’ll gladly include them in the set (and credit you publicly). I was actually working on a&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-tools-for-applescript-editing/">TextExpander tools for AppleScript editing</a></p>]]></description>
			<content:encoded><![CDATA[<p>I added a new group to the <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander Tools</a> collection this morning: a set of snippets for working in AppleScript editor. The group is pretty barebones right now, but handy nonetheless. Feel free to submit any additions or expansions you come up with, I’ll gladly include them in the set (and credit you publicly).</p>

<p>I was actually working on a more complex set of snippets involving some AppleScripting when I decided to build a few of these. I’ll try to post the results of that later today.</p>

<p>The snippets cover basic syntax for <code>if</code>, <code>tell</code>, <code>repeat</code> and setting variables and properties. For <code>if</code> and <code>tell</code>, following the trigger (“if” or “tell”) with a space will create a one-liner and reposition your cursor, following immediately with minus symbol (<code>-</code>) will create a block with an end block and put your cursor back in position for continuing the statement. <code>s=</code> and <code>p=</code> will use the Fill dialog to create <code>set</code> statements and <code>property</code> declarations, respectively.</p>

<p>You can pick up the group using the <a href="http://brettterpstra.com/share/te-snippets/index.php?group=AppleScript%20Editor&amp;prefix=">te-snippets tool</a>, which will allow you to download directly or give you a url you can subscribe to in TextExpander to automatically get updates as the group grows.</p>

<p><strong>Addendum:</strong> If it doesn’t come through in the <code>.textexpander</code> file, I should mention that I have the group set up in TextExpander to expand “Only in…” AppleScript Editor. Just select the group in the TextExpander window and set “Expand in:” as needed.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/' rel='bookmark' title='Markdown snippets for TextExpander touch'>Markdown snippets for TextExpander touch</a></li>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-tools-for-applescript-editing/">TextExpander tools for AppleScript editing</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textexpander-tools-for-applescript-editing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mac App Giveaway: TextExpander</title>
		<link>http://brettterpstra.com/mac-app-giveaway-textexpander/</link>
		<comments>http://brettterpstra.com/mac-app-giveaway-textexpander/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 18:00:25 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[giveaway]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac app store]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=3295</guid>
		<description><![CDATA[<p>Since it’s Black Friday, I’m going to run a second giveaway today: TextExpander. It’s one of my all-time favorite Mac utilities, and I have quite a few free snippets available to demonstrate its usefulness. It’s available in the Mac App Store for US $34.99, and it’s worth every penny. Today, though, you can comment below and be entered 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/mac-app-giveaway-textexpander/">Mac App Giveaway: TextExpander</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/11/TextExpander_icon.jpg?9d7bd4" alt="" title="TextExpander_icon" width="250" height="250" class="alignright size-full wp-image-3296" />Since it’s Black Friday, I’m going to run a second giveaway today: <a href="http://smilesoftware.com/TextExpander/index.html">TextExpander</a>. It’s one of my <a href="http://brettterpstra.com/tag/textexpander/">all-time favorite</a> Mac utilities, and I have quite a few <a href="http://brettterpstra.com/project/textexpander-tools/">free snippets available</a> to demonstrate its usefulness. It’s available <a href="http://itunes.apple.com/us/app/textexpander-for-mac/id405274824?mt=12">in the Mac App Store</a> for US $34.99, and it’s worth every penny. Today, though, you can <a href="#leave-a-reply">comment below</a> and be entered for a chance at one of three free licenses.</p>

<p>Winners will be drawn <strong>at noon on Wednesday, November 30th</strong> and notified by email. Please use a valid email address and a unique name (to make announcing the winners easier). One entry per person per giveaway, but feel free to enter for <a href="http://brettterpstra.com/tag/giveaway/">every giveaway</a> I’m running this week! I have a <em>lot</em> of amazing applications to share right now… keep checking back, there are at least three more coming before this madness ends!</p>

<p>Smile, the company behind TextExpander, is also running their own special for Black Friday. Today only, get <a href="http://smilesoftware.com/PDFpen/index.html">PDFPen</a> or <a href="http://smilesoftware.com/PDFpenPro/index.html">PDFPenPro</a> for <a href="http://sites.fastspring.com/smile/product/pdfpen5new&amp;coupon=FRIDAYPDFPEN">50% off</a>. It’s the perfect time to jump on one of the most powerful tools available for creating fillable forms and working with PDF files.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/mac-app-giveaway-byword/' rel='bookmark' title='Mac App Giveaway: Byword'>Mac App Giveaway: Byword</a></li>
<li><a href='http://brettterpstra.com/mac-app-giveaway-pdfpen/' rel='bookmark' title='Mac App Giveaway: PDFpen'>Mac App Giveaway: PDFpen</a></li>
<li><a href='http://brettterpstra.com/mac-app-giveaway-multimarkdown-composer/' rel='bookmark' title='Mac App Giveaway: MultiMarkdown Composer'>Mac App Giveaway: MultiMarkdown Composer</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/mac-app-giveaway-textexpander/">Mac App Giveaway: TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/mac-app-giveaway-textexpander/feed/</wfw:commentRss>
		<slash:comments>140</slash:comments>
		</item>
		<item>
		<title>Natural language dates for TextExpander</title>
		<link>http://brettterpstra.com/natural-language-dates-for-textexpander/</link>
		<comments>http://brettterpstra.com/natural-language-dates-for-textexpander/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 11:06:35 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[natural langauge]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2957</guid>
		<description><![CDATA[<p>: http://brettterpstra.com/share/te-snippets/index.php?group=Tools&#38;prefix=„ I had a strong urge to make a new TextExpander snippet this morning. I think the Date Math features of TextExpander that Donald Curtis turned me on to with his Date Time group got me thinking. I find my OS X Service for natural language date conversion pretty handy. I think TextExpander could make it handier, though, with&#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-dates-for-textexpander/">Natural language dates for TextExpander</a></p>]]></description>
			<content:encoded><![CDATA[<p>I had a strong urge to make a new <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> snippet this morning. I think the Date Math features of TextExpander that <a href="http://milkbox.net/">Donald Curtis</a> turned me on to with his <a href="https://gist.github.com/1282431">Date Time group</a> got me thinking.</p>

<p>I find my <a href="http://brettterpstra.com/os-x-service-for-natural-language-dates/">OS X Service for natural language date conversion</a> pretty handy. I think TextExpander could make it handier, though, with the form fill feature and a little more flexibility.</p>

<p>I’ve added the new snippet to the <a href="http://brettterpstra.com/project/textexpander-tools/#tools-emem">Tools group</a> in the <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander Project</a>, so TextExpander users can <a href="http://brettterpstra.com/share/te-snippets/index.php?group=Tools&amp;prefix=,,">grab the download or self-updating URL</a> and play with it.</p>

<h3>Of note</h3>

<p>It accepts most basic date language. “today”, “tomorrow”, “3 days”, “2 days ago”, “next tue”, “last fri”, etc.</p>

<p>I added a couple of checks. If you use a plus (+) or minus (-) sign followed immediately by a number and that’s all, it will just add or subtract that many days from the current date. The plus sign is optional, it will work with just “3” to give you the date 3 days from now.</p>

<p>If the words “am”, “pm”, “noon”, “midnight”, “hours” or “minutes” are in your string, it will add the time string to the formatted output.</p>

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

<h3>Setup</h3>

<p>This one runs on PHP, so it’s ready to use with your built-in tools and has no additional dependencies. There are a few things you can edit (and probably should) once you have it open in TextExpander.</p>

<p>First, <a href="http://php.net/manual/en/timezones.php">set the timezone</a> correctly for your location in the third line. The next line has the primary date format, which defaults to “l, M jS, Y”, like this: Saturday, Oct 15th, 2011. The line after that is the string that’s appended if you use a phrase that triggers a time for the output, defaulting to ” \a\t g:ia” which comes out as “at 3:00pm”.</p>

<p>The $debug parameter can be set to 0, 1 or 2. At zero, if your string fails to translate it will fail silently. At 1, it will return the phrase “Derp” where you meant to paste the date. I figure some feedback is better than none… at 3 it will give you the “Derp” <em>and</em> a Growl notification if you have <code>growlnotify</code> installed.</p>

<h3>The code</h3>

<p>You can just install this from the <a href="http://brettterpstra.com/share/te-snippets/index.php?group=Tools&amp;prefix=,,">project page</a>, but here’s the code if your curious. This looks a little different than what you see in the snippet, I’ll show you why in a second.</p>


<div class="wp_syntax"><div class="code"><pre class="php">#!/usr/bin/env php
<span class="kw2">&lt;?php</span>
<a href="http://www.php.net/date_default_timezone_set"><span class="kw3">date_default_timezone_set</span></a><span class="br0">&#40;</span><span class="st0">&quot;America/Chicago&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$dateformat</span> <span class="sy0">=</span> <span class="st0">&quot;l, M jS, Y&quot;</span><span class="sy0">;</span>
<span class="re0">$timeformat</span> <span class="sy0">=</span> <span class="st0">&quot; \a<span class="es1">\\</span>t g:ia&quot;</span><span class="sy0">;</span>
<span class="re0">$debug</span> <span class="sy0">=</span> <span class="nu0">2</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$input</span><span class="sy0">=</span><span class="st0">&quot;<span class="es6">%f</span>ill:Date string%&quot;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/preg_match"><span class="kw3">preg_match</span></a><span class="br0">&#40;</span> <span class="st0">&quot;/^([+-])?(\d+)$/&quot;</span><span class="sy0">,</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$input</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="re0">$matches</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> 
<span class="br0">&#123;</span>
  <span class="re0">$input</span> <span class="sy0">=</span> <span class="re0">$matches</span><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> <span class="sy0">.</span> <span class="st0">&quot; days&quot;</span><span class="sy0">;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$matches</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st0">&quot;-&quot;</span><span class="br0">&#41;</span> <span class="re0">$input</span> <span class="sy0">.=</span> <span class="st0">&quot; ago&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> 
<span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/preg_match"><span class="kw3">preg_match</span></a><span class="br0">&#40;</span><span class="st0">&quot;/([ap]m|noon|midnight|hours|minutes)/i&quot;</span><span class="sy0">,</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$input</span><span class="br0">&#41;</span><span class="sy0">,</span><span class="re0">$matches</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> 
<span class="br0">&#123;</span>
  <span class="re0">$dateformat</span> <span class="sy0">.=</span> <span class="re0">$timeformat</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$timestamp</span> <span class="sy0">=</span> <a href="http://www.php.net/strtotime"><span class="kw3">strtotime</span></a><span class="br0">&#40;</span><span class="st0">&quot;<span class="es4">$input</span>&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">===</span> <span class="kw4">false</span><span class="br0">&#41;</span> 
<span class="br0">&#123;</span>
  <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$debug</span> <span class="sy0">&gt;</span> <span class="nu0">1</span><span class="br0">&#41;</span> 
    `<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>bin<span class="sy0">/</span>growlnotify <span class="sy0">-</span>a TextExpander <span class="sy0">-</span>t <span class="st0">&quot;Natural language FAIL&quot;</span> <span class="sy0">-</span>m <span class="st0">&quot;I can't understand you when you mumble&quot;</span>`<span class="sy0">;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$debug</span> <span class="sy0">&gt;</span> <span class="nu0">0</span><span class="br0">&#41;</span> 
	<a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st_h">'Derp'</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span> 
<span class="kw1">else</span> 
<span class="br0">&#123;</span>
  <span class="kw1">echo</span> <a href="http://www.php.net/date"><span class="kw3">date</span></a><span class="br0">&#40;</span><span class="re0">$dateformat</span><span class="sy0">,</span><span class="re0">$timestamp</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>


<p>Because we’re using the newly-shell-script-friendly Fill feature, normally the entire script would show up in the fill box. That’s ugly. If we add some spacing before and after the Fill placeholder, we can clear most of the excess out. Like so:</p>

<pre><code>
[...]
$input=










                "%fill:Date string%";
                // mon, tue, next fri, tomorrow 3pm...
                // 1, 3, -2 (days), 30 minutes...
                // avoid "on" and "at", keep it simple.







if ( preg_match( "/^([+-])?(\d+)$/", trim($input), $matches ) )
[...]
</code></pre>

<p>Looks like this now:</p>

<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/10/fill_dialog_cleaned_up.jpg?9d7bd4" alt="Fill dialog cleaned up" /></p>

<p>Hopefully this will be useful for some of you!</p>
<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-date-service-update/' rel='bookmark' title='Natural Language Date Service update'>Natural Language Date Service update</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/natural-language-dates-for-textexpander/">Natural language dates for TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/natural-language-dates-for-textexpander/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New: TextExpander downloads with custom prefixes</title>
		<link>http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/</link>
		<comments>http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 18:01:11 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/</guid>
		<description><![CDATA[<p>Hey, TextExpander users! Wanna see something cool? I made a little tool this morning to allow any of my TextExpander groups to be installed with your own custom prefix. You can now use whatever is “standard” for your shortcuts. All of the group links on the project page now go to this tool, and you can open it directly for&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/">New: TextExpander downloads with custom prefixes</a></p>]]></description>
			<content:encoded><![CDATA[<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/03/custom_textexpander_url_screenshot.jpg?9d7bd4" alt="Custom TextExpander URL screenshot" /></p>

<p>Hey, <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> users! Wanna see something cool? I made a little tool this morning to allow any of my <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander groups</a> to be installed with your own custom prefix. You can now use whatever is “standard” for your shortcuts. All of the group links on the project page now go to this tool, and you can <a href="http://brettterpstra.com/share/te-snippets/">open it directly</a> for access to all of my groups.</p>

<p>The tool lets you select the group and enter your prefix, then provides you with a download link, a URL for “Add group from URL” in TextExpander, as well as a preview of all of the snippets in the group and how their shortcuts will be modified. If you follow a link from the TextExpander project page into the tool, it will select the appropriate group and add a suggested prefix automatically.</p>

<p>I’m more than happy to share the process and code with anyone who wants to implement it. There are folks working to bring together a <a href="http://te-snippets.com">TE community site</a>, and I’d love to see this kind of tool implemented there. I built it was a certain amount of scalability in mind, and made it as easy as possible for people to create compatible files for it.</p>

<p>If you want to add your own groups to my tool, let me know. I’ll come up with a way of providing attribution and possibly start a full repository here, to be mirrored or moved once a dedicated outlet becomes available.</p>

<h4>Addendum</h4>

<p>In case you’re wondering how it works: you take a .textexpander file, run a search and replace on it to change your own standard prefix into ‘[[PREFIX]]’ and rename the file with a <code>.tedist</code> extension. Drop it into a folder on the web server and it will automatically show up in the list of available groups, and the snippets preview is generated on the fly by parsing the plist via an Ajax call. No database for now, just globbing and parsing. I like it.</p>

<p>The code is <a href="https://github.com/ttscoff/Brett-s-TextExpander-Snippets">available on GitHub</a> for anyone who wants to play. The next step is to turn it into a community site: add a means of attribution (which will either mean a database or metadata in the .tedist files) and an uploader for contributions. Then search and organization features, of course. That’s the direction Poslavsky Alexander and I want to head with <a href="http://te-snippets.com">http://te-snippets.com</a>. We’ll keep you posted.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</a></li>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
<li><a href='http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/' rel='bookmark' title='Markdown snippets for TextExpander touch'>Markdown snippets for TextExpander touch</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/">New: TextExpander downloads with custom prefixes</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Additional Characters for TextExpander</title>
		<link>http://brettterpstra.com/additional-characters-for-textexpander/</link>
		<comments>http://brettterpstra.com/additional-characters-for-textexpander/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 10:56:59 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2101</guid>
		<description><![CDATA[<p>Thanks to Thomas Borowski, the Characters group in my TextExpander project has been expanded to include Home, End, Control, Escape, Enter and Delete symbols. Check it out on the TextExpander project page. If you already have the group installed from the URL, you can update it from within TextExpander. Related posts: New: TextExpander downloads with custom prefixes TextExpander tools for AppleScript editing&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/additional-characters-for-textexpander/">Additional Characters for TextExpander</a></p>]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a href="http://twitter.com/thomasborowski">Thomas Borowski</a>, the Characters group in my <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> project has been expanded to include Home, End, Control, Escape, Enter and Delete symbols. Check it out on the <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander project page</a>. If you already have the group installed from the URL, you can update it from within TextExpander.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</a></li>
<li><a href='http://brettterpstra.com/filesystem-navigation-with-textexpander/' rel='bookmark' title='Filesystem navigation with TextExpander'>Filesystem navigation with TextExpander</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/additional-characters-for-textexpander/">Additional Characters for TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/additional-characters-for-textexpander/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Filesystem navigation with TextExpander</title>
		<link>http://brettterpstra.com/filesystem-navigation-with-textexpander/</link>
		<comments>http://brettterpstra.com/filesystem-navigation-with-textexpander/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 17:39:46 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[finder]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/filesystem-navigation-with-textexpander/</guid>
		<description><![CDATA[<p>I just added a TextExpander group called “Filesystem” to my TextExpander project page. It’s just a small set of paths that I find myself typing often in support emails, but here’s the cool part: they also work in “Go to folder” mode in Finder dialogs. If you’re not familiar with “Go to folder,” it’s a keyboard geeks way of navigating&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/filesystem-navigation-with-textexpander/">Filesystem navigation with TextExpander</a></p>]]></description>
			<content:encoded><![CDATA[<p>I just added a <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> group called “Filesystem” to my <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander project page</a>. It’s just a small set of paths that I find myself typing often in support emails, but here’s the cool part: they also work in “Go to folder” mode in Finder dialogs.</p>

<p>If you’re not familiar with “Go to folder,” it’s a keyboard geeks way of navigating in Finder. From a finder window or any save/open dialog, just type Command-Shift-G to get a little dialog where you can type a path directly in POSIX syntax (<code>~/Library/etc.</code>). You can also bring it up just by typing the tilde symbol (~). Tab completion works to a minimal extent, in that it’s case sensitive and generally guess wrong if there is more than one possible completion. Handy nonetheless.</p>

<p>With these snippets, and any that you add, you can just type things like <code>~apps</code> to jump to your Application Support folder. I have a few that get more specific, but they’re not really general-use, so I kept them separate. The group is more of a starting point than any kind of complete library.</p>

<p>You can download it from the <a href="http://brettterpstra.com/project/textexpander-tools/">TextExpander project page</a> or, better yet, install it using the url provided there with the “Install from URL” option in TextExpander.</p>

<p>I also added some new snippets to the Characters set, and made some handy changes/additions to the CSS3 set. For example, it doesn’t automatically insert a “#” in the color field anymore, so you can use RGBA without having to backspace. It also adds a field in that snippet’s fill form for “inset” shadows. If you don’t want inset, just leave it blank, but if you do, fill it in with “inset” and you won’t have to manually edit that on all three lines after you insert. There’s a new snippet for RGBA colors, and an entire set of Webkit scrollbar mods you can use. Have fun.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</a></li>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/filesystem-navigation-with-textexpander/">Filesystem navigation with TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/filesystem-navigation-with-textexpander/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic placeholder images, now with kittens</title>
		<link>http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/</link>
		<comments>http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 01:27:25 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2014</guid>
		<description><![CDATA[<p>Thanks to Michael Jones for brightening an otherwise dull day for me. He pointed me to placekitten, a site that mimics placehold.it and inserts dummy images into HTML mockups for you. The difference being that placekitten does it with pictures of, yes, kittens. While you might not ever show a design filled with kittens to the average client, you can&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/">Dynamic placeholder images, now with kittens</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://placekitten.com/300/250" alt="KITTEH 300x250" width="300" height="250" class="alignright shadow" />Thanks to <a href="https://twitter.com/#!/TuxToaster">Michael Jones</a> for brightening an otherwise dull day for me. He pointed me to <a href="http://placekitten.com/">placekitten</a>, a site that mimics <a href="http://placehold.it">placehold.it</a> and inserts dummy images into HTML mockups for you. The difference being that placekitten does it with pictures of, yes, kittens.</p>

<p>While you might not ever show a design filled with kittens to the average client, you can keep yourself feeling warm and fuzzy while you code out the details. You were going to put the client’s images into those placeholders anyway, right?</p>

<p>For whatever you’d actually use it for, I threw snippets into the Tools group (<a href="http://brettterpstra.com/textexpander-experiments/">started here</a>) in my TextExpander snippets. If you’re curious, just install them from my <a href="http://brettterpstra.com/code/textexpander/">TextExpander project page</a>, or update your existing group if you’ve installed via the urls.</p>

<p>For reference, the snippet is simply this:</p>


<div class="wp_syntax"><div class="code"><pre class="html">&lt;img src=&quot;http://placekitten.com/g/%fill:width%/%fill:height%&quot; alt=&quot;KITTEH %fill:width%x%fill:height%&quot; width=&quot;%fill:width%&quot; height=&quot;%fill:height%&quot; /&gt;</pre></div></div>


<p>The <code>g/</code> in there makes it greyscale, just pull it out of the url to make it color instead. Both versions are in the Tools snippets.</p>

<p>Hey, lighten up. <a href="http://placekitten.com/">Try some kittens</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</a></li>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/">Dynamic placeholder images, now with kittens</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Markdown snippets for TextExpander touch</title>
		<link>http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/</link>
		<comments>http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 19:30:39 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1836</guid>
		<description><![CDATA[<p>It may come as a surprise to some (many), but I’ve never really made effective use of TextExpander on my iPad or iPhone (TextExpander touch). I don’t do a lot of the things on my iPad which I do on my desktop, and the things that are similar often don’t support TE. When I want to write some Markdown quickly,&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/">Markdown snippets for TextExpander touch</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/TextExpanderiOSIcon-1.jpg?9d7bd4" alt="" title="TextExpanderiOSIcon-1" width="186" height="187" class="alignright size-full wp-image-1837" />It may come as a surprise to some (many), but I’ve never really made effective use of <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> on my iPad or iPhone (<a href="http://smilesoftware.com/TextExpander/touch/index.html">TextExpander touch</a>). I don’t do a lot of the things on my iPad which I do on my desktop, and the things that are similar often don’t support TE. When I want to write some Markdown quickly, I use <a href="http://itunes.apple.com/us/app/nebulous-notes-for-dropbox/id375006422?mt=8">Nebulous Notes</a> with my custom macros. Lastly, my shell scripts don’t work on iOS, and most of my favorite snippets are, <a href="http://brettterpstra.com/tag/textexpander/">as you’ve seen</a>, shell scripts.</p>

<p>Early this morning, though, I decided to figure out how TextExpander was going to speed up what I do on iOS. The fact that %clipboard (insert contents of clipboard) and $| (position the cursor after inserting) still work on iOS is a big deal. I built quick snippets for auto-pairing characters and placing the cursor in the middle, and accompanying snippets for doing the same with the contents of the clipboard.</p>

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

<ul>
<li><code>[[</code> inserts “[]” and places the cursor between</li>
<li><code>((</code> inserts “()” and places the cursor between</li>
<li><code>""</code>, <code>&lt;&lt;</code>, same thing</li>
<li><code>c"</code>,<code>c[</code>,<code>c(</code> and <code>c&lt;</code> insert pairs surrounding the contents of the clipboard</li>
<li><code>/cl</code> creates an inline markdown link (<code>[](http://www.bla.com)</code>), assumes clipboard is the link and places cursor in the square brackets after insertion </li>
</ul>

<p>The biggest downside is the innate inability of TextExpander to act on selected text. To use the <code>c*</code> snippets effectively, you have to cut the text and then run the snippet. Not my favorite thing to do, but combined with the <code>$sel</code> macro in Nebulous Notes, they make for pretty snappy typing.</p>

<p>Here’s the current set of the ones that actually worked out. Let me know what you’re doing with TE in iOS and how you’re making it useful. I don’t need to know about your signoffs and abbreviations, of course, but general workflow enhancements would be awesome to hear about!</p>

<p><strong>Note:</strong> You can now install these using “Add group from URL” in TextExpander with this url:</p>

<p><code>http://brettterpstra.com/share/te-snippets/iOSMarkdown.textexpander</code></p>

<p>Then you can auto-update if I expand the set in the future. I’ll be adding urls for my other TE groups soon as well.</p>

<p><em>Both the above url and the download below have been updated to fix a typo in the <code>''</code> snippet.</em></p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/iOSMarkdown-TE-b.zip?9d7bd4" title="Download Markdown for TextExpander iOS (1181)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2011/02/TextExpanderiOSIcon-1.jpg?9d7bd4" alt="download image for Markdown for TextExpander iOS" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/iOSMarkdown-TE-b.zip?9d7bd4" title="Download Markdown for TextExpander iOS (1181)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/iOSMarkdown-TE-b.zip?9d7bd4" title="Download Markdown for TextExpander iOS (1181)">Markdown for TextExpander iOS</a> — Markdown snippets for TextExpander, especially useful on iOS. <a href="http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-tools-for-applescript-editing/' rel='bookmark' title='TextExpander tools for AppleScript editing'>TextExpander tools for AppleScript editing</a></li>
<li><a href='http://brettterpstra.com/new-textexpander-downloads-with-custom-prefixes/' rel='bookmark' title='New: TextExpander downloads with custom prefixes'>New: TextExpander downloads with custom prefixes</a></li>
<li><a href='http://brettterpstra.com/filesystem-navigation-with-textexpander/' rel='bookmark' title='Filesystem navigation with TextExpander'>Filesystem navigation with TextExpander</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/markdown-snippets-for-textexpander-on-ios/">Markdown snippets for TextExpander touch</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Dammit. Again with the Lipsum.</title>
		<link>http://brettterpstra.com/dammit-again-with-the-lipsum/</link>
		<comments>http://brettterpstra.com/dammit-again-with-the-lipsum/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 16:51:56 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1809</guid>
		<description><![CDATA[<p>I know, I said I was done with the Lorem Ipsum generators. Then Dr. Drang responded with a brilliant solution which doesn’t require Internet access to generate some beautiful dummy text. I set it up and ran it myself, and loved the results. Then I found myself wanting to expand it to do more, such as multiple paragraphs, list items&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/dammit-again-with-the-lipsum/">Dammit. Again with the Lipsum.</a></p>]]></description>
			<content:encoded><![CDATA[<p>I know, I <a href="http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/">said I was done</a> with the Lorem Ipsum generators. Then <a href="http://www.leancrew.com/all-this/2011/02/dissociated-darwin/">Dr. Drang responded</a> with a brilliant solution which doesn’t require Internet access to generate some beautiful dummy text. I set it up and ran it myself, and loved the results. Then I found myself wanting to expand it to do more, such as multiple paragraphs, list items and other things I use regularly when making dummy layouts. The problem is that I’m only good for one-liners in Perl, and didn’t want to take take the time to learn what I needed to in order to make the modifications. So I redid it in Ruby.<sup id="fnref:fn1"><a href="#fn:fn1" rel="footnote">1</a></sup></p>

<p>I used a Gem called <a href="https://github.com/postmodern/raingrams">Raingrams</a>, along with <a href="https://github.com/nex3/maruku">Maruku</a> for processing Markdown to HTML. See, if I had it output Markdown to begin with, I had the flexibility to do both easily. I’m posting the main script, which you can modify to output various elements and amounts of text. Even if you don’t know ruby, you can probably find your way around with a little guessing. In the section after the function definitions you can take any of the lines and output what you want by mixing or removing those elements.</p>

<p><span id="more-1809"></span>
This script requires Rubygems, and the Raingrams and Maruku gems. If you have Rubygems installed, you can just type <code>sudo gem install raingrams</code> and <code>sudo gem install maruku</code> at the command line to quickly get both on your system. If you don’t have Rubygems, you might want to skip this one, as you’re in for more trouble than this will pay off…</p>

<p>You’ll also need a text file to pull from. I’m using a chopped up version of 1984, with just enough paragraphs to get some good randomness. You can <a href="http://brettterpstra.com/share/1984trunc.txt">find it here</a>, if you want it. Otherwise, choose your favorite text file and make it long enough to be random and short enough to be fast. That might take some experimentation. Put the text in a file called <code>inputtext.txt</code> in a directory called <code>words</code> in the root of your home folder. The final path should look like <code>/Users/[YOUR USER NAME]/words/inputtext.txt</code>.</p>

<h3>The big script</h3>

<p>The script should have enough comments to make it relatively easy to dissect and rebuild as a TextExpander snippet for any individual part of it.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby"><span class="co1">#!/usr/bin/env ruby -rjcode -Ku</span>
&nbsp;
<span class="kw3">require</span> <span class="st0">'rubygems'</span>
<span class="kw3">require</span> <span class="st0">'raingrams'</span>
<span class="kw3">require</span> <span class="st0">'maruku'</span>
&nbsp;
<span class="kw1">include</span> Raingrams
&nbsp;
<span class="co1"># All (min,max) pairs need max &gt; min</span>
&nbsp;
<span class="re1">@model</span> = BigramModel.<span class="me1">build</span> <span class="kw1">do</span> <span class="sy0">|</span>model<span class="sy0">|</span>
  model.<span class="me1">train_with_text</span> <span class="kw4">File</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="kw4">File</span>.<span class="me1">expand_path</span><span class="br0">&#40;</span><span class="st0">'~/words/inputtext.txt'</span><span class="br0">&#41;</span>,<span class="st0">'r'</span><span class="br0">&#41;</span>.<span class="me1">read</span>
<span class="kw1">end</span>
&nbsp;
<span class="re1">@model</span>.<span class="me1">refresh</span>
&nbsp;
<span class="co1"># generates a paragraph with random sentences</span>
<span class="co1"># min = minimum sentences</span>
<span class="co1"># max = maximum sentences</span>
<span class="kw1">def</span> graf<span class="br0">&#40;</span>min,max<span class="br0">&#41;</span> 
  <span class="co1"># grab the paragraph and split it into words</span>
  para = <span class="re1">@model</span>.<span class="me1">random_paragraph</span><span class="br0">&#40;</span><span class="br0">&#123;</span>:min_sentences <span class="sy0">=&gt;</span> min,:max_sentences <span class="sy0">=&gt;</span> max <span class="br0">&#125;</span><span class="br0">&#41;</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span>
  <span class="co1"># add a random italics element</span>
  em = <span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span>para.<span class="me1">count</span> <span class="sy0">-</span> <span class="nu0">10</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="br0">&#41;</span>
  para<span class="br0">&#91;</span>em<span class="br0">&#93;</span> = <span class="st0">&quot;*#{para[em]}*&quot;</span>
  <span class="co1"># add a random bold element</span>
  strong = <span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span>para.<span class="me1">count</span> <span class="sy0">-</span> <span class="nu0">10</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="br0">&#41;</span>
  <span class="co1"># make sure they don't overlap</span>
  strong = strong <span class="sy0">-</span> <span class="nu0">2</span> <span class="kw1">if</span> strong == em
  para<span class="br0">&#91;</span>strong<span class="br0">&#93;</span> = <span class="st0">&quot;**#{para[strong]}**&quot;</span>
  <span class="co1"># add a multi-word link</span>
  link = <span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span>para.<span class="me1">count</span> <span class="sy0">-</span> <span class="nu0">10</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="br0">&#41;</span>
  linkend = link <span class="sy0">+</span> <span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">2</span><span class="br0">&#41;</span>
  para<span class="br0">&#91;</span>link<span class="br0">&#93;</span> = <span class="st0">&quot;[#{para[link]}&quot;</span>
  para<span class="br0">&#91;</span>linkend<span class="br0">&#93;</span> = <span class="st0">&quot;#{para[linkend]}](http://dummy.com)&quot;</span>
  <span class="kw2">return</span> para.<span class="me1">join</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span>
<span class="kw1">end</span>
&nbsp;
<span class="co1"># returns a random sentence, used in headlines</span>
<span class="co1"># min = minumum words, max = max words</span>
<span class="kw1">def</span> sentence<span class="br0">&#40;</span>min,max<span class="br0">&#41;</span> 
  <span class="kw2">return</span> <span class="re1">@model</span>.<span class="me1">random_sentence</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span>..<span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span>max <span class="sy0">-</span> min<span class="br0">&#41;</span><span class="sy0">+</span>min<span class="br0">&#41;</span><span class="br0">&#93;</span>.<span class="me1">join</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span>
<span class="kw1">end</span>
&nbsp;
<span class="co1"># returns a random list</span>
<span class="co1"># type = ul or ol</span>
<span class="co1"># min = minimum number of list items</span>
<span class="co1"># max = maximum number of list items</span>
<span class="kw1">def</span> list<span class="br0">&#40;</span>type,min,max<span class="br0">&#41;</span>
  list = <span class="st0">''</span>;
  prefix = type == <span class="st0">&quot;ol&quot;</span> ? <span class="st0">&quot; 1. &quot;</span> : <span class="st0">&quot; * &quot;</span>
  <span class="br0">&#40;</span><span class="kw3">rand</span><span class="br0">&#40;</span>max <span class="sy0">-</span> min<span class="br0">&#41;</span> <span class="sy0">+</span> min<span class="br0">&#41;</span>.<span class="me1">times</span> <span class="kw1">do</span>
    list <span class="sy0">+</span>= prefix <span class="sy0">+</span> <span class="re1">@model</span>.<span class="me1">random_gram</span>.<span class="me1">to_s</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span>&quot;</span>
  <span class="kw1">end</span>
  list <span class="sy0">+</span>= <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
  <span class="kw2">return</span> list
<span class="kw1">end</span>
&nbsp;
<span class="co1"># Sequentially builds an output variable (o)</span>
<span class="co1"># Chop this apart to make snippets as needed</span>
&nbsp;
<span class="co1"># Level 1 headline</span>
o = <span class="st0">&quot;# &quot;</span> <span class="sy0">+</span> sentence<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="nu0">5</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># 2 medium paragraphs</span>
<span class="nu0">2</span>.<span class="me1">times</span> <span class="kw1">do</span>
  o <span class="sy0">+</span>= <span class="st0">&quot;#{graf(4,6)}<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="kw1">end</span>
<span class="co1"># Level 2 headline</span>
o <span class="sy0">+</span>= <span class="st0">&quot;## &quot;</span> <span class="sy0">+</span> sentence<span class="br0">&#40;</span><span class="nu0">4</span>,<span class="nu0">7</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># 1 short paragraph</span>
o <span class="sy0">+</span>= graf<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="nu0">4</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># an unordered list</span>
o <span class="sy0">+</span>= list<span class="br0">&#40;</span><span class="st0">'ul'</span>,<span class="nu0">5</span>,<span class="nu0">8</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># 1 more long paragraph</span>
o <span class="sy0">+</span>= graf<span class="br0">&#40;</span><span class="nu0">6</span>,<span class="nu0">8</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># Level 3 header</span>
o <span class="sy0">+</span>= <span class="st0">&quot;### &quot;</span> <span class="sy0">+</span> sentence<span class="br0">&#40;</span><span class="nu0">5</span>,<span class="nu0">9</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># medium paragraph</span>
o <span class="sy0">+</span>= graf<span class="br0">&#40;</span><span class="nu0">4</span>,<span class="nu0">6</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
<span class="co1"># ordered list</span>
o <span class="sy0">+</span>= list<span class="br0">&#40;</span><span class="st0">'ol'</span>,<span class="nu0">5</span>,<span class="nu0">8</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\n</span><span class="es0">\n</span>&quot;</span>
&nbsp;
<span class="co1"># Process Markdown to HTML</span>
&nbsp;
<span class="co1"># if you want just the Markdown</span>
<span class="co1"># delete the two lines below</span>
<span class="co1"># and replace with 'puts o'</span>
doc = Maruku.<span class="me1">new</span><span class="br0">&#40;</span>o<span class="br0">&#41;</span>
<span class="kw3">puts</span> doc.<span class="me1">to_html</span>.<span class="kw3">gsub</span><span class="br0">&#40;</span><span class="sy0">/</span>\<span class="sy0">/</span>li<span class="sy0">&gt;</span>\n<span class="sy0">/</span>,<span class="st0">'/li&gt;'</span><span class="br0">&#41;</span>.<span class="kw3">gsub</span><span class="br0">&#40;</span><span class="sy0">/</span>\<span class="sy0">/</span>li<span class="sy0">&gt;&lt;</span>\<span class="sy0">/</span><span class="br0">&#40;</span><span class="br0">&#91;</span>uo<span class="br0">&#93;</span><span class="br0">&#41;</span>l<span class="sy0">/</span>,<span class="st0">&quot;/li&gt;<span class="es0">\n</span>&lt;/<span class="es0">\\</span>1l&quot;</span><span class="br0">&#41;</span>
<span class="co1"># the gsub is just to clean up maruku's double-spaced list output</span></pre></div></div>


<p><a href="http://peg.gd/17Q">Here’s some sample output</a>, generated in <a href="http://brettterpstra.com/code/notational-velocity-alt/">nvALT</a>, using <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> with this script as a shell Snippet, and posted to Peggd. As you can see, it needs some fine tuning. The list items, strong and em could be multi-word, the links could check to see if there was a period-space-capital and prevent overlapping sentences, etc. It’s enough for my purposes, though, and between the script and this post, I’ve lost over an hour of what was supposed to be a productive weekend. I’m out!</p>

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

<li id="fn:fn1">
<p>This isn’t a one-up on Dr. Drang; it’s a rough script, and I’m just posting what I wasted half an hour on last night. <a href="#fnref:fn1" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/the-quickcal-winners/' rel='bookmark' title='The QuickCal winners'>The QuickCal winners</a></li>
<li><a href='http://brettterpstra.com/random-lipsum-for-textexpander/' rel='bookmark' title='Random Lipsum for TextExpander'>Random Lipsum for TextExpander</a></li>
<li><a href='http://brettterpstra.com/grabbing-a-mac-apps-icon-advanced-bash-usage-2/' rel='bookmark' title='Grabbing a Mac app’s icon: advanced Bash usage'>Grabbing a Mac app’s icon: advanced Bash usage</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/dammit-again-with-the-lipsum/">Dammit. Again with the Lipsum.</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/dammit-again-with-the-lipsum/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch</title>
		<link>http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/</link>
		<comments>http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/#comments</comments>
		<pubDate>Sat, 05 Feb 2011 14:30:37 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1780</guid>
		<description><![CDATA[<p>Ok, this is the last TextExpander Lipsum post, I promise (with my fingers crossed). I’m posting a full TextExpander group with all of the TextExpander random Lorem Ipsum generators I’ve posted so far (LoremIpsum.com, LoremIpscream), plus some new ones based on the Kwisatz Haderach1 generator. That one seemed to make a few people pretty happy (looking at MacSparky). It combines&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/">One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch</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/kwisatzscreenshot.jpg?9d7bd4" alt="Kwisatzs Haderach screenshot" border="0" width="300" height="200" class="alignright" /></p>

<p>Ok, this is the last TextExpander Lipsum post, I promise (with my fingers crossed). I’m posting a full TextExpander group with all of the TextExpander random Lorem Ipsum generators I’ve posted so far (<a href="http://brettterpstra.com/random-lipsum-for-textexpander/">LoremIpsum.com</a>, <a href="http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/">LoremIpscream</a>), plus some new ones based on the <a href="http://kwisatz.hadera.ch/">Kwisatz Haderach</a><sup id="fnref:dune"><a href="#fn:dune" rel="footnote">1</a></sup> generator. That one seemed to make a few people pretty happy (looking at <a href="https://twitter.com/macsparky/status/33369498220236800">MacSparky</a>). It combines word lists from various “<a href="http://kwisatz.hadera.ch/universes">universes</a>,” including Dune, Foundation, Ringworld, Harry Potter and Doctor Who (Doctor Who courtesy of the always-fabulous <a href="http://thebananaverse.com/">Kelly Guimont</a>).</p>

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

<p>Here’s a sample snippet of Kwisatz Haderach text:</p>

<blockquote>
  <p>Grim Dark Liz Shaw remembrall crysknife mentat River Song gillyweed Zensunni Astrid Peth science fiction. Filt Plug ayat bi-la kaifa Polly Wright Gringotts. Suk Mahdi Gamont Rani guild Peri Brown Siona Cthalctose bludger mish mish. Basilisk travel Hufflepuff solari mentat Shadout Mapes ibad. Caid Tractite specials Chula Ian Chesterton Jal Karath inkvine Atraxi gom jabbar karama Killoran Shai Hulud musky Lords Of Jelsen.</p>
</blockquote>

<p>The Kwisatz Haderach set I threw together for TextExpander is multi-faceted, and includes some HTML versions of the snippets, which are of more use to web designers than just plain text. There are snippets for one, two and three paragraphs of Kwisatz text, and versions of the same which include <code>&lt;p&gt;</code> tags. There are also short and long HTML list generators for both ordered (<code>&lt;ol&gt;</code>) and unordered (<code>&lt;ul&gt;</code>) lists. To avoid the pains of parsing HTML in the shell (KH doesn’t currently have an API), they’re Ruby-based. I’m not going to post the code here, just download the package below. TextExpander users can just expand the archive and double click the .textexpander file to install it. If you want the raw code for something else, just contact me.</p>

<p>The scripts are easily editable to change the number of paragraphs and minimum words per paragraph, as well as the number of items in the lists, by using the variables at the top of the scripts. They should be pretty self explanatory, just replace the existing numbers with your preferred quantities.</p>

<p>Enjoy!</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/RandomLipsums.zip?9d7bd4" title="Download Random Lipsums for TextExpander (431)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/textexpandericon.png?9d7bd4" alt="download image for Random Lipsums for TextExpander" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/RandomLipsums.zip?9d7bd4" title="Download Random Lipsums for TextExpander (431)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/RandomLipsums.zip?9d7bd4" title="Download Random Lipsums for TextExpander (431)">Random Lipsums for TextExpander</a> — All of the random Lorem Ipsum generators for TextExpander that I’ve put together so far, including LoremIpscream, Kwisatz Haderach and LoremIpsum.com generators. <a href="http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach">More Info</a></p></div>

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

<li id="fn:dune">
<p>It’s a <a href="http://en.wikipedia.org/wiki/Dune_universe">Dune</a> reference, in case you’re not a Frank Herbert devotee. <a href="#fnref:dune" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/' rel='bookmark' title='TextExpander lipsum followup, with ice cream'>TextExpander lipsum followup, with ice cream</a></li>
<li><a href='http://brettterpstra.com/markdown-snippets-for-textexpander-on-ios/' rel='bookmark' title='Markdown snippets for TextExpander touch'>Markdown snippets for TextExpander touch</a></li>
<li><a href='http://brettterpstra.com/dammit-again-with-the-lipsum/' rel='bookmark' title='Dammit. Again with the Lipsum.'>Dammit. Again with the Lipsum.</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/">One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>TextExpander lipsum followup, with ice cream</title>
		<link>http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/</link>
		<comments>http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 19:00:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1732</guid>
		<description><![CDATA[<p>It turns out it was me that was broken, not the Loremipscream API. That API can return just plain text, so the shell scripts are much more readable than trying to hack apart XML in Bash. You can get a list of “flavors” from the website, or just curl "http://loremipscream.com/flavors.xml" from the command line. That will also give you the&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/">TextExpander lipsum followup, with ice cream</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2011/02/loripscream.jpg?9d7bd4"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/02/loripscream.jpg?9d7bd4" alt="loremipscream logo" title="loripscream" width="200" height="173" class="alignright shadow size-full wp-image-1733" /></a>It turns out it was <em>me</em> that was broken, not the <a href="http://loremipscream.com/">Loremipscream</a> API. That API can return just plain text, so the shell scripts are much more readable than trying to hack apart XML in Bash. You can get a list of “flavors” from the website, or just <code>curl "http://loremipscream.com/flavors.xml"</code> from the command line. That will also give you the slugs you need to use when calling them.</p>

<p><a href="http://en.wikipedia.org/wiki/Why_the_lucky_stiff">_why’s</a> Chunky Bacon<sup id="fnref:bacon"><a href="#fn:bacon" rel="footnote">1</a></sup> is nice, and Sailing Three Tuesdays<sup id="fnref:emo"><a href="#fn:emo" rel="footnote">2</a></sup> (whose slug is “emo,” appropriately) is hilarious. There’s even one (Soylent Cream) which spits out fake identities<sup id="fnref:soylent"><a href="#fn:soylent" rel="footnote">3</a></sup>, and there are German and Czech flavors, too. Try them out on the website and then just paste a line like this in a <a href="http://smileonmymac.com/TextExpander/">TextExpander</a> snippet set to “Shell Command”:</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="co0">#!/bin/bash</span>
curl <span class="st0">&quot;http://loremipscream.com/flavors/chunky_bacon/serving.txt&quot;</span></pre></div></div>


<p>That will spit out a nice, small chunk of random text in your preferred flavor. Of course, you could always make a few different snippets to suit any mood. For reference, here’s <a href="http://loremipscream.com/api">the API info</a>, and here are the available flavors and their slugs:</p>

<div class="collapse">


<div class="wp_syntax"><div class="code"><pre class="xml"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span><span class="re2">?&gt;</span></span>
<span class="sc3"><span class="re1">&lt;flavors<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Vanilla<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>vanilla<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Mint Chocolate Czech<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>mint<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Sailing Three Tuesdays<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>emo<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Soylent Cream<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>soylent<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Texas Toast<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>toast<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>German Chocolate<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>chocolate<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Chunky Bacon<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>chunky_bacon<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;flavor<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Neapolitician<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;slug<span class="re2">&gt;</span></span></span>neapolitician<span class="sc3"><span class="re1">&lt;/slug<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/flavor<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/flavors<span class="re2">&gt;</span></span></span></pre></div></div>



</div>

<p>I should also take the opportunity to mention another cool take on the “greeking” text idea: <a href="http://kwisatz.hadera.ch/">Kwisatz Haderach</a>, which my friend (and <a href="http://www.tuaw.com/bloggers/kelly-guimont/">TUAW blogger</a>) <a href="http://thebananaverse.com/">Kelly Guimont</a> has been contributing to. Have a look, it’s fun stuff. You can always make non-random TextExpander snippets out of whatever is going to be the most useful to you. Assuming Lorem Ipsum is useful to you, which is probably a poor assumption to make. I think we’ll both survive this, though.</p>

<p>If you haven’t seen <a href="http://brettterpstra.com/textexpander-experiments/">my last TextExpander bonanza</a>, check it out to see what else it can do. That one includes some good static Lipsum snippets and HTML Lipsum, amongst some neat tricks. I’ve posted <a href="http://brettterpstra.com/tag/textexpander/">a few other TextExpander experiments</a>, some more useful than others. Have a look, see if anything helps you out!</p>

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

<li id="fn:bacon">
<p><strong>Chunky Bacon:</strong> But I have ever seen, and Invernoire Fantome reminds me a random password. I dont quite remember the visionary machine-coddling antics of Temple Grandin. Shibata-san’s site is a company which specializes in belgian waffles and fun fun fun pictures. These guys shot a couple more, if you’re Japanese. <a href="#fnref:bacon" rev="footnote">↩</a></p>
</li>

<li id="fn:emo">
<p><strong>Sailing Three Thursdays:</strong><br />
Cause we know if this emptiness is called love, I don’t know what I wanna do.<br />
Cause we know the answer.<br />
Cause we hope you like what I have to take.<br />
Vengeance in his brain.<br />
When they are lame – no authority.<br />
She is the party next door. <a href="#fnref:emo" rev="footnote">↩</a></p>
</li>

<li id="fn:soylent">
<p><strong>Soylent Cream:</strong><br />
Valerie Wright<br />
Female<br />
569–82-2027<br />
3/1/1930<br />
Griffith<br />
99 Squier Road<br />
Bryant, AR 72089 <a href="#fnref:soylent" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/additional-characters-for-textexpander/' rel='bookmark' title='Additional Characters for TextExpander'>Additional Characters for TextExpander</a></li>
<li><a href='http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/' rel='bookmark' title='One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch'>One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch</a></li>
<li><a href='http://brettterpstra.com/filesystem-navigation-with-textexpander/' rel='bookmark' title='Filesystem navigation with TextExpander'>Filesystem navigation with TextExpander</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/">TextExpander lipsum followup, with ice cream</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Random Lipsum for TextExpander</title>
		<link>http://brettterpstra.com/random-lipsum-for-textexpander/</link>
		<comments>http://brettterpstra.com/random-lipsum-for-textexpander/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 05:38:41 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[experiments]]></category>
		<category><![CDATA[lorem ipsum]]></category>
		<category><![CDATA[textexpander]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1726</guid>
		<description><![CDATA[<p>I hate it when I get an idea for something simple and end up spending an hour figuring out how to do it. I figured I’d make a post out of it to make myself feel better. It all started with my being disappointed that the Loripscream API wasn’t working. I did a little digging and found that &#60;lipsum.com&#62; had&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/random-lipsum-for-textexpander/">Random Lipsum for TextExpander</a></p>]]></description>
			<content:encoded><![CDATA[<p>I hate it when I get an idea for something simple and end up spending an hour figuring out how to do it. I figured I’d make a post out of it to make myself feel better. It all started with my being disappointed that the <a href="http://loremipscream.com/api">Loripscream API</a> wasn’t working. I did a little digging and found that &lt;lipsum.com&gt; had a not-well-publicized XML feed you can pull from. That’s where the fun began.</p>

<p>The XML from lipsum.com must be malformed, although I only say that because System Events would <em>not</em> parse it in AppleScript. I resorted to Bash scripting, and probably did a pretty kludgy job of it, but it works.</p>

<p>You can adjust the following script to return anything from 1 word to 20 paragraphs (or more) of random <a href="http://www.lipsum.com/">Lorem Ipsum</a>. Just change the query values in the curl call: what (words, paras, or bytes), amount (self-explanatory, I hope) and the “start” parameter tells it whether or not to begin the line with “Lorem Ipsum dolor sit…” or make it completely random. I’m going with random.</p>

<p>Sure, you could use this from the shell and pipe it to <code>pbcopy</code>, but a <a href="http://smilesoftware.com/TextExpander/">TextExpander</a> snippet seemed like just the thing. Just create a new snippet and set the type to “Shell Script.” Then, paste this code in, modifying as you see fit.</p>


<div class="wp_syntax"><div class="code"><pre class="bash"><span class="co0">#!/bin/bash</span>
&nbsp;
curl <span class="re5">-s</span> <span class="st_h">'http://www.lipsum.com/feed/xml?amount=2&amp;what=paras&amp;start=0'</span><span class="sy0">|</span> \
xpath <span class="st_h">'//lipsum'</span> <span class="nu0">2</span><span class="sy0">&gt;/</span>dev<span class="sy0">/</span>null <span class="sy0">|</span> \ 
<span class="kw2">sed</span> <span class="re5">-e</span> <span class="st_h">'s/&lt;lipsum&gt;//'</span> <span class="re5">-e</span> <span class="st_h">'s/&lt;\/lipsum&gt;//'</span><span class="sy0">|</span> \
<span class="kw2">awk</span> <span class="re5">-F</span><span class="st0">&quot;<span class="es1">\n</span>&quot;</span> <span class="st_h">'{print $1&quot;\n&quot;}'</span></pre></div></div>


<p>For whatever that’s worth…</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-lipsum-followup-with-ice-cream/' rel='bookmark' title='TextExpander lipsum followup, with ice cream'>TextExpander lipsum followup, with ice cream</a></li>
<li><a href='http://brettterpstra.com/textexpander-lipsum-with-kwisatz-haderach/' rel='bookmark' title='One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch'>One more time: TextExpander Lipsum snippets with kwisatz​.hadera​.ch</a></li>
<li><a href='http://brettterpstra.com/dammit-again-with-the-lipsum/' rel='bookmark' title='Dammit. Again with the Lipsum.'>Dammit. Again with the Lipsum.</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/random-lipsum-for-textexpander/">Random Lipsum for TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/random-lipsum-for-textexpander/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>TextExpander: bit.ly with authentication</title>
		<link>http://brettterpstra.com/textexpander-bit-ly-with-authentication/</link>
		<comments>http://brettterpstra.com/textexpander-bit-ly-with-authentication/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 23:56:44 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[bit.ly]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[textexpander]]></category>
		<category><![CDATA[url shortener]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=1114</guid>
		<description><![CDATA[<p>A bit.ly shortening script for TextExpander which allows the use of the authenticated v3 API for click tracking and analytics.</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-bit-ly-with-authentication/">TextExpander: bit.ly with authentication</a></p>]]></description>
			<content:encoded><![CDATA[<p>A quick script in response to <a href="http://brettterpstra.com/textexpander-experiments/#comments">Donald’s query</a> on my TextExpander Experiments post. He wanted to know if I could make the bit.ly script—which expands to a bit.ly-shortened version of a url in the clipboard—work with an authenticated account, presumably for click tracking. Well, sure! Just adjust the script below to contain your bit.ly username and your <a href="http://bit.ly/a/your_api_key">API key</a> (in lines 6 &amp; 7), and replace the existing script in the <a href="http://brettterpstra.com/code/?did=6" title="Download the TextExpander Experiments bundle">TextExpander experiments bundle</a> with this one (or create a new snippet with the script).</p>


<div class="wp_syntax"><div class="code"><pre class="ruby"><span class="co1">#!/usr/bin/env ruby -wKU</span>
&nbsp;
<span class="kw3">require</span> <span class="st0">'open-uri'</span>
<span class="kw3">require</span> <span class="st0">'cgi'</span>
&nbsp;
USER_NAME = <span class="st0">'username'</span> <span class="co1"># Your login name</span>
API_KEY = <span class="st0">'yourlongapikey'</span> <span class="co1"># http://bit.ly/a/your_api_key</span>
&nbsp;
<span class="kw1">def</span> entity_escape<span class="br0">&#40;</span>text<span class="br0">&#41;</span>
  text.<span class="kw3">gsub</span><span class="br0">&#40;</span><span class="sy0">/&amp;</span><span class="br0">&#40;</span>?!<span class="br0">&#40;</span><span class="br0">&#91;</span>a<span class="sy0">-</span>zA<span class="sy0">-</span>Z0<span class="sy0">-</span><span class="nu0">9</span><span class="br0">&#93;</span><span class="sy0">+|</span><span class="co1">#[0-9]+|#x[0-9a-fA-F]+);)/, '&amp;amp;')</span>
<span class="kw1">end</span>
&nbsp;
<span class="kw1">def</span> make_link<span class="br0">&#40;</span>text<span class="br0">&#41;</span>
  <span class="kw1">case</span> text
  <span class="kw1">when</span> <span class="sy0">%</span>r<span class="br0">&#123;</span>\Ahttps?:<span class="sy0">//</span>.<span class="sy0">*</span>?\.\w<span class="br0">&#123;</span><span class="nu0">2</span>,<span class="nu0">4</span><span class="br0">&#125;</span>.<span class="sy0">*</span>?\z<span class="br0">&#125;</span>:
    entity_escape<span class="br0">&#40;</span>text<span class="br0">&#41;</span>
  <span class="kw1">when</span> <span class="sy0">%</span>r<span class="br0">&#123;</span>\A<span class="br0">&#40;</span>www\..<span class="sy0">*|</span>.<span class="sy0">*</span>\.\w<span class="br0">&#123;</span><span class="nu0">2</span>,<span class="nu0">4</span><span class="br0">&#125;</span><span class="br0">&#41;</span>\z<span class="br0">&#125;</span>:
    <span class="st0">&quot;http://#{entity_escape text}&quot;</span>
  <span class="kw1">when</span> <span class="sy0">%</span>r<span class="br0">&#123;</span>\A.<span class="sy0">*</span>?\.\w<span class="br0">&#123;</span><span class="nu0">2</span>,<span class="nu0">4</span><span class="br0">&#125;</span>\<span class="sy0">/</span>?.<span class="sy0">*</span>\z<span class="br0">&#125;</span>:
    <span class="st0">&quot;http://#{entity_escape text}&quot;</span>
  <span class="kw1">else</span>
    <span class="kw2">nil</span>
  <span class="kw1">end</span>
<span class="kw1">end</span>
&nbsp;
url = make_link <span class="sy0">%</span>x<span class="br0">&#123;</span>__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste<span class="br0">&#125;</span>.<span class="me1">strip</span>
res = <span class="kw3">open</span><span class="br0">&#40;</span><span class="st0">&quot;http://api.bit.ly/v3/shorten?login=#{USER_NAME}&amp;apiKey=#{API_KEY}&amp;longUrl=#{CGI.escape(url)}&amp;format=txt&quot;</span><span class="br0">&#41;</span>.<span class="me1">read</span> <span class="kw1">unless</span> url.<span class="kw2">nil</span>?
&nbsp;
<span class="kw1">begin</span>
  <span class="kw3">print</span> res <span class="kw1">unless</span> res.<span class="kw2">nil</span>?
<span class="kw1">rescue</span>
  <span class="kw3">exit</span>
<span class="kw1">end</span></pre></div></div>


<p>The API can output JSON and XML, which would be more appropriate on most occasions, but the “txt” format (which <em>only</em> includes the shortened link) is perfect for this situation. Enjoy!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/textexpander-experiments/' rel='bookmark' title='TextExpander experiments'>TextExpander experiments</a></li>
<li><a href='http://brettterpstra.com/sms-from-the-command-line-with-google-voice/' rel='bookmark' title='SMS from the command line with Google Voice'>SMS from the command line with Google Voice</a></li>
<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>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/textexpander-bit-ly-with-authentication/">TextExpander: bit.ly with authentication</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/textexpander-bit-ly-with-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Instant placeholder images with TextExpander</title>
		<link>http://brettterpstra.com/instant-placeholder-images-with-textexpander/</link>
		<comments>http://brettterpstra.com/instant-placeholder-images-with-textexpander/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 01:43:50 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[textexpander]]></category>
		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=866</guid>
		<description><![CDATA[<p>When designing for the web, placeholder images can come in handy during initial layout, and even during wireframing, if you happen to wireframe in markup. I’ve been using a TextExpander snippet to generate instant placeholder images at any size (almost) and with appropriate titles using Placehold.it. It’s a really handy snippet to have in your web design toolkit. Just create&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/instant-placeholder-images-with-textexpander/">Instant placeholder images with TextExpander</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=Placehold.it" alt="Placehold.it" width="200" height="150" class="alignright noshadow" /> When designing for the web, placeholder images can come in handy during initial layout, and even during wireframing, if you happen to wireframe in markup. I’ve been using a <a href="http://www.smileonmymac.com/textexpander/">TextExpander</a> snippet to generate instant placeholder images at any size (<a href="http://twitter.com/chockenberry/status/20348744761">almost</a>) and with appropriate titles using <a href="http://placehold.it/">Placehold.it</a>. It’s a really handy snippet to have in your web design toolkit.</p>

<p>Just create a new plain text snippet, title it “Placeholder Image,” give it whatever shortcut makes sense to you, and then add this code:</p>

<div markdown=0><pre><code>
&#x3C;img src=&#x22;http://placehold.it/%fill:width%x%fill:height%/333333/dddddd&#x26;text=%fill:title%&#x22; alt=&#x22;%fill:title%&#x22; width=&#x22;%fill:width%&#x22; height=&#x22;%fill:height%&#x22; /&#x3E;
</code></pre></div>

<p>It uses TextExpander 3’s Fill feature to get the width, height and title from you before it inserts the image tag. If you have multiple words in your title, use plus signs (+) instead of spaces (url encoded). I’ll be turning this into a <a href="http://www.macromates.com/">TextMate</a> snippet soon, too, and I’ll post that when I have another minute. I’d love to hear about any other great tools you’re using!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/dynamic-placeholder-images-now-with-kittens/' rel='bookmark' title='Dynamic placeholder images, now with kittens'>Dynamic placeholder images, now with kittens</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/natural-language-dates-for-textexpander/' rel='bookmark' title='Natural language dates for TextExpander'>Natural language dates for TextExpander</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/instant-placeholder-images-with-textexpander/">Instant placeholder images with TextExpander</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/instant-placeholder-images-with-textexpander/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 35/176 queries in 0.431 seconds using xcache
Object Caching 4314/4481 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-05-23 04:41:53 -->
