<?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>The Joy of Hack &#187; Efficiency</title>
	<atom:link href="http://www.aijazansari.com/tag/efficiency/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aijazansari.com</link>
	<description>For people who like to make things</description>
	<lastBuildDate>Tue, 20 Jul 2010 13:20:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Firefox Search Shortcut</title>
		<link>http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/</link>
		<comments>http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 17:00:00 +0000</pubDate>
		<dc:creator>Aijaz Ansari</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Productivity]]></category>

		<guid isPermaLink="false">http://www.aijazansari.com/?p=528</guid>
		<description><![CDATA[Wow.  This cool Firefox feature has been around since 2005, but I just found out about it a few months ago!  I swear I haven&#8217;t been living in a cave all this time.  So if you&#8217;re like me and don&#8217;t know about this yet, listen up:  In Firefox, you can bookmark a search with a [...]]]></description>
			<content:encoded><![CDATA[<p>Wow.  This cool Firefox feature has been around since 2005, but I just found out about it a few months ago!  I swear I haven&#8217;t been living in a cave all this time.  So if you&#8217;re like me and don&#8217;t know about this yet, listen up:  In Firefox, you can bookmark a search with a keyword, and then use that keyword in your URL entry field.  As <a href="http://johnbokma.com/firefox/keymarks-explained.html">this article</a> shows, you right-click on the input field and select &#8220;Add a Keyword for this Search.&#8221;  This will allow you to bookmark the search and add a keyword.  I usually use two letter keywords like &#8216;we&#8217; for weather.com and &#8216;im&#8217; for imdb.com.</p>
<p>In the case of &#8216;im,&#8217; I first manually went to the imdb.com site and looked for the search form at the top of the page.  I right-clicked on the input field, and selected &#8216;im&#8217; as the keyword for that search.  So now, whenever I want to look up something on imdb, all I have to do is hit &#8216;Cmd-L&#8217; on my Mac to shift focus to the URL bar, enter &#8216;im&#8217; followed by the query string and then hit enter.  Then I&#8217;m taken directly to the search results page.  It saves me from having to navigate to imdb.com first. It works really well for all kinds of searches, including CPAN, Wikipedia and Weather.com.</p>
<p>I can&#8217;t believe I wasn&#8217;t aware of this shortcut all this time <img src='http://www.aijazansari.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div id="attachment_596" class="wp-caption alignnone" style="width: 344px"><a rel="attachment wp-att-596" href="http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/addkeyword/"><img class="size-full wp-image-596" title="Adding a Keyword to the CPAN Search Box" src="http://www.aijazansari.com/wp-content/uploads/2010/04/addKeyword.png" alt="Adding a Keyword to the CPAN Search Box" width="334" height="298" /></a><p class="wp-caption-text">Adding a Keyword to the CPAN Search Box</p></div>
<div id="attachment_595" class="wp-caption alignnone" style="width: 346px"><a rel="attachment wp-att-595" href="http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/enterkeyword/"><img class="size-full wp-image-595" title="Entering the Keyword" src="http://www.aijazansari.com/wp-content/uploads/2010/04/EnterKeyword.png" alt="Entering the Keyword" width="336" height="175" /></a><p class="wp-caption-text">Entering the Keyword</p></div>
<div id="attachment_594" class="wp-caption alignnone" style="width: 422px"><a rel="attachment wp-att-594" href="http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/keywordprompt/"><img class="size-full wp-image-594" title="The Keyword Search In Action" src="http://www.aijazansari.com/wp-content/uploads/2010/04/KeywordPrompt.png" alt="The Keyword Search In Action" width="412" height="65" /></a><p class="wp-caption-text">The Keyword Search In Action</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.aijazansari.com/2010/04/03/firefox-search-shortcut/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Performance Cost of Using WordPress</title>
		<link>http://www.aijazansari.com/2010/03/31/performance-cost-of-using-wordpress/</link>
		<comments>http://www.aijazansari.com/2010/03/31/performance-cost-of-using-wordpress/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:57:48 +0000</pubDate>
		<dc:creator>Aijaz Ansari</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[Etag]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Metrics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Safari Web Browser]]></category>
		<category><![CDATA[Spiders]]></category>
		<category><![CDATA[TaskForest]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.aijazansari.com/?p=531</guid>
		<description><![CDATA[I recently tried to switch a website over from a homegrown content management system to WordPress.  The results were thoroughly disheartening.  This post illustrates the steps I took, and how I managed to move in the opposite direction and optimize my site even more.  ]]></description>
			<content:encoded><![CDATA[<p>Happy with my experience with a custom WordPress installation for this blog, I decided to try using the blogging platform for the <a title="TaskForest Job Scheduler" href="http://www.taskforest.com/">TaskForest</a> website.  The two main reasons were the ease of creating RSS feeds and the ability for users to comment on posts or articles.  After a few days of tinkering around, I&#8217;ve come to the conclusion that, at least for TaskForest, WordPress would cause more problems than it would solve. Here&#8217;s how I came to that conclusion:</p>
<h2>Setting up a Sandbox Domain</h2>
<p>The first step in trying out WordPress was to set up a new domain just for testing out the WordPress installation.  This way, I wouldn&#8217;t affect the taskforest.com domain during my experiments.  I happen to run my own name servers using Daniel Bernstein&#8217;s <a href="http://cr.yp.to/djbdns.html"><em>tinydns</em></a>, so I decided to create a new domain called <em>tf.enoor.com</em>, a subdomain of my defunct company&#8217;s domain.  Since I use bluehost.com&#8217;s WordPress hosting service, I had to make their name servers responsible for the domain.  All that&#8217;s needed is adding the following two lines to <em>/etc/tinydns/root/data</em>:</p>
<pre class="brush: plain;">
&amp;tf.enoor.com:74.220.195.31:ns1.bluehost.com:300
&amp;tf.enoor.com:69.89.16.4:ns2.bluehost.com:300
</pre>
<h2>Selecting a Theme</h2>
<p>After setting up WordPress, the next step was to select a theme.  I wanted something similar to TaskForest&#8217;s current design, so I chose the remarkably customizable <a title="Suffusion" href="http://www.aquoid.com/news/themes/suffusion/">Suffusion</a> theme.  After some tinkering I was able to get a site that was quite similar to the original, with one compromise &#8211; I could get either the logo or the site&#8217;s name in the header, but not both.  Not the way they are on the current site.  It&#8217;s quite important that the site&#8217;s name appear in the header, because that helps with Search Engine Ranking.  So with a heavy heart I decided to omit the logo.</p>
<h2>The Problem with Content</h2>
<p>TaskForest ships with its own web server to support <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> interface.  As part of the included website is all the documentation for the system. Just like the code, this documentation is under source control, and it&#8217;s also used to populate the taskforest.com website.  This way, I can ensure that both the taskforest.com website and a user&#8217;s local install have the most up-to-date docs, as long as the user is running the latest version of the software.  What this also means is that I have a few dozen webpages that need to be transfered to WordPress before the new site can go live.  I was already resigned to the fact that the URLs of these pages would be different &#8211; the current site has URLs that look like <em>http://www.taskforest.com/about.html</em>, but the default WordPress installation would use URLs that look like <em>http://www.taskforest.com/about/</em>.  It&#8217;s not a huge deal, but I prefer my way.</p>
<p>The bigger issue is that when a new version of the software is released, the pages change.  The current build process ensures that the client website and the taskforest.com website stay in sync.  Now if I use WordPress, I don&#8217;t want to manually edit the pages using the WP admin site.  I need to install a new plugin that handles inclusion of files.  So, I installed the WP Include plugin.  I&#8217;d have to change my build process, but I could get it to work.</p>
<h2>Putting It All Together</h2>
<p>Okay, so I got the themes and plugins installed, and I&#8217;ve got the process worked out.  It was then time to try a proof of concept with a single page.  It worked just as expected, but the site seemed very sluggish.  I made sure I didn&#8217;t have anything enabled that I didn&#8217;t need.  Still, the site was noticeably slower than the existing site, and that&#8217;s with only one non-blank page and zero blog posts.  I thought that maybe the problem was that the bluehost.com shared server was too slow.  I just happened to have an unused server in the same data center that hosts taskforest.com.  The same kind of server as well. It took the better part of the morning, but I installed PHP, mysql and WordPress on that server.  In installed PHP as a static module within Apache, for optimal performance.  Even then, on a pristine machine running nothing else, it was <strong>slow</strong>.</p>
<h2>How Slow is Slow?</h2>
<p>Anyone who knows me knows that I&#8217;m an Engineer, and as an Engineer I like metrics.  I wanted to know that it wasn&#8217;t just my own bias that was penalizing WordPress over my established way of doing things.  So, I looked at the Safari web browser on the Mac.  Safari has a really useful feature called the Web Inspector that, among other things, displays the amount of time it takes for different parts of a page to load.  The numbers were very surprising.  With WordPress, a new page would take <strong>1.75</strong> seconds to load &#8211; an eternity on a high-speed broadband connection.  A subsequent request of the same page would take about <strong>700ms</strong>. Switching to the TaskForest website&#8217;s strategy would take about <strong>800ms</strong> for a new page, and <strong>275ms</strong> for a cached page.  That&#8217;s more than a <strong>20</strong><strong>0%</strong> increase in speed!  The TaskForest website used a preprocessor that allowed for including header files.  It ran under mod_perl.  I decided to write a spider that crawled the website and convert everything to static pages, and serve those pages without mod_perl.  With this enhancement, the results were even better.  I saw a <strong>400% to 800% speed increase</strong>, with cached pages taking just <strong>140ms</strong> to load.</p>
<p>One of the reasons WordPress&#8217;s numbers were so poor is that if articles like <a href="http://www.codinghorror.com/blog/2008/04/behold-wordpress-destroyer-of-cpus.html">this one</a> are still correct, WordPerfect does not cache the content of pages by default.  Resources within the HTML page, like images or javascript files seem to be cached, but every page still does upto 120 database accesses depending on the setup.  Apache is a lot better at caching requests for static HTML pages.  Even the TaskForest webserver used for the REST API, caches data very intelligently using the HTTP headers.</p>
<h2>What Does This All Mean?</h2>
<p>Given the amount of compromises I would have to make in the design, layout and build process, switching to WordPress would have been very painful.  However, with the performance hit the site would be taking, it seems unlikely that I&#8217;ll switch to WP any for the TaskForest website any time soon.  I think I&#8217;d rather write a script to generate RSS feeds on demand and automatically submit the feed to feed notification sites like pingomatic. I think this was a great learning experience that will help me with similar decisions in the future.  And I also got to write a cool spider and increase the speed of the TaskForest web site.</p>
<div id="attachment_559" class="wp-caption alignnone" style="width: 595px"><a rel="attachment wp-att-559" href="http://www.aijazansari.com/2010/03/31/performance-cost-of-using-wordpress/webinspector/"><img class="size-large wp-image-559" title="Safari's Web Inspector" src="http://www.aijazansari.com/wp-content/uploads/2010/03/WebInspector-585x351.png" alt="" width="585" height="351" /></a><p class="wp-caption-text">Safari&#39;s Web Inspector</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.aijazansari.com/2010/03/31/performance-cost-of-using-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Why Text Editors Matter</title>
		<link>http://www.aijazansari.com/2010/01/26/why-text-editors-matter/</link>
		<comments>http://www.aijazansari.com/2010/01/26/why-text-editors-matter/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 04:46:17 +0000</pubDate>
		<dc:creator>Aijaz Ansari</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Editors]]></category>
		<category><![CDATA[Efficiency]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[VI]]></category>

		<guid isPermaLink="false">http://www.aijazansari.com/?p=186</guid>
		<description><![CDATA[A good editor is a very flexible tool.  Once you become an expert at it, you can use it to accomplish tasks almost as quickly as you can think of them.]]></description>
			<content:encoded><![CDATA[<p>As of this past weekend it&#8217;s been fifteen years since I started my career as a software developer.  With the exception of a few months here and there, I&#8217;ve spent all these years working on Linux or Unix-like operating systems.  I&#8217;ve noticed that despite the wide variety of tools and applications I have used and continue to use, some key skills are always in demand in this field. One of these is mastery of a text editor.<span id="more-186"></span></p>
<div id="attachment_195" class="wp-caption alignleft" style="width: 230px"><a rel="attachment wp-att-195" href="http://www.aijazansari.com/2010/01/26/why-text-editors-matter/editor/"><img class=" wp-image-195 " title="Emacs Screenshot" src="http://www.aijazansari.com/wp-content/uploads/2010/01/editor.jpg" alt="Emacs Screenshot" width="220" height="258" /></a><p class="wp-caption-text">The emacs editor</p></div>
<p>In their book &#8220;<a href="http://www.pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a>,&#8221; Andrew Hunt and David Thomas stress to &#8220;Use a single editor well. The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable.&#8221;  I couldn&#8217;t agree with this more.  A good editor is a very flexible tool.  Once you become an expert at it, you can use it to accomplish tasks almost as quickly as you can think of them.  You need to process a file as a one-off?  You could write a perl or python script, or an awk/sed one-liner, but often you could also do it in an editor &#8211; with the benefit of &#8216;Undo.&#8217;</p>
<p>A good editor is configurable, so that you can use it the way that works best for you.  Most editors have more than one way to do things, and there is no right way, just the way that works for you and helps you reach your goal quickly and efficiently. A good editor is extensible, so that it can grow along with your needs.  You need syntax highlighting for the new programming language that was invented after your editor?  You should be able to go online and download an extension module &#8211; or write one yourself.  A good editor is programmable.  Your job requires you to document functions and change histories a certain way &#8211; your editor should allow you to change its behavior, so that you don&#8217;t have to repeat the same kinds of tasks over and over again.</p>
<p>One of the best ways to learn what you can do with editors is to watch others.  Do you have a coworker whose fingers fly across the keyboard while she bends text files to her will? It may not be just that she&#8217;s a fast typist &#8211; she&#8217;s probably really comfortable using her editor.  Search for these people, ask for advice and take notes.  Try different options out, pick an editor, and invest the time to learn it well. You&#8217;ll be doing your career a favor.</p>
<p>There is no real correct answer to the question &#8220;Which editor is best?&#8221;  But there is one absolute: If you work on a Linux or Unix system, you <strong>must</strong> know how to use the <code>vi</code> editor.  This is because every Linux or Unix system has at least that one editor installed.  Depending on your line of work, it may not be unusual to find yourself on a machine that has <em>only</em> that editor installed.  I started off using <code>vi</code> in college and took the time to learn it well.  Years later I found myself in a short lull while switching from the IS41 to the VLR products at Motorola.  I took advantage of the downtime by teaching myself <code>emacs</code> and have been primarily an <code>emacs</code> user for since then (about 11 years now).  While I prefer <code>emacs</code>, I still use <code>vi</code> every so often, and consider myself fortunate because I know both.</p>
<p>There are many other editors out there and a lot of them would probably meet Hunt&#8217;s and Thomas&#8217;s criteria, but I would like to add one more to their list:  A good editor must be usable without a windowing system.  I have also played the role of system administrator, and none of my hosted machines ever had a windowing system installed.  This means I could not run eclipse or even jedit.  The only editors I could install and use were ones that would work in a text window (an xterm).  So it was either <code>vi</code> or <code>emacs</code>.</p>
<p>Pick a good editor, one that meets the criteria listed above, and learn it well.  Spend the time to become an expert. The time you invest will be paid back in increased productivity, power and flexibility.</p>
<div class="wp-caption alignnone" style="width: 630px"><img class="  size-full" title="Real Programmers - xkcd" src="http://imgs.xkcd.com/comics/real_programmers.png" alt="Real Programmers - xkcd" width="620" height="349" /><p class="wp-caption-text">Real Programmers - from http://xkcd.com/378</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.aijazansari.com/2010/01/26/why-text-editors-matter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
