<?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>Think Vitamin &#187; Greg Annandale</title>
	<atom:link href="http://thinkvitamin.com/author/greg/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkvitamin.com</link>
	<description>The Web Practitioner&#039;s Blog</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:41:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>The Problem with Hits (Still)</title>
		<link>http://thinkvitamin.com/business/the-problem-with-hits-still/</link>
		<comments>http://thinkvitamin.com/business/the-problem-with-hits-still/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 09:00:03 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Business]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=11044</guid>
		<description><![CDATA[It would appear that the age-old confusion concerning the use of the word &#8216;hits&#8217; is as prevalent as ever, perhaps more so due to the increased, and now, ever-constant coverage of the web in the media. How often do we hear on the radio or in a TV interview a reference to how many hits [...]]]></description>
			<content:encoded><![CDATA[<p>It would appear that the age-old confusion concerning the use of the word &#8216;hits&#8217; is as prevalent as ever, perhaps more so due to the increased, and now, ever-constant coverage of the web in the media. How often do we hear on the radio or in a TV interview a reference to how many hits a particular site has received? I can say that it&#8217;s almost a daily occurrence for me.<span id="more-11044"></span></p>
<p>I&#8217;m going to assume that readers are more than familiar with the basics of web analytics, and the point of this piece is not necessarily to educate in this regard but rather to encourage that we do as much as we can to help clarify the situation. Each time I work with a new client I make a specific point of talking them through analytics and explicitly defining the difference between hits, visits (uniques &amp; recurring) and views.</p>
<p>Without fail, each one has mentioned that they had misunderstood the term &#8216;hits&#8217; and were glad to be informed (although often a little disappointed) that they should ignore it as a representation of a site&#8217;s popularity.</p>
<h3>A Quick Recap</h3>
<p>A a hit is a request received by a web server for a single file. Thus, a page load may result in a number of hits, for example: one for the page itself, another for the stylesheet, another for a JavaScript file and a further hit for each image. See the <a href="http://en.wikipedia.org/wiki/Web_analytics#Key_definitions">Wikipedia web analytics article</a> for a more in-depth look at the key definitions.</p>
<p>Why is it important to make the distinction between a hit and a page view? The problem is that the figure represented in the monthly hit count for a site really has no bearing on the number of page views and visits. Of course, there&#8217;s a linear relationship between page views and hits, assuming that each page has a similar number of hits per view (which often shouldn&#8217;t be the case if client-side caching is on and has been correctly configured).</p>
<h3>Counting Hits</h3>
<p>If a page has for example 20 external resources to be loaded, one view will of course generate 20 hits. Another page may have only 5 resources and so 5 hits are generated per view. This clearly indicates a huge discrepancy if a sole reliance on hits is used for judging the popularity of the page. The figure could naturally be far more extreme.</p>
<h3>Help Your Clients Understand</h3>
<p>So I&#8217;d like to encourage everyone to, at the very least, insist on making the above distinctions clear with their clients. Hopefully this will help clear up the confusion to some extent.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/business/the-problem-with-hits-still/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>High Scalability</title>
		<link>http://thinkvitamin.com/web-apps/high-scalability/</link>
		<comments>http://thinkvitamin.com/web-apps/high-scalability/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 16:01:32 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Web Apps]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=10866</guid>
		<description><![CDATA[Scaling a site or app is a tricky topic to tackle. There&#8217;s no shortage of technologies out there to increase performance, spread load, distribute databases and so forth; the difficulty is choosing from the sheer volume of options and permutations. It&#8217;s widely understood that languages don&#8217;t scale, but how should you choose your stack, caching [...]]]></description>
			<content:encoded><![CDATA[<p>Scaling a site or app is a tricky topic to tackle. There&#8217;s no shortage of technologies out there to increase performance, spread load, distribute databases and so forth; the difficulty is choosing from the sheer volume of options and permutations.</p>
<p>It&#8217;s widely understood that languages don&#8217;t scale, but how should you choose your stack, caching techniques, hardware (or whether to go virtual or cloud), monitoring tools and backup solutions? How should the database be structured and in what way will code upgrades / bug fixes / features be rolled out?<span id="more-10866"></span></p>
<p><a href="http://highscalability.com">Highscalability.com</a> covers this broad range of topics and, helpfully, has plenty of real-world examples. Ever wondered how Facebook deals with a staggering 2.7 million photo uploads every 20 minutes, or how Stack Overflow holds up with only a handful of servers and many million uniques a month? Here are a few links to some detailed rundowns:</p>
<ul>
<li><a href="http://highscalability.com/blog/2010/12/31/facebook-in-20-minutes-27m-photos-102m-comments-46m-messages.html">Facebook &#8211; Facebook in 20 Minutes: 2.7M Photos, 10.2M Comments, 4.6M Messages</a></li>
<li><a href="http://highscalability.com/blog/2010/12/28/netflix-continually-test-by-failing-servers-with-chaos-monke.html">Netflix &#8211; Continually Test by Failing Servers with Chaos Monkey</a></li>
<li><a href="http://highscalability.com/blog/2010/3/26/strategy-caching-404s-saved-the-onion-66-on-server-time.html">The Onion &#8211; Caching 404s Saved the Onion 66% on Server Time</a></li>
<li><a href="http://highscalability.com/blog/2009/8/31/squarespace-architecture-a-grid-handles-hundreds-of-millions.html">Squarespace &#8211; A Grid Handles Hundreds of Millions of Requests a Month</a></li>
<li><a href="http://highscalability.com/blog/2009/8/5/stack-overflow-architecture.html">Stack Overflow &#8211; Architecture</a></li>
</ul>
<p>Salesforce have always been very open about their force.com architecture; if you&#8217;re building an app requiring multi tenancy, their <a href="http://wiki.developerforce.com/index.php/Multi_Tenant_Architecture">white paper</a> and <a href="http://wiki.developerforce.com/index.php/Multitenancy_Webinar">webcast</a> covering their platform are well worth a look. As ever, Stack Overflow has plenty of interesting discussions, so be sure to read through the <a href="http://stackoverflow.com/questions/tagged/scalability">questions tagged &#8216;scalability&#8217;</a>.</p>
<p>I&#8217;d love to hear your recommended scalability resources, so do please post them in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/web-apps/high-scalability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geolocation Online Conference</title>
		<link>http://thinkvitamin.com/events/geolocation-online-conference/</link>
		<comments>http://thinkvitamin.com/events/geolocation-online-conference/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 17:37:05 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=10742</guid>
		<description><![CDATA[Join us on Thursday 13th January for 4 hours of geolocation sessions: Raffi Krikorian (Twitter) and Schuyler Erle (SimpleGeo) will be covering &#8216;What do users want with geo?&#8217; and &#8216;How to add geo to your app&#8217; during their 2 hour talks and will be answering your questions live in their individual Q&#38;A sessions. There&#8217;s no [...]]]></description>
			<content:encoded><![CDATA[<p>Join us on Thursday 13th January for 4 hours of geolocation sessions: Raffi Krikorian (Twitter) and Schuyler Erle (SimpleGeo) will be covering &#8216;What do users want with geo?&#8217; and &#8216;How to add geo to your app&#8217; during their 2 hour talks and will be answering your questions live in their individual Q&amp;A sessions.</p>
<p>There&#8217;s no need to take time away from the office and you can re-watch the conference recording as many times as you like after the event. <a href="http://thinkvitamin.com/online-conferences/geolocation/">Sign up now</a> on the <a href="http://thinkvitamin.com/online-conferences/">Think Vitamin Online Conferences site</a>.</p>
<p><em>Want access to more online conferences at a great discount?</em> Sign up to <a href="http://membership.thinkvitamin.com">Think Vitamin Membership</a> and you&#8217;ll get access to a set number of conferences and save money. If you&#8217;re already a member, you can select to attend the conference as part of your package.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/geolocation-online-conference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Faster Websites Online Conference</title>
		<link>http://thinkvitamin.com/events/faster-websites-online-conference-2/</link>
		<comments>http://thinkvitamin.com/events/faster-websites-online-conference-2/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 22:09:12 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=10459</guid>
		<description><![CDATA[We&#8217;ve got a great 4 hours of website / web app performance and optimization tutorials: the &#8216;Faster Websites&#8217; online conference with 3 amazing speakers. Here&#8217;s the rundown: Even Faster Web Sites &#8211; Steve Souders Backend Performance &#8211; Chris Lea Using nginx as a Reverse Proxy &#8211; Chris Lea NoSQL Databases &#8211; Mike Malone It&#8217;ll be [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a great 4 hours of website / web app performance and optimization tutorials: the &#8216;Faster Websites&#8217; online conference with 3 amazing speakers. Here&#8217;s the rundown:</p>
<ul>
<li><strong>Even Faster Web Sites </strong> &#8211; Steve Souders</li>
<li><strong>Backend Performance</strong> &#8211; Chris Lea</li>
<li><strong>Using nginx as a Reverse Proxy</strong> &#8211; Chris Lea</li>
<li><strong>NoSQL Databases </strong> &#8211; Mike Malone</li>
</ul>
<p>It&#8217;ll be kicking off at 9am Pacific / 5pm GMT on Thursday 16 December, so go ahead and <a href="http://thinkvitamin.com/online-conferences/faster-websites/">grab your tickets</a> now! There&#8217;s no need to take time away from the office and you can re-watch the conference recording as many times as you like after the event.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/faster-websites-online-conference-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone App Design Online Conference</title>
		<link>http://thinkvitamin.com/events/iphone-app-design-online-conference-3/</link>
		<comments>http://thinkvitamin.com/events/iphone-app-design-online-conference-3/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 21:59:15 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=9823</guid>
		<description><![CDATA[We&#8217;ve got a great 4 hours lined up for the iPhone App Design conference with 3 amazing speakers. Here&#8217;s the rundown: Design Workflow &#8211; Brian Fling iPhone UI Decisions &#38; iOS Gotchas &#8211; Sarah Parmenter App Usability &#8211; Brian Fling Preparing Your App for the Store &#8211; Malcolm Barclay It&#8217;ll be kicking off at 9am [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a great 4 hours lined up for the iPhone App Design  conference with 3 amazing speakers. Here&#8217;s the rundown:</p>
<ul>
<li><strong>Design Workflow</strong> &#8211; Brian Fling</li>
<li><strong>iPhone UI Decisions &amp; iOS Gotchas</strong> &#8211; Sarah Parmenter</li>
<li><strong>App Usability</strong> &#8211; Brian Fling</li>
<li><strong>Preparing Your App for the Store</strong> &#8211; Malcolm Barclay</li>
</ul>
<p>It&#8217;ll be kicking off at 9am Pacific / 5pm GMT on Tuesday 30 November, so go ahead and <a href="http://thinkvitamin.com/online-conferences/iphone-app-des/">grab your tickets</a> now! There&#8217;s no need to take time away from the office and you can re-watch the conference recording as many times as you like after the event.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/iphone-app-design-online-conference-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Faster Websites Online Conference</title>
		<link>http://thinkvitamin.com/events/faster-websites-online-conference/</link>
		<comments>http://thinkvitamin.com/events/faster-websites-online-conference/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 18:31:44 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=9775</guid>
		<description><![CDATA[We&#8217;ve got a great lineup for our upcoming &#8216;Faster Websites&#8217; online conference on December 16: Chris Lea, Steve Souders &#38; Mike Malone. 4 hours of in-depth discussion on optimization and performance, from front-end to back-end, with no travel costs and no time out of the office. Sign up here and check out our other upcoming [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a great lineup for our upcoming &#8216;Faster Websites&#8217; online conference on December 16: <strong>Chris Lea, Steve Souders &amp; Mike Malone</strong>. 4 hours of in-depth discussion on optimization and performance, from front-end to back-end, with no travel costs and no time out of the office. <a href="http://thinkvitamin.com/online-conferences/faster-websites/">Sign up here</a> and check out our other <a href="http://thinkvitamin.com/online-conferences/">upcoming conferences</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/faster-websites-online-conference/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iPhone App Design Online Conference</title>
		<link>http://thinkvitamin.com/events/iphone-app-design-online-conference-2/</link>
		<comments>http://thinkvitamin.com/events/iphone-app-design-online-conference-2/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 23:16:37 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=9713</guid>
		<description><![CDATA[Join us on Tuesday 30 November for the iPhone App Design conference; covering tons of useful info, tips &#38; tricks for new or current designers of apps from the masters, including Brian Fling, Sarah Parmenter and Malcolm Barclay. We’ll be covering topics such as Design Workflow, App Usability, iPhone UI Decisions &#38; iOS Gotchas &#38; [...]]]></description>
			<content:encoded><![CDATA[<p>Join us on Tuesday 30 November for the iPhone App Design conference;  covering tons of useful info, tips &amp; tricks for new or current  designers of apps from the masters, including <strong>Brian Fling</strong>, <strong>Sarah Parmenter</strong> and <strong>Malcolm Barclay</strong>.</p>
<p>We’ll be covering topics such as<strong> Design Workflow</strong>, <strong>App Usability, iPhone UI Decisions &amp; iOS Gotchas </strong>&amp;<strong> Preparing Your App for the Store</strong>.</p>
<p>It&#8217;ll be kicking off at 9am Pacific / 5pm GMT, so go ahead and <a href="../online-conferences/iphone-app-des/">grab your tickets</a> now!</p>
<p>There&#8217;s no need to take time away from the office and you can  re-watch the conference recording as many times as you like after the  event.</p>
<p><em>Want access to more online conferences at a great discount?</em> Sign up to <a href="http://membership.thinkvitamin.com/">Think Vitamin Membership</a> and you&#8217;ll get access to a set number of conferences and save money. If  you&#8217;re already a member, you can select to attend the conference as  part of your package.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/iphone-app-design-online-conference-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone App Design Online Conference</title>
		<link>http://thinkvitamin.com/events/iphone-app-design-online-conference/</link>
		<comments>http://thinkvitamin.com/events/iphone-app-design-online-conference/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 16:23:59 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=8827</guid>
		<description><![CDATA[We&#8217;ve got a great 4 hours lined up for the iPhone App Design conference; covering tons of useful info, tips &#38; tricks for new or current designers of apps. Here&#8217;s a rundown of the topics: Design Workflow &#8211; You&#8217;re already a web designer and have your preferred methods, techniques and tools. We&#8217;ll discuss how to [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a great 4 hours lined up for the iPhone App Design conference; covering tons of useful info, tips &amp; tricks for new or current designers of apps. Here&#8217;s a rundown of the topics:</p>
<ul>
<li><strong>Design Workflow</strong> &#8211; You&#8217;re already a web designer and have your preferred methods, techniques and tools. We&#8217;ll discuss how to modify and develop these to suit the requirements for iOS platform designs along with how to plan your app&#8217;s interface.</li>
<li><strong>App Usability</strong> &#8211; Taking existing apps as examples, we&#8217;ll look in detail at to what design patters exist on the platform and how form follows function throughout the various categories of apps available.</li>
<li><strong>iPhone UI Decisions &amp; iOS Gotchas</strong> &#8211; This session will discuss the nuances of designing for a touch screen device along with how to maintain the trademark Apple &#8216;look and feel&#8217; to your apps whilst staying creative and original. We&#8217;ll cover plenty of hints and tips such as optimum sizing of UI elements and colour palettes.</li>
<li><strong>Preparing Your App for the Store</strong> &#8211; We&#8217;ll cover all of the essential considerations in preparation for submitting your app, such as the icon, Apple&#8217;s app guidelines and regulations, to how to charge and how to maintain and update your app once it&#8217;s in the store.</li>
</ul>
<p>It&#8217;ll be kicking off at 9am Pacific on Tuesday 30 November, so go ahead and <a href="http://thinkvitamin.com/online-conferences/iphone-app-des/">grab your tickets</a> now!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/iphone-app-design-online-conference/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5 Online Conference</title>
		<link>http://thinkvitamin.com/events/html5-online-conference/</link>
		<comments>http://thinkvitamin.com/events/html5-online-conference/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 23:01:35 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=8475</guid>
		<description><![CDATA[We&#8217;ve got a great lineup for our next HTML5 online conference on 1st November: Patrick Lauke, Aaron Gustafson, Paul Irish and Molly Holzschlag. 4 hours of in-depth discussion on all you need to know about HTML5 with no travel costs and no time out of the office. Sign up here and check out our other [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a great lineup for our next HTML5 online conference on 1st November: <strong>Patrick Lauke</strong>, <strong>Aaron Gustafson</strong>, <strong>Paul Irish</strong> and <strong>Molly Holzschlag</strong>. 4 hours of in-depth discussion on all you need to know about HTML5 with no travel costs and no time out of the office. <a href="http://thinkvitamin.com/online-conferences/html5-nov/">Sign up here</a> and check out our other <a href="http://thinkvitamin.com/online-conferences/">upcoming conferences</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/html5-online-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Typography Online Conference</title>
		<link>http://thinkvitamin.com/events/web-typography-online-conference/</link>
		<comments>http://thinkvitamin.com/events/web-typography-online-conference/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 14:45:01 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://thinkvitamin.com/?p=8461</guid>
		<description><![CDATA[Join us on Monday, 25th October for 4 hours of typography sessions from the masters: including Richard Rutter, Jeffrey Veen, Matthew Smith and the Web Standardistas &#8211; Chris Murphy and Nicklas Persson. We&#8217;ll be covering topics such as &#8216;The Bright Future of Web Typography&#8216;, &#8216;Better Typography &#38; Setting a Grid&#8216; and &#8216;Communicating with Type&#8216; and [...]]]></description>
			<content:encoded><![CDATA[<p>Join us on Monday, 25th October for 4 hours of typography sessions from the masters: including <strong>Richard Rutter</strong>, <strong>Jeffrey Veen</strong>, <strong>Matthew Smith</strong> and the <strong>Web Standardistas &#8211; Chris Murphy and Nicklas Persson</strong>.</p>
<p>We&#8217;ll be covering topics such as &#8216;<strong>The Bright Future of Web Typography</strong>&#8216;, &#8216;<strong>Better Typography &amp; Setting a Grid</strong>&#8216; and &#8216;<strong>Communicating with Type</strong>&#8216; and the speakers will be answering your questions live in their individual Q&amp;A sessions.</p>
<p>There&#8217;s no need to take time away from the office and you can re-watch the conference recording as many times as you like after the event. <a href="http://thinkvitamin.com/online-conferences/web-typography/">Sign up now</a> on the <a href="http://thinkvitamin.com/online-conferences/">Think Vitamin Online Conferences site</a>.</p>
<p><em>Want access to more online conferences at a great discount?</em> Sign up to <a href="http://membership.thinkvitamin.com">Think Vitamin Membership</a> and you&#8217;ll get access to a set number of conferences and save money. If you&#8217;re already a member, you can select to attend the conference as part of your package.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/events/web-typography-online-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Textmate: Re-Usable Command Basics</title>
		<link>http://thinkvitamin.com/code/textmate-re-usable-command-basics/</link>
		<comments>http://thinkvitamin.com/code/textmate-re-usable-command-basics/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 14:51:49 +0000</pubDate>
		<dc:creator>Greg Annandale</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://carsonified.com/?p=3359</guid>
		<description><![CDATA[At first glance, Textmate can appear to be nothing more than a bog-standard code editor, lacking the more advanced features of an IDE. However, a quick look under the hood reveals how its relationship with UNIX command line tools has allowed it to become a supremely powerful editor. There are a whole host of available [...]]]></description>
			<content:encoded><![CDATA[<p>At first glance, Textmate can appear to be nothing more than a bog-standard code editor, lacking the more advanced features of an IDE. However, a quick look under the hood reveals how its relationship with UNIX command line tools has allowed it to become a supremely powerful editor.</p>
<p>There are a whole host of available commands and bundles, but what if you need to extend existing ones or create your own? I&#8217;ll cover some of the basics which will help you get started&#8230;</p>
<p>For this example, I&#8217;m going to perform a simple append to end-of-line (EOL) operation on selected text using <a href="http://www.gnu.org/software/sed/">sed</a>.</p>
<p><span id="more-3359"></span></p>
<h3>Using Filter Through Command</h3>
<p>Textmate&#8217;s &#8216;Filter Through Command&#8230;&#8217;  (under Text) is our first port of call. This will allow us to send input data from Textmate to a command and then return the command&#8217;s output to the current document.</p>
<p><img class="alignnone size-full wp-image-3360" title="tm_filter_command_sed" src="http://carsonified.com/wp-content/uploads/2009/09/tm_filter_command_sed.jpg" alt="tm_filter_command_sed" width="370" height="260" /></p>
<p><code>sed 's/$/,/'<br />
</code></p>
<p>We now end up with a comma at the end of each line of the selected text. The comma can of course be replaced with any string.</p>
<h3>Re-using Commands</h3>
<p>Textmate&#8217;s strength however lies in its bundles; essentially containers for re-usable blocks of code, templates and snippets. Rather than having to use the &#8216;Filter Through Command&#8217; feature each time, we can replicate its behaviour in a stored command. We can also extend the original sed command by taking the content of the clipboard and appending this to the end of each selected line.</p>
<p>Under <em>&#8216;Bundles &gt; Bundle Editor &gt; Show Bundle Editor&#8217;</em> we create a new command within the Text bundle.</p>
<p><img class="alignnone size-full wp-image-3361" title="tm_bundle_edit_eol" src="http://carsonified.com/wp-content/uploads/2009/09/tm_bundle_edit_eol.jpg" alt="tm_bundle_edit_eol" width="472" height="309" /></p>
<p><code>#!/bin/bash<br />
if [[ $(pbpaste|wc -l) -eq 0 ]]<br />
then r=`pbpaste`<br />
sed "s/$/$r/"<br />
else sed "s/$/,/"<br />
fi<br />
</code></p>
<p>The second line of our new command checks whether we have more than one line of data in the clipboard, if so we&#8217;ll default to simply appending a comma to the end of the selected lines (line 5). If the clipboard contains no more than one line, its contents are assigned to $r and placed into the sed command.</p>
<p>The input is &#8216;Selected Text&#8217; or &#8216;Nothing&#8217; and the output is &#8216;Replace Selected Text&#8217;. The command can be run by going to<em> &#8216;Bundles &gt; Text &gt; Name of command&#8217;</em>. We can also bind this command to a keyboard shortcut if we so wish.</p>
<h3>Adding simple UI elements</h3>
<p>As a final example, we can extend this command further by introducing a dialog box which prompts for the input of the string to be appended, rather than relying on the clipboard.</p>
<p>Create a new command under the Text bundle with the same input and output settings as above, enter the following as the command:</p>
<p><code>#!/bin/bash<br />
r=$(CocoaDialog inputbox --title "String to be appended to EOL" \<br />
--informative-text "Enter string:" \<br />
--button1 "Okay" --button2 "Cancel")<br />
[[ $(head -n1 &lt;&lt;&lt;"$r") == "2" ]] &amp;&amp; exit_discard<br />
r=$(tail -n1 &lt;&lt;&lt;"$r")<br />
sed "s/$/$r/"<br />
</code></p>
<p>A CocoaDialog input box is called and we create two buttons, &#8216;Cancel&#8217; and &#8216;Okay&#8217;, along with some assistive text. The dialog will return two lines of text:</p>
<ol>
<li>the button pressed (numeric)</li>
<li>the string entered into the input</li>
</ol>
<p>On line 6, we perform a check to see whether the &#8216;Cancel&#8217; button was clicked (button number 2). If so we can exit, otherwise we retrieve the content of the second line returned by the dialog, assign this to $r and place it into our sed command.</p>
<p><img class="alignnone size-full wp-image-3362" title="tm_append_eol_dialog" src="http://carsonified.com/wp-content/uploads/2009/09/tm_append_eol_dialog.jpg" alt="tm_append_eol_dialog" width="394" height="126" /></p>
<p>Hopefully you&#8217;ll be inspired to modify and extend the examples for your own use. Please feel free to post these in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkvitamin.com/code/textmate-re-usable-command-basics/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.272 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-11 10:24:33 -->

