<?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>WiseBison</title>
	<atom:link href="http://www.wisebison.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wisebison.com</link>
	<description>coding tutorials for newbies and entrepreneurs</description>
	<lastBuildDate>Sun, 20 May 2012 03:43:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Dear Diary: Day 2 of Software Engineering for SaaS</title>
		<link>http://www.wisebison.com/3000/dear-diary-day-2-of-software-engineering-for-saas/</link>
		<comments>http://www.wisebison.com/3000/dear-diary-day-2-of-software-engineering-for-saas/#comments</comments>
		<pubDate>Sun, 20 May 2012 03:42:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/?p=3000</guid>
		<description><![CDATA[Day 2 of the UCB SaaS course is gone and I&#8217;ve scarcely looked at the coursework. From my brief review of Week 1, I see that there are 2.5 hours of video to watch, a couple of chapters to read in the text book, and some interesting assignments that I&#8217;m looking forward to. Overall, the [...]]]></description>
			<content:encoded><![CDATA[<p>Day 2 of the UCB SaaS course is gone and I&#8217;ve scarcely looked at the coursework. From my brief review of Week 1, I see that there are 2.5 hours of video to watch, a couple of chapters to read in <a title="SaaS Textbook" href="http://beta.saasbook.info/" target="_blank">the text book</a>, and some interesting assignments that I&#8217;m looking forward to. Overall, the course is top-notch, and the instructors are world class.</p>
<p>I&#8217;m feeling totally comfortable with the Rails and Ruby part of this course. What I&#8217;m having trouble with is Father Time himself. I&#8217;ve spent the last couple of day getting three finals together for my CCSF course. What made it more time-consuming (yet more rewarding) was that I got a wild idea to write an automated testing suite to evaluate the functionality of the insanely complex HTML forms I&#8217;m having my students create (and validate) as part of the Final. The test suite is done with <a title="Simpletest dot org" href="http://simpletest.org">SimpleTest</a>, the rather fabulous PHP Unit Testing library.</p>
<p>Check out the SaaS course here &#8212; <a href="https://www.coursera.org/course/saas">Software Engineering for SaaS | Coursera</a>. Maybe you can catch it the next time it comes around.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/3000/dear-diary-day-2-of-software-engineering-for-saas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Sad Day for Fans of ThinkPad Keyboards</title>
		<link>http://www.wisebison.com/2994/a-sad-day-for-fans-of-thinkpad-keyboards/</link>
		<comments>http://www.wisebison.com/2994/a-sad-day-for-fans-of-thinkpad-keyboards/#comments</comments>
		<pubDate>Fri, 18 May 2012 04:16:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/?p=2994</guid>
		<description><![CDATA[I always liked two things about IBM ThinkPad laptops: the little red TrackPoint pointer, and the great keyboards that IBM used. My T42p and X61 are both still alive and kicking and have the greatest keyboards I&#8217;ve every laid hands on. So, when I read this news today, I got a little bummed out. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I always liked two things about IBM ThinkPad laptops: the little red TrackPoint pointer, and the great keyboards that IBM used. My T42p and X61 are both still alive and kicking and have the greatest keyboards I&#8217;ve every laid hands on. So, when I read <a href="http://news.cnet.com/8301-1023_3-57435504-93/lenovo-dumps-classic-keyboard-on-new-thinkpad-laptops/">this news</a> today, I got a little bummed out. It&#8217;s sad the see a good thing go extinct.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2994/a-sad-day-for-fans-of-thinkpad-keyboards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m Taking This UC Berkeley SaaS Course</title>
		<link>http://www.wisebison.com/2949/u-c-berkeley-software-engineering-for-saas-coursera/</link>
		<comments>http://www.wisebison.com/2949/u-c-berkeley-software-engineering-for-saas-coursera/#comments</comments>
		<pubDate>Wed, 16 May 2012 22:17:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bleeding Edge]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SaaS Course]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/?p=2949</guid>
		<description><![CDATA[Software Engineering for SaaS &#124; Coursera. I&#8217;m enrolled in this UC Berkeley SaaS course. The cool thing is that some of my Ruby and PHP students will be in the course too. The course starts May 18, so you&#8217;d better get with it if you want to hang with us. I&#8217;ll post about my experiences [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://www.coursera.org/course/saas">Software Engineering for SaaS | Coursera</a>.</p>
<p>I&#8217;m enrolled in this UC Berkeley SaaS course. The cool thing is that some of my Ruby and PHP students will be in the course too. The course starts May 18, so you&#8217;d better get with it if you want to hang with us.</p>
<p>I&#8217;ll post about my experiences as I go along. This will be all new to me, and I&#8217;m looking forward learning the cool stuff that the cool kids are doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2949/u-c-berkeley-software-engineering-for-saas-coursera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yes, Virginia, There Is Such A Thing As A Stupid Question.</title>
		<link>http://www.wisebison.com/53/yes-virginia-there-is-such-a-thing-as-a-stupid-question/</link>
		<comments>http://www.wisebison.com/53/yes-virginia-there-is-such-a-thing-as-a-stupid-question/#comments</comments>
		<pubDate>Tue, 08 May 2012 13:29:00 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Nostalgia]]></category>
		<category><![CDATA[Original Gangster]]></category>
		<category><![CDATA[Shop Talk]]></category>

		<guid isPermaLink="false">http://hackingthevalley.com/2009/08/25/yes-virginia-there-is-such-a-thing-as-a-stupid-question/</guid>
		<description><![CDATA[In reading the Eric Raymond&#8217;s classic essay How To Ask Questions The Smart Way I found proof that, no matter how kind and gentle, now matter how considerate and co-operative we want to be, no matter how much we want to nurture participation and camaraderie, there really are stupid questions.]]></description>
			<content:encoded><![CDATA[<p>In reading the Eric Raymond&#8217;s classic essay <a href="http://catb.org/%7Eesr/faqs/smart-questions.html">How To Ask Questions The Smart Way</a> I found proof that, no matter how kind and gentle, now matter how considerate and co-operative we want to be, no matter how much we want to nurture participation and camaraderie, there really are stupid questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/53/yes-virginia-there-is-such-a-thing-as-a-stupid-question/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Singleton Design Pattern in PHP</title>
		<link>http://www.wisebison.com/89/the-singleton-design-pattern-in-php/</link>
		<comments>http://www.wisebison.com/89/the-singleton-design-pattern-in-php/#comments</comments>
		<pubDate>Fri, 04 May 2012 04:21:00 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[Nostalgia]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://hackingthevalley.com/2010/01/09/the-singleton-design-pattern-in-php/</guid>
		<description><![CDATA[The Singleton design pattern creates a class that can only have one instance. This is useful for tasks such as creating a globally available database connection for your script. The prototype for the singleton class, in PHP, goes like this: Singleton Pattern class ClassName {  static $instance = NULL; private function __construct() {} private function [...]]]></description>
			<content:encoded><![CDATA[<p>The Singleton design pattern creates a class that can only have one instance. This is useful for tasks such as creating a globally available database connection for your script.</p>
<p>The prototype for the singleton class, in PHP, goes like this:</p>
<h3 id="singleton-pattern">Singleton Pattern</h3>
<pre>class ClassName {
    static $instance = NULL;
    private function __construct() {}
    private function __clone() {}
    static function getInstance() {
        if(self::$instance === NULL) self::$instance = new ClassName();
        return self::$instance;
    }
}

$obj = ClassName::getInstance();</pre>
<h4>It&#8217;s All About Scope</h4>
<p>PHP variables have scope restrictions that prevent them from being visible in all parts of your program. We often need these variables inside classes and functions. One way to provide globally accessible variables is to pass them into classes or functions as parameters. This method makes it clear that the function of class method is dependent on an external variable or object. Here’s an example:</p>
<p><span id="more-89"></span></p>
<h3 id="option-1-pass-the-variable-as-a-parameter">Option #1: Pass the Variable As A Parameter</h3>
<p>Here’s an example of passing a database handle into a hypothetical function and into a class.</p>
<pre>function logger($info, $dbhandle);

class Logger {
    static $handle = NULL;
    static function logIt($info, $dbhandle) {
        self::$handle = $dbhandle;
    }
}</pre>
<p>When you have only a few parameters this tactic works fine, but if your functions have many parameters the result is unwieldy code. It is not uncommon to find programmers creating functions or methods that have <em>parameteritis</em>, with dozens of confusing parameters.</p>
<p>Fortunately, a singleton class provides a cleaner solution: it provides global availability of a single object—with the side-effect that the sole object cannot be modified. If we want to ensure that this class cannot be cloned or sub-classed, we will mark it as <em>final</em> and the <tt><em>construct()</em></tt> and <tt>clone()</tt> methods as <em>protected</em>.</p>
<h3 id="option-2-use-a-singleton-class">Option #2: Use a Singleton Class</h3>
<p>Here’s an example a properly formed singleton class that cannot be cloned or sub-classed, ensuring that there will only be one instance of this class.</p>
<pre>final class DbConnection {

    private static $handle = null;
    private static $instance = NULL;
    private static $db = 'default.db';

    // Deny new DbConnection();
    private function __construct($db = NULL) {} 

    // We deny cloning, as with:
    //
    $instance = DbConnection::connect();
    //
    $clone = $instance;
    private function __clone() {} 

    function connect() {
        if(is_null(self::$handle)) {
            if(defined('DEFAULT_DB') {
                 self::$db = DEFAULT_DB;
            }
            // Create the only possible instance of this class
            self::$handle = new SqliteDatabase(self::$db);
        }
        return self::$handle;
    }

    static function getInstance() {
        if(self::$instance === NULL) {
            self::$instance = new DbConnection();
        }
        return self::$instance;
    }
}</pre>
<p>This class encapsulates the entire process of creating the single instance and the database handle, and checks to see if a default database constant exists. We can use it this way:</p>
<pre>class Logger {
    // Notice that this, too, is a singleton pattern class.
    static private $logger = NULL;

    static function logIt($it) {
        $dbc = DbConnection::getInstance()-&gt;connect();
        if(self::$instance == NULL) {
            self::$instance = new Logger);
        }
    }
    private function __construct() {}
}</pre>
<h3 id="refactoring">Refactoring</h3>
<p>Since the sole function of the <tt>DbConnection</tt> class is to provide a database connection, we can simplify the code considerably by eliminating the getInstance() method:</p>
<pre>final class DbConnection {

    private static $handle = null;
    private static $db = 'default.db';

    // Deny new DbConnection();
    private function __construct($db = NULL) {} 

    // We deny cloning
    private function __clone() {} 

    function connect() {
        if(is_null(self::$handle)) {
            if(defined('DEFAULT_DB') {
                self::$db = DEFAULT_DB;
            }
            // Create the only possible instance of this class
            self::$handle = new SqliteDatabase(self::$db);
        }
        return self::$handle;
    }
}

class Logger {

    static private $logger = NULL;

    static function logIt($it) {
        $dbc = DbConnection::connect();
        if(self::$instance == NULL) {
            self::$instance = new Logger);
        }
    }

    // Your other methods go here

    private function __construct() {}
}</pre>
<p>Happy hacking…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/89/the-singleton-design-pattern-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hooray for the Average</title>
		<link>http://www.wisebison.com/2876/hooray-for-the-average/</link>
		<comments>http://www.wisebison.com/2876/hooray-for-the-average/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 03:03:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[Original Gangster]]></category>
		<category><![CDATA[average]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/?p=2876</guid>
		<description><![CDATA[Average Magazine In a world of curated blogs, where every life is golden and reeking of the sweet smell of success, Average Magazine is a winner. It&#8217;s an annual magazine, so get your copy now. 2013 is a long way away. A shiny magazine without the shine, Average celebrates ordinary moments &#038; the minutia our [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://averagemagazine.com">Average Magazine</a></p>
<p>
In a world of curated blogs, where every life is golden and reeking of the sweet smell of success, Average Magazine is a winner. It&#8217;s an annual magazine, so get your copy now. 2013 is a long way away.
</p>
<blockquote><p>
   A shiny magazine without the shine, Average celebrates ordinary moments &#038; the minutia our lives are based on, without pretension &#038; full of honesty. Articles include:</p>
<ul>
<li>Softpants: characteristics, occasions &#038; litmus tests</li>
<li>Sheet Cake: the building block of group celebration</li>
<li>Law &#038; Order: a one-week analysis of the franchise</li>
<li>The Wire Coat Hanger: one man&#8217;s quest to have his coat remained unwrinkled</li>
<li>The Word Count: one thousand, one hundred &#038; eighty words</li>
<li>Oblong Sandwiches: and the cities that claimed to have coined them</li>
<li>The Green Book: profoundly calm &#038; unhurried</li>
<li>Snails: the life of a pair of clip on earrings</li>
<li>People: and how they like their toast among other things</li>
<li>Trees That Look Like Giant Vegetables</li>
<li>Reflections on Regression Towards the Mean</li>
<li>Your Grandmother Taught You To Steal To Survive A Depression</li>
<li>You Are What You Eat: a photo essay examining the interior of refrigerators in homes across Texas</li>
<li>Sky Chart: paintings &#038; analysis of the sky over a three month period</li>
<li>On Swimming: a short story</li>
<li>Someone Named Joe: the first in a series of portraits</li>
<li>+ a crossword puzzle</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2876/hooray-for-the-average/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paranoid About Google Much?</title>
		<link>http://www.wisebison.com/2860/paranoid-about-google-much/</link>
		<comments>http://www.wisebison.com/2860/paranoid-about-google-much/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 18:33:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bleeding Edge]]></category>
		<category><![CDATA[Shop Talk]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/?p=2860</guid>
		<description><![CDATA[WHen I click on a link to the Google blog, NoScript shows me there are 15 scripts running. They&#8217;re all benign, right? Not evil, right?]]></description>
			<content:encoded><![CDATA[<p>WHen I click on a link to the <a title="Official Google Blog" href="http://googleblog.blogspot.ca/2012/04/introducing-google-drive-yes-really.html">Google blog</a>, <a title="NoScript Javascript/Java/flash blocker" href="http://noscript.net/">NoScript</a> shows me there are 15 scripts running. They&#8217;re all benign, right? Not evil, right?</p>
<div id="attachment_2865" class="wp-caption alignnone" style="width: 460px"><a href="http://www.wisebison.com/wp-content/uploads/2012/04/google_scripts1.png" rel="shadowbox[sbpost-2860];player=img;"><img class=" wp-image-2865 " title="NoScript warning page for Official Google Blog" src="http://www.wisebison.com/wp-content/uploads/2012/04/google_scripts1.png" alt="NoScript warning page for Official Google Blog" width="450px" /></a><p class="wp-caption-text">NoScript warning page for Official Google Blog</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2860/paranoid-about-google-much/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Coffee Shop at the End of the World</title>
		<link>http://www.wisebison.com/2767/the-coffee-shop-at-the-end-of-the-world/</link>
		<comments>http://www.wisebison.com/2767/the-coffee-shop-at-the-end-of-the-world/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 02:47:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2767</guid>
		<description><![CDATA[I&#8217;ve drunk a lot of coffee in a lot of Java joints and the best I&#8217;ve ever drunk was in a little dive out on the western edge of North America, Trouble Coffee Company, out on Judah Steet in San Francisco&#8217;s Sunset District, about 100 yards from the Pacific Ocean. If you&#8217;re ever in that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wisebison.com/wp-content/uploads/2012/04/trouble_coffee1.jpg" rel="shadowbox[sbpost-2767];player=img;"><img class=" wp-image-2819 alignleft"  title="trouble_coffee" src="http://www.wisebison.com/wp-content/uploads/2012/04/trouble_coffee1-300x300.jpg" alt="" width="100" height="100" /></a>I&#8217;ve drunk a lot of coffee in a lot of Java joints and the best I&#8217;ve ever drunk was in a little dive out on the western edge of North America, <a title="Trouble Coffee Company" href="http://troublecoffee.com/">Trouble Coffee Company</a>, out on Judah Steet in San Francisco&#8217;s Sunset District, about 100 yards from the Pacific Ocean. If you&#8217;re ever in that forlorn, fog-bound neighborhood, drop in and get a cappuccino. You won&#8217;t regret it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2767/the-coffee-shop-at-the-end-of-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Lights Go Out for Face-to-face PHP Classes at CCSF</title>
		<link>http://www.wisebison.com/2786/the-lights-go-out-for-face-to-face-php-classes-at-ccsf/</link>
		<comments>http://www.wisebison.com/2786/the-lights-go-out-for-face-to-face-php-classes-at-ccsf/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 07:23:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://www.wisebison.com/blog/?p=2786</guid>
		<description><![CDATA[For the first time in 10 years CCSF will not have a face-to-face PHP course on the class schedule. Budget cuts, coming in waves over the last three years, have forced cuts to thousands of courses and CCSF, and now my classroom PHP courses are going into mothballs. CCSF&#8217;s only PHP course will will an [...]]]></description>
			<content:encoded><![CDATA[<p>For the first time in 10 years CCSF will not have a face-to-face PHP course on the class schedule. Budget cuts, coming in waves over the last three years, have forced cuts to thousands of courses and CCSF, and now my classroom PHP courses are going into mothballs. CCSF&#8217;s only PHP course will will an entry level online course.</p>
<p>The plan is that face-to-face courses will be restored once the economy rebounds, but the reality is that online courses draw more enrollment, and F2F courses will become second class citizens.</p>
<p>The upside of all these changes is I&#8217;ve decided to make my college courses available on this web site beginning in June, 2012. As I edit this semester&#8217;s course work, I am simultaneously moving content to this web stie.. The first course will be Beginning PHP. Later I&#8217;ll add a beginning Python and Ruby courses.</p>
<p>My courses are designed for motivated students who want a beginner-friendly introduction to web development. Click <a href="http://feeds.feedburner.com/wisebison">here</a> to subscribe to updates.</p>
<p>Keep hacking&#8230;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2786/the-lights-go-out-for-face-to-face-php-classes-at-ccsf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx, Varnish, PHP5-FPM, and WordPress</title>
		<link>http://www.wisebison.com/2769/nginx-varnish-php5-fpm-and-wordpress/</link>
		<comments>http://www.wisebison.com/2769/nginx-varnish-php5-fpm-and-wordpress/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 06:58:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bleeding Edge]]></category>
		<category><![CDATA[Editorial]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2769</guid>
		<description><![CDATA[10 Million hits a day with WordPress using a $15 server Here are my results, as generated by my four-year old PC. My math tells me that localhost can handle about 406 million hits a day. Too bad it&#8217;s so difficult to monetize the computers stacked under my desk. Linux Mint LMDE, 2.66GHz Core 2 [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Nginx, Varnish, PHP5-FPM, and WordPress" href="http://www.ewanleith.com/blog/900/10-million-hits-a-day-with-wordpress-using-a-15-server">10 Million hits a day with WordPress using a $15 server</a> </p>
<p>Here are my results, as generated by my four-year old PC. My math tells me that <tt>localhost</tt> can handle about 406 million hits a day. Too bad it&#8217;s so difficult to monetize the computers stacked under my desk.</p>
<h4>Linux Mint LMDE, 2.66GHz Core 2 Duo, Nginx, Varnish, PHP5-FPM, etc.</h4>
<pre style="font-size:11px;overflow:wrap">% /usr/bin/ab -t 60  -c 100 http://localhost/2012/03/02/setting-up-two-portrait-monitors-with-linux/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Completed 50000 requests
Finished 50000 requests

Server Software:        nginx/1.1.0
Server Hostname:        localhost
Server Port:            80

Document Path:          /2012/03/02/setting-up-two-portrait-monitors-with-linux/
Document Length:        14171 bytes

Concurrency Level:      100
Time taken for tests:   10.606 seconds
Complete requests:      50000
Failed requests:        0
Write errors:           0
Total transferred:      728605005 bytes
HTML transferred:       708550000 bytes
Requests per second:    4714.15 [#/sec] (mean)
Time per request:       21.213 [ms] (mean)
Time per request:       0.212 [ms] (mean, across all concurrent requests)
Transfer rate:          67085.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0      16
Processing:     0   21   9.4     19     134
Waiting:        0   20   8.8     19     133
Total:          0   21   9.5     19     136

Percentage of the requests served within a certain time (ms)
  50%     19
  66%     22
  75%     24
  80%     25
  90%     31
  95%     38
  98%     45
  99%     53
 100%    136 (longest request)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2769/nginx-varnish-php5-fpm-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flying isn&#8217;t as easy as it looks</title>
		<link>http://www.wisebison.com/2756/flying-isnt-as-easy-as-it-looks/</link>
		<comments>http://www.wisebison.com/2756/flying-isnt-as-easy-as-it-looks/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 05:00:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2756</guid>
		<description><![CDATA[Man Successfully Flies With Custom-Built Bird Wings http://www.wired.com/ I had always imagined that flying would be fun, but this just looks like a lot of work, or a nicely produced hoax. UPDATE: Wired has changed &#8220;Successfully&#8221; to &#8220;Claimed&#8221;.]]></description>
			<content:encoded><![CDATA[<p><a title="Man successfully flies with custom-built bird wings" href="http://www.wired.com/wiredscience/2012/03/human-bird-wings/">Man Successfully Flies With Custom-Built Bird Wings</a> http://www.wired.com/</p>
<p>I had always imagined that flying would be fun, but this just looks like a lot of work, or a nicely produced hoax.</p>
<p>UPDATE: Wired has changed &#8220;Successfully&#8221; to &#8220;Claimed&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2756/flying-isnt-as-easy-as-it-looks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cal State Colleges On the Fritz</title>
		<link>http://www.wisebison.com/2754/cal-state-colleges-on-the-fritz/</link>
		<comments>http://www.wisebison.com/2754/cal-state-colleges-on-the-fritz/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 06:42:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2754</guid>
		<description><![CDATA[Cal State to Close Door on Spring 2013 Enrollment Jerry Brown is playing hardball now.]]></description>
			<content:encoded><![CDATA[<p><a title="Cal State to close door on spring 2013 enrollment" href="http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2012/03/19/BAPL1NN1KR.DTL&amp;tsp=1">Cal State to Close Door on Spring 2013 Enrollment</a></p>
<p>Jerry Brown is playing hardball now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2754/cal-state-colleges-on-the-fritz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now that Steve Jobs is gone, who will create your next insanely great gadget?</title>
		<link>http://www.wisebison.com/2737/now-that-steve-jobs-is-gone/</link>
		<comments>http://www.wisebison.com/2737/now-that-steve-jobs-is-gone/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 20:32:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2737</guid>
		<description><![CDATA[Frighteningly Ambitious Startup Ideas  &#8211; Paul Graham You&#8217;ll have to read the article to see why these ideas are so frightening &#8212; or you can just cast a cold eye on this list. Build a better search engine &#8212; replace the current ego-oriented Google with a hacker-type search engine that give real results, not &#8220;social&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Frighteningly Ambitious Startup Ideas" href="http://paulgraham.com/ambitious.html">Frighteningly Ambitious Startup Ideas</a>  &#8211; Paul Graham</p>
<p>You&#8217;ll have to read the article to see why these ideas are so frightening &#8212; or you can just cast a cold eye on this list.</p>
<ol>
<li>Build a better search engine &#8212; replace the current ego-oriented Google with a hacker-type search engine that give real results, not &#8220;social&#8221; results. Make it like the old Google.</li>
<li>Replace email with a new protocol that does not allow anyone to push <em>their</em> junk into <em>your</em> mindspace.</li>
<li>Replace universities with something better, then move on to community colleges, then to high schools.</li>
<li>Replace TV (cable) with Internet Delivery.</li>
<li>Be the next Steve Jobs &#8212; it could be you, since the next Steve Jobs will definitely not be working at Apple.</li>
<li>Bring back Moore&#8217;s Law. Forget about creating faster &#8212; and &#8220;better&#8221; &#8212; software, which is pretty much impossible, and get back to making better, faster hardware.</li>
<li>Create a way to do ongoing medical diagnosis.  (This is totally Star Trekky, Paul.)</li>
</ol>
<p>Paul, I&#8217;m with you on #4. I, too, use my iMac as my TV.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2737/now-that-steve-jobs-is-gone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You think you&#8217;re busy? Maybe so, but not as busy as Stephen Wolfram</title>
		<link>http://www.wisebison.com/2734/so-you-think-youre-busy-maybe-so-but-not-as-busy-as-stephen-wolfram/</link>
		<comments>http://www.wisebison.com/2734/so-you-think-youre-busy-maybe-so-but-not-as-busy-as-stephen-wolfram/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 09:03:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bleeding Edge]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2734</guid>
		<description><![CDATA[The Personal Analytics of My Life &#8212; Stephen Wolfram This guy is, after all, all about numbers.]]></description>
			<content:encoded><![CDATA[<p><a title="Stephen Wolfram The Pesonal Analytics of My Life" href="http://blog.stephenwolfram.com/2012/03/the-personal-analytics-of-my-life/">The Personal Analytics of My Life</a> &#8212; Stephen Wolfram</p>
<p>This guy is, after all, all about numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2734/so-you-think-youre-busy-maybe-so-but-not-as-busy-as-stephen-wolfram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pushing Back Against the Hotheads and Jerks</title>
		<link>http://www.wisebison.com/2712/pushing-back-against-the-hotheads/</link>
		<comments>http://www.wisebison.com/2712/pushing-back-against-the-hotheads/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 00:10:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bleeding Edge]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2712</guid>
		<description><![CDATA[Give it five minutes &#8212; Jason Fried, 37 Signals Jason Fried misses a chance to explain what you have to do when that hothead jerk/creep/troll is trying to stomp the life out of your fragile idea: you have to push back until they buzz off &#8212; or, like Jason Fried, see the light.]]></description>
			<content:encoded><![CDATA[<p><a href="http://37signals.com/svn/posts/3124-give-it-five-minutes" title="Give it five minutes -- Jason F.">Give it five minutes</a> &#8212; Jason Fried, 37 Signals</p>
<p>Jason Fried misses a chance to explain what you have to do when that hothead jerk/creep/troll is trying to stomp the life out of <em>your</em> fragile idea: you have to push back until they buzz off &#8212; or, like Jason Fried, see the light.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2712/pushing-back-against-the-hotheads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Dual Portrait Monitors with Linux</title>
		<link>http://www.wisebison.com/2690/setting-up-two-portrait-monitors-with-linux/</link>
		<comments>http://www.wisebison.com/2690/setting-up-two-portrait-monitors-with-linux/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 05:43:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2690</guid>
		<description><![CDATA[When I installed LMDE (Linux Mint Debian Edition) to build a development box to replace my 27-inch iMac (now pretending to be the family television), I wanted to set up my two 24-inch 1920&#215;1200 monitors side by side in portrait mode to get a nice tall workspace. I&#8217;ve mentioned before that I loathe HD monitors [...]]]></description>
			<content:encoded><![CDATA[<p>When I installed LMDE (Linux Mint Debian Edition) to build a development box to replace my 27-inch iMac (now pretending to be the family television), I wanted to set up my two 24-inch 1920&#215;1200 monitors side by side in portrait mode to get a nice tall workspace. I&#8217;ve mentioned before that I loathe HD monitors &#8212; they&#8217;re great for TV (wide), but dismal for coding (tall). </p>
<h2>HD Monitors Suck, Portrait Monitors Rock</h2>
<p>My solution to the monitor problem is to buy wide monitors that can operate in portrait mode. This setup works effortlessly with Windows 7 and OS X. You plug them in, go to the control panel, rotate both monitors, and click Apply, and it just works. You can have two portrait monitors with Linux, too, but the path to success is paved with unpleasantness and frustration &#8212; if you don&#8217;t know what you&#8217;re doing, and I didn&#8217;t know, until today.</p>
<h2>The Hardware</h2>
<p>My funky HP box (got it for cheap at Costco) has an older NVidia card (8400GS) with both DVI and HDMI outputs, and I thought, naively, that it would work out of the box with Linux Mint, as it does in Windows and with my iMac. Wrong!</p>
<h2>The Software &#8212; NVidia Proprietary Drivers</h2>
<p>Since I like to use Compiz (I&#8217;m a sucker for drop shadows and and 3-D effects), I installed the proprietary NVidia drivers. Getting that done took some serious searching, but I found the clues I needed on the Linux Mint forum. <a href="http://forums.linuxmint.com/viewtopic.php?f=141&#038;t=54836" title="Linux Mint Forums">Check it out here</a>.</p>
<h2>The Fabulous Shinobu&#8217;s Secrets</h2>
<p>After digging around I found a tutorial  on <a href="http://zuttobenkyou.wordpress.com/2009/10/04/linux-nvidia-xinerama-guide-rotating-just-one-monitor-in-a-dual-head-setup/" title="Shinobu's Secrets">Shinobu&#8217;s Secrets</a> that showed how to set up dual monitors. You might also want to check out Shinobu&#8217;s eclectic collection of Linux/Emacs/Vim/programming tutorials. </p>
<p>By following the NVidia tutorial I was able to get the two monitors working side by side. The next step was to rotate them into portrait mode.</p>
<div id="attachment_2695" class="wp-caption aligncenter" style="width: 610px"><a href="http://wisebison.com/wp-content/uploads/2012/03/xserver-settings.png" rel="shadowbox[sbpost-2690];player=img;"><img src="http://wisebison.com/wp-content/uploads/2012/03/xserver-settings.png" alt="" title="xserver-settings" width="100%" class="size-full wp-image-2695" /></a><p class="wp-caption-text">The NVidia Gui Settings App</p></div>
<h2>nvidia Settings</h2>
<p>Unfortunately, the Linux version of nvidia-settings is missing the rotation settings! So, back to foraging I went, and I found the <a href="http://linux.die.net/man/5/xorg.conf" title="xorg.conf documentation">xorg.conf documentation</a> where I saw the options for rotation: &#8220;normal&#8221;, &#8220;left&#8221;, &#8220;right&#8221;, and &#8220;inverted&#8221;. </p>
<p>After a little experimentation, I added this line to the xorg.conf Monitor section.</p>
<p><code>Option "Rotate" "Left"</code></p>
<div id="attachment_2699" class="wp-caption aligncenter" style="width: 610px"><a href="http://wisebison.com/wp-content/uploads/2012/03/twinview.jpg" rel="shadowbox[sbpost-2690];player=img;"><img src="http://wisebison.com/wp-content/uploads/2012/03/twinview.jpg" alt="Dual Monitors in Portrait Mode on Linux" title="Dual Monitors in Portrait Mode on Linux" width="600" height="752" class="size-full wp-image-2699" /></a><p class="wp-caption-text">Dual Monitors in Portrait Mode using Linx Mint Debian Edition, with Happy Hacking Professional 2 Keyboard.</p></div>
<h2 style="text-transform:none !important">The final xorg.conf</h2>
<pre>
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 280.13  (buildd@biber)  Sat Aug  6 10:45:52 UTC 2011

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "DELL U2412M"
    HorizSync       30.0 - 83.0
    VertRefresh     50.0 - 61.0
    Option         "DPMS"
    Option         "Rotate" "Left"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce 8400 GS"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP-1"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0, DFP-1: nvidia-auto-select +0+1200"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2690/setting-up-two-portrait-monitors-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Mint Debian Edition and the iMac TV</title>
		<link>http://www.wisebison.com/2622/linux-mint-and-the-imac-tv/</link>
		<comments>http://www.wisebison.com/2622/linux-mint-and-the-imac-tv/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 03:16:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2622</guid>
		<description><![CDATA[The Nerd News around WiseBison Manor is that the iMac is doing duty as the family TV. This started about two weeks ago. What happened is this&#8230; I&#8217;m catching up on four years of Breaking Bad. Since the fourth season hasn&#8217;t been released on DVD, I&#8217;m watching it using Amazon&#8217;s Digital (works fine). The iMac [...]]]></description>
			<content:encoded><![CDATA[<p>The Nerd News around WiseBison Manor is that the iMac is doing duty as the family TV. This started about two weeks ago. What happened is this&#8230;</p>
<p>I&#8217;m catching up on four years of <em>Breaking Bad</em>. Since the fourth season hasn&#8217;t been released on DVD, I&#8217;m watching it using Amazon&#8217;s Digital (works fine). The iMac has a decent-sized screen, though it is too glossy to do a great job. At least it&#8217;s connected to the Internet. So, I moved it into the living room where I can kick back in my Ikea Klackbo and watch Walter and Jesse&#8217;s adventures in the meth trade.</p>
<h2>Linux Mint</h2>
<p>To do my hacking, I pulled out my 5-year old PC and installed <a title="Linux Mint" href="http://www.linuxmint.com/">Linux Mint</a> on it. This is one sweet Linux distro.</p>
<h2>Successes</h2>
<ul>
<li>The desktop looks good. Guys, it really doesn&#8217;t suck, like <a href="http://wisebison.com/2010/06/23/my-dream-linux-desktop/">these Linux desktops</a>.</li>
<li>It&#8217;s Debian.</li>
<li>There&#8217;s no crappy Unity desktop (Ubuntu, big dumb mistake going with that!)</li>
<li>No crappy Gnome 3 (tried it, hated it!).</li>
<li>Apt-get works like a dream, as always.</li>
<li>The wifi works with my hardware. This can be a hassle with some distros (SuSE, I mean you).</li>
<li>The sound works. I can listen to my <a href="http://www.pmvibes.net/">Balearic Trance</a> just fine.</li>
<li>Installing all my work tools went off without a hitch: LAMP, Ruby, Python, Vim, etc all installed easily.</li>
</ul>
<h2>Inconveniences</h2>
<p>There are a couple tweaks I had to make.</p>
<ul>
<li>The default Debian kernel recognizes only one core of my super spiffy Core 2 Duo processor, so I had to install the PAE kernel. By the way, I had to look at the Debian documentation to get this one working.</li>
<li>I wanted the proprietary NVidia drivers, so I had to dig around to figure that out. This involves installing a kernel module. It worked just fine, though the portrait mode wasn&#8217;t working. I had to tweak the xorg.conf to handle the rotation. See below.</li>
</ul>
<h2>The Big Advantages</h2>
<p>The real advantage of Linux is that it&#8217;s a cinch to install the software I need. I need Ruby, PHP, Python, and all that other good GNU software. For editors I use Vim and&#8230; well, I use Vim.</p>
<p>Frankly, Linux running on a humble, and homely, HP box, with an awesome Happy Hacking Professional 2 keyboard (worth its weight in gold), and a 24&#8243; Dell monitor in portrait mode (can&#8217;t do that with any Apple monitor), is the low-friction OS for web development.</p>
<p>&nbsp;</p>
<hr />
<strong>xorg.conf tweak</strong></p>
<pre>
Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
    Option         "Rotate" "Left"
EndSection</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2622/linux-mint-and-the-imac-tv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heads Up</title>
		<link>http://www.wisebison.com/2610/heads-up/</link>
		<comments>http://www.wisebison.com/2610/heads-up/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 05:35:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2610</guid>
		<description><![CDATA[This site is in transition while I migrate my PHP and Ruby courses over from CCSF and CSM. Though the California Community Colleges are sinking (ever so slowly and painfully), I do have time to move my courses and ensure that they will be available to anyone who&#8217;s interested in getting into Web programming. Courses [...]]]></description>
			<content:encoded><![CDATA[<p>This site is in transition while I migrate my PHP and Ruby courses over from CCSF and CSM. Though the California Community Colleges are sinking (ever so slowly and painfully), I do have time to move my courses and ensure that they will be available to anyone who&#8217;s interested in getting into Web programming.</p>
<p><strong>Courses</strong><br />
My introductory PHP and Ruby courses will be available June 1, 2012. Eventually my Python and HTML5 courses will make it over. My college courses run for 18-weeks, but I will be rewriting my WiseBison courses to be self-paced, modular, month-long classes.</p>
<p>Besides putting my the courses here, I&#8217;ll have my blog, code tips, PDFs, free stuff, and reviews. If you&#8217;re  interested in updates while I&#8217;m getting set up, sign on to the <a href="http://feeds.feedburner.com/wisebison">RSS feed</a>.</p>
<p>Keep hacking&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2610/heads-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Relaunching Wisebison.com</title>
		<link>http://www.wisebison.com/2285/relaunching-wisebison-com/</link>
		<comments>http://www.wisebison.com/2285/relaunching-wisebison-com/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 06:48:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://wisebison.com/?p=2285</guid>
		<description><![CDATA[Welcome to WiseBison.com. This web site will be the home of my CCSF and CSM Ruby, Python, and HTML5 courses. The courses will cover the content of in my college classes, with the same reading, coding assignments, and quizzes. The courses will all be self-administered and self-paced. I will eventually create some short-term instructor-led (by [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to WiseBison.com. This web site will be the home of my CCSF and CSM Ruby, Python, and HTML5 courses. The courses will cover the content of in my college classes, with the same reading, coding assignments, and quizzes. The courses will all be self-administered and self-paced. I will eventually create some short-term instructor-led (by me) courses around these topics. The first courses will become available June 1, 2012.</p>
<p>This will also be my blog, replacing my HackingtheValley.com blog. Check back now and then to see what&#8217;s going on, or sign up for the <a href="http://wisebison.com/feed/">RSS feed</a> to stay up to date.</p>
<p>Keep hacking&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/2285/relaunching-wisebison-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Newlines Will Kill Your Linux Scripts</title>
		<link>http://www.wisebison.com/1782/windows-newlines-will-kill-your-linux-scripts/</link>
		<comments>http://www.wisebison.com/1782/windows-newlines-will-kill-your-linux-scripts/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 03:19:13 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nostalgia]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://hackingthevalley.com/?p=1782</guid>
		<description><![CDATA[Here&#8217;s a little something I give to my online Ruby and Python students every year. Sometimes you create Ruby or Python code looks perfect, yet it will not run when you upload it to the server. You will get mysterious error messages like this: Server error! The server encountered an internal error and was unable [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little something I give to my online Ruby and Python students every year.</p>
<p><span id="more-1782"></span></p>
<p>Sometimes you create Ruby or Python code looks perfect, yet it will not run when you upload it to the server. You will get mysterious error messages like this:</p>
<blockquote><p><strong>Server error!</strong></p>
<p>The server encountered an internal error and was unable to complete your request.</p>
<p>Error message:</p>
<p>Premature end of script headers: lab1.2.py</p></blockquote>
<p>So, you look at your script, and all you can see is absolute perfection, but it still won’t work, so you run it on the command line, like this:</p>
<pre>python3 lab1.2.py</pre>
<div>and it runs perfectly. But, when you run it like this:</div>
<pre>./lab1.2.py</pre>
<p>&#8230; it goes down in flames:</p>
<pre>unable to exec joesmith88/public_html/lab1.2.py: No such file or directory</pre>
<h4><a name="toc-Section--2"></a>What’s Going On?</h4>
<p>What’s going on is that you really do have a fatal error in your code, and it&#8217;s an error that you can’t see. In fact, it’s invisible. The error is that you have uploaded a file that you created on a Windows machine.</p>
<p>There’s nothing intrinsically wrong with Windows, but Windows editors often, by default, do something that breaks — fatally breaks — CGI scripts that run on a Unix server: they add Windows line endings to the end of every line.</p>
<h4><a name="toc-Subsection--1"></a>What Are Windows Line Endings?</h4>
<div>Windows uses two characters for line endings: a carriage return and a new line. We would write it in Python like this: &#8220;<tt>\r\n</tt>&#8220;.</div>
<h4><a name="toc-Subsection--2"></a>Unix Line Endings</h4>
<div>Unix uses one character for line endings: a new line, like this: &#8220;<tt>\n</tt>&#8220;.</div>
<h4><a name="toc-Subsection--3"></a>Why Do WIndows Line Endings Break CGI Scripts?</h4>
<div>Assume that you upload a file that contains the code below. I’ll make the line endings conspicuous by using &#8220;<tt>\r\n</tt>&#8221; to indicate them:</div>
<pre>#!/usr/local/bin/python3\r\n
print(’Content-type:text/html\n’)\r\n
print(’Hello, world’)\r\n</pre>
<div>The real problem is the shebang line.</div>
<pre>#!/usr/local/bin/python3\r\n</pre>
<p>Here’s how Linux sees that line. First, Linux doesn’t know about Windows line endings; the “<tt>\r</tt>” character is just another character, like an “a”, “b”, or “c”. The shell sees the shebang and looks for a program named <tt>/usr/local/bin/python3\r</tt>.</p>
<p>Since Linux the &#8220;<tt>\r</tt>&#8221; as just another character in the program’s name, it looks on the files system for a file named <tt>/usr/local/bin/python3\r</tt>. Of course, that file doesn’t exist, so you get a mysterious fatal error, the error caused by the invisible &#8220;<tt>\r</tt>&#8221; character.</p>
<h4><a name="toc-Section--3"></a>od (octal dump)</h4>
<p>Your can see all of the characters in your scripts by using the <tt>od</tt></p>
<p>program to dump all of the characters in your script.</p>
<p>Here’s an example that shows how to use it. This example dump comes from a script a student uploaded from a Windows machine. The &#8220;cr&#8221; and &#8220;nl&#8221; characters in the output represent the “\r\n” Windows line endings, and they appear at the end of every line of code. As we’ve already discussed, the “cr” will cause fatal errors when they are at the end of the shebang line. In a Unix CGI script, there should not be ANY <tt>cr</tt> characters unless you put them there intentionally.</p>
<pre>% od -a joesmith88/public_html/lab1.2.py
0000000   #   !   /   u   s   r   /   l   o   c   a   l   /   b   i   n
0000020   /   p   y   t   h   o   n   3  cr  nl   #  sp   N   a   m   e
0000040   :  sp   J   o   s   e   p   h  sp  sp   S   m   i   t   h  cr
0000060  nl   #  sp   F   i   l   e  sp   n   a   m   e   :  sp   l   a
0000100   b   1   .   2   .   p   y  cr  nl   #  sp   D   a   t   e   :
0000120  sp   J   u   n   e  sp   2   1   ,  sp   2   0   1   1  cr  nl
0000140  cr  nl   #  sp   *   *   *   *   *   *   *   *   *   *  sp   L
0000160   a   b  sp   1  sp   E   x   e   r   c   i   s   e  sp   1   .
0000200   2  sp   *   *   *   *   *   *   *   *   *   *  cr  nl  cr  nl
0000220   p   r   i   n   t   (   ’   C   o   n   t   e   n   t   -   t
0000240   y   p   e   :  sp   t   e   x   t   /   h   t   m   l   \   n
0000260   ’   )  cr  nl   p   r   i   n   t   (   ’   \   n   ’   )  cr
0000300  nl   p   r   i   n   t   (  sp   ’   *   ’  sp   *  sp   1   0
0000320  sp   +  sp   ’  sp   L   a   b  sp   E   x   e   r   c   i   s
0000340   e  sp   1   .   2  sp   ’  sp   +  sp   ’   *   ’  sp   *  sp
0000360   1   0  sp   )  cr  nl   p   r   i   n   t   (   ’   H   e   l
0000400   l   o   ,  sp   w   o   r   l   d   !   ’   )  cr  nl  cr  nl</pre>
<h4><a name="toc-Section--4"></a>The Solution</h4>
<p>The solution, fortunately, is really simple: tell your Windows or Mac editor (yes, even Mac editors misbehave), to stop using Windows-style line endings. Fix it right now. Dig into your editor’s configuration file and tell it to ALWAYS use Unix-style line endings. End of headache&#8230;</p>
<h4><a name="toc-Subsection--4"></a>FTP Causes Problems, Too</h4>
<p>Some FTP clients add a &#8220;<tt>\r\n</tt>&#8221; line ending by default. If you upload scripts that you know have Unix-style line endings, and they still fail, check them with od to see whether FTP has added Windows line endings. If so, configure your FTP client to behave properly.</p>
<p>Keep hacking&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisebison.com/1782/windows-newlines-will-kill-your-linux-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.544 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-19 23:36:04 -->
<!-- Compression = gzip -->
