<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Graham King</title>
	
	<link>http://www.darkcoding.net</link>
	<description>Solvitas perambulum</description>
	<lastBuildDate>Fri, 30 Jul 2010 19:57:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/darkcoding" /><feedburner:info uri="darkcoding" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Kathy Sierra: Give your users super-powers</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/qP5mu_YY5sM/</link>
		<comments>http://www.darkcoding.net/future-of-web-apps/kathy-sierra-give-your-users-super-powers/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 06:15:21 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Future of Web Apps]]></category>
		<category><![CDATA[kathy sierra]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=801</guid>
		<description><![CDATA[Kathy Sierra at the Business Of Software conference last autumn. Hour long talk, really worth watching (as the length of my notes will vouch).

Abstract: It&#8217;s not about you, not about your product, it&#8217;s about how awesome you make your users. If you sell digital cameras, make your users better photographers, through a better camera yes, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Kathy_Sierra">Kathy Sierra</a> at the <a href="http://businessofsoftware.blip.tv/">Business Of Software</a> conference last autumn. Hour long talk, really worth watching (as the length of my notes will vouch).</p>

<p><strong>Abstract:</strong> It&#8217;s not about you, not about your product, it&#8217;s about how awesome you make your users. <strong>If you sell digital cameras, make your users better photographers</strong>, through a better camera yes, but also teach them about exposure, light, etc.</p>

<p><embed src="http://blip.tv/play/hatvgc21fQI" type="application/x-shockwave-flash" width="480" height="350" allowscriptaccess="always" allowfullscreen="true"></embed><br />
<small>(If the embed is broken, see <a href="http://www.blip.tv/file/3346148">Kathy Sierra at Business of Software</a>)</small></p>

<p>Here are my notes:</p>

<h2>Make the user awesome.</h2>

<p>You want them to talk about the amazing thing they did (with your tool).</p>

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

<p>Your product is part of a higher purpose (digital cameras -> photography). Don&#8217;t talk about your product, instead blog / tweet / evangelize the higher purpose.</p>

<p>Make the user better. Teach.</p>

<p>Sense of belonging. Do people want to wear T-shirts with your logo? What does being your user SAY about your user? It shouldn&#8217;t say something bad, and it shouldn&#8217;t say nothing.</p>

<h2>Get them interested</h2>

<p>Trigger an emotional reaction (faces, sex, cute, fear, story) so people pay attention.</p>

<p>Talk in conversations, not formal language. Stories trump data.</p>

<p>Contrast your marketing material, with your user manual. Take care of people <em>after</em> they buy, so they stay excited.</p>

<h2>Give super-powers</h2>

<p>Instead of Word Of Mouth, which requires people <em>telling</em> other people, use Word Of Obvious, where they show other people what they did, or other people see it, it&#8217;s obvious that person is awesome now that they use your product.</p>

<p>Flip business advice: </p>

<ul>
<li>Exceptional customer service -> exceptional customers. </li>
<li>&#8216;From good to great&#8217; -> great customers.</li>
</ul>

<p>Make your customers into the perfect customers you wish you had.</p>

<p>What super-powers do you give your customers? Help them get really really good at something.</p>

<p><strong>Don&#8217;t build a better [x], build a better [user of x]</strong>.
Say: <em>We help [type of person] get better at [thing]</em>.</p>

<p>Wrong: What problem do you solve? What value to you add?<br />
Right: What does having the solution mean to our users? What bigger, cooler thing is enabled?</p>

<p>Make it a rule that with your product, <strong>the user must do something cool within [x] minutes</strong>. Make a document listing 10 awesome things they can do, quickly, with your product, and how.</p>

<p>Help users justify acquiring your product to others. They are already sold, help them sell others.</p>

<h2>Make good things easy / natural / obvious</h2>

<p>Motivate / Inspire users. Motivate users to do things they wish they already did.</p>

<p>Peter Bregman, harvard business.org, on <a href="http://blogs.hbr.org/bregman/2009/03/the-easiest-way-to.html">the easiest way to change behavior</a>: </p>

<p>Right things should be easiest, most natural. Make doing the wrong thing very difficult. Usability matters.</p>

<h2>Help your users practice</h2>

<p>Make your users smarter. Shrink the 10,000 hours they need to become experts. Give users patterns they can learn. Experts are better at identifying patterns in the problem domain (the thing you are making your users super-heros at). Make their practice fun.</p>

<p>After 1 or 2 years, experience is a poor predictor of performance / expertise. Was it 10 years, or 1 year repeated 10 times?</p>

<p>Offer exercises, games, contests, tutorials that support deliberate practice of the right things. The things that make people awesome.</p>

<p>Those exercises etc should use cognitive pleasures to keep users interested and practicing. Game designers have identified a bunch: </p>

<ul>
<li>Thrill</li>
<li>Discovery</li>
<li>Challenge</li>
<li>Self-expression</li>
<li>Social</li>
<li>Novelty</li>
<li>Sensory.  </li>
</ul>

<p>The more <a href="http://projects.ict.usc.edu/itw/gel/EricssonDeliberatePracticePR93.pdf">deliberate practice</a> [pdf] your users get, the better they get, so the more they enjoy using your product. And the more chance other people have of seeing them practice, so more Word Of Obvious.</p>

<h2>Talk with users at their angriest</h2>

<p>Add a &#8220;WTF?&#8221; button. </p>

<p>Help / FAQ are usually written for people who are intellectually curious, wanting to learn more. The &#8220;WTF?&#8221; button is for angry upset people who hate your product right now. Different feeling, different audience.</p>

<p>How you make users feel about themselves, drives how they feel about YOU.</p>

<p>If you want them to RTFM, make a better FM.</p>

<p>Where do you fit on their <a href="http://www.mcli.dist.maricopa.edu/smc/journey/ref/summary.html">Hero&#8217;s Journey</a> (also <a href="http://www.thewritersjourney.com/hero's_journey.htm">here</a> and <a href="http://en.wikipedia.org/wiki/Monomyth">full detail here</a>). What part do you play? Are you the helpful sidekick? The ogre guarding the bridge? Something else?</p>

<h2>Community management</h2>

<p>Model good behavior in your community. </p>

<p>Make a short document for moderators / active users telling them how to answer &#8216;dumb questions&#8217;, in a nice way. Provide alternative answers to guide them away from RTFM or &#8220;just google it&#8221;.</p>

<p>Encourage a culture of &#8220;there are no dumb answers&#8221;. Newbies are often the best people to answer other newbie&#8217;s questions, yet on most forums people don&#8217;t feel ready to answer until they are experts. Encourage early participation.</p>

<p>Don&#8217;t force inclusivity, don&#8217;t force your expert users to hang out and nurture the newbies. Hanging out with other experts is a lot more interesting. Give them a special space, where they can use jargon. <a href="http://www.djangoproject.com/">Django</a>, like many projects, has two mailing lists: django-users (beginners, normal folk), and django-developers (experts).</p>

<p>Evolution of awesome: </p>

<ol>
<li>Awesome product (features)</li>
<li>Awesome people talking about the product (expert / influencer testimonials)</li>
<li>User testimonials (&#8221;I love this company&#8221;)</li>
<li>User benefits (&#8221;Look at what I did&#8221;)</li>
<li><a href="http://www.youtube.com/watch?v=EmEPXXJ4sKw">I know Kung-Fu</a></li>
</ol>

<h2>Summary</h2>

<p>In the words of <a href="http://www.jwz.org/doc/groupware.html">Jamie Zawinski</a>:</p>

<blockquote>
  <p>So I said, narrow the focus. Your &#8220;use case&#8221; should be, there&#8217;s a 22 year old college student living in the dorms. How will this software get him laid?</p>
</blockquote>

<p><strong>Your job is to make people better. Your tool is software.</strong></p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/qP5mu_YY5sM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/future-of-web-apps/kathy-sierra-give-your-users-super-powers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/future-of-web-apps/kathy-sierra-give-your-users-super-powers/</feedburner:origLink></item>
		<item>
		<title>A quote from Richard Stallman</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/GUzzN0K1P7U/</link>
		<comments>http://www.darkcoding.net/ideas/a-quote-from-richard-stallman/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 21:06:53 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[rms]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=793</guid>
		<description><![CDATA[	I have done most of my work while anxious about whether I could do the job, and unsure that it would be enough to achieve the goal if I did.
But I tried anyway, because there was no one but me between the enemy and my city. Surprising myself, I have sometimes succeeded.


	From this article about [...]]]></description>
			<content:encoded><![CDATA[	<p><blockquote>I have done most of my work while anxious about whether I could do the job, and unsure that it would be enough to achieve the goal if I did.<br />
But I tried anyway, because there was no one but me between the enemy and my city. Surprising myself, I have sometimes succeeded.<br />
</blockquote></p>

	<p>From this <a href="http://www.h-online.com/open/features/GNU-HURD-Altered-visions-and-lost-promise-1030942.html">article about <span class="caps">GNU HURD</span></a>.</p>

 <img src="http://feeds.feedburner.com/~r/darkcoding/~4/GUzzN0K1P7U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/ideas/a-quote-from-richard-stallman/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/ideas/a-quote-from-richard-stallman/</feedburner:origLink></item>
		<item>
		<title>Notes from O’Reilly’s Website Optimization</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/v9W-u7iXHAA/</link>
		<comments>http://www.darkcoding.net/software/notes-from-oreillys-website-optimization/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 03:59:46 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[marketing]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=783</guid>
		<description><![CDATA[These are my notes from O&#8217;Reilly&#8217;s Website Optimization. It is a strange book, that will appeal to the one-renaissance-person web business: someone who optimizes Javascript for performance and tracks Google Ads conversion goals. You&#8217;re bound to find a useful chapter in here, but I doubt you will find more than one relevant to you. Here [...]]]></description>
			<content:encoded><![CDATA[<p>These are my notes from <a href="http://oreilly.com/catalog/9780596515089">O&#8217;Reilly&#8217;s Website Optimization</a>. It is a strange book, that will appeal to the one-renaissance-person web business: someone who optimizes Javascript for performance and tracks Google Ads conversion goals. You&#8217;re bound to find a useful chapter in here, but I doubt you will find more than one relevant to you. Here are my notes:</p>

<hr />

<h1>Website Optimization. Conversion Rate Optimization</h1>

<p>The art and science of persuading your site visitors to take actions that benefit you.</p>

<h2>Crediblity</h2>

<p>Site must appear credible: Often a gut reaction.<br />
<a href="http://www.uky.edu/~drlane/capstone/persuasion/sourcecred.htm">Source credibility theory</a>: Perceived expertise and trustworthiness.</p>

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

<ul>
<li>Professional web design</li>
<li>Intuitive navigation (good usability)</li>
<li>Clear unique selling point</li>
<li>Loads fast</li>
<li>Use &#8216;trigger words&#8217; that users are scanning for</li>
<li>Benefit-oriented content, that focuses on visitors needs and goals</li>
</ul>

<p>Reassure users with:</p>

<ul>
<li>privacy policy link</li>
<li>trust logos: Verisgn / Better Business Bureau / etc</li>
</ul>

<h2>Six psychological principles of persuasion, use them:</h2>

<ul>
<li>social proof: Testimonials of people like you. Popularity (best selling xyz).</li>
<li>reciprocity: Give first, initiate.</li>
<li>consistency / commitement: Foot-in-the-door</li>
<li>liking / similarity: develop user personas, speak their language</li>
<li>authority</li>
<li>scarcity: list how many products left, how long till sale is over</li>
</ul>

<p>These come from <a href="http://www.darkcoding.net/behaviour/influence-by-robert-cialdini/">Robert Cialdini&#8217;s Influence</a></p>

<h1>Media</h1>

<p>Brand is: Company name, logo, and tagline. Make them good.</p>

<p>Hero shot: Include one high quality prominent picture of your product, or of someone enjoying it. Put image on left and text on right for easier reading. Make it relevant. Make image clickable for larger view. Give it a strong caption &#8211; headlines and captions are most read part of page.</p>

<p>Interactivity increases conversions: Video, animation, live chat, something the user can interact with. Be subtle and tasteful.</p>

<h2>Personas:</h2>

<ul>
<li>Demographics: Age, gender, income, education</li>
<li>Psychographics: Personality type</li>
<li>Geographic: Local, national, international?</li>
<li>Customer pain points and goals: What is the problem they are trying to solve? What is the single most important factor to them?</li>
<li>Value proposition / unique selling points: Why you and not the competition?</li>
<li>Benefit hierarchy: What benefits / features of your product are important to the customer? Order them by importance.</li>
<li>Key frustrations and objections: What is their biggest frustration with companies in your industry and/or products like yours?</li>
<li>Buying criteria: What factors do they weight when making the buying decision?</li>
<li>Risk reversal: What risks are your customers taking when buying your product, and can you avoid those? 100% money back guarantee, free trial, free return shipping, etc.</li>
<li>Keyword phrases: How do your customers refer to your product, what words do they use to search for it?</li>
</ul>

<p>Unique Selling Proposition: &#8220;Oh I&#8217;ve heard of you, you&#8217;re the company that &#8230;&#8221;</p>

<h2>Write for the web:</h2>

<ul>
<li>Brief. Bold. Inject personality. </li>
<li>Active voice, start with a verb.</li>
<li>Front load with keywords, users scan the first one or two words of each title / link / bullet.</li>
<li>Think newspaper headline.</li>
<li>Use sub-headings.</li>
<li>Write for scanning: Half the words. One idea per paragraph. Bullet lists. Highlight keywords.</li>
</ul>

<p>Develop primary and secondary responses:</p>

<ol>
<li>Primary response is your main call to action, typically &#8216;Buy Now&#8217;.</li>
<li>Secondary response is something for people who are not quite ready to buy now. Don&#8217;t lose them. Instead get them to sign up for newsletter, or download a PDF brochure, etc.</li>
</ol>

<p>Show don&#8217;t tell. Encourage customer&#8217;s emotional mental imaging.</p>

<p>Links get highest clickthrough at 7 &#8211; 12 words.
Repeat keywords that brought users to your site (ad words) in the links.</p>

<p>Avoid jargon, hype, and wimpy could should may might. Be positive &#8211; this will <em>absolutely</em> happen as soon as they give their credit card number!</p>

<p>Always be closing: Actually ask them to buy. Ask them to perform the call to action.</p>

<h1>Metrics</h1>

<h2>Conversion metrics</h2>

<p>What are your objectives &#8211; what does a &#8216;conversion&#8217; mean?</p>

<ul>
<li>Sell product: Count completed orders, count additions to shopping basket.</li>
<li>Ad clicks: For ad-supported site.</li>
<li>Distribution / Downloads: PDF, software, etc.</li>
<li>Informational: Read a page, view a video.</li>
<li>Comments: A blog could make getting a user to comment a conversion.</li>
<li>Sign-ups: Joining the site. Registering for the newsletter or for a beta invite, etc.</li>
</ul>

<p>What to track, what to care about:</p>

<ul>
<li>Unique visitors.</li>
<li>Average time on site. Pages per visit. These measure how engaged the user was in your site.</li>
<li>Bounce rate: % of users who left within a short period of time, and without browsing to a different page on your site. High bounce rate pages need some work, or the campaign that lead them there incorrectly needs some work (wrong adwords being targetted for example)</li>
<li>Conversion rates: Whatever you define a conversion to be.</li>
<li>Entry points: Which pages do your users first land on? Also called &#8216;primary content consumption&#8217;.</li>
<li>Exit points: Where do users stop browsing and leave? If it&#8217;s the &#8216;payment complete&#8217; page, fine. If not, needs looking into.</li>
<li>ROI (return on investment) by keyword and campaign, an cost per conversion: Track your advertising spend&#8217;s effectivness.</li>
</ul>

<p>Business metrics you should be tracking anyway:</p>

<ul>
<li>Revenue per order</li>
<li>Profit per order</li>
</ul>

<h2>Performance metrics:</h2>

<ul>
<li>Number of HTTP requests</li>
<li>Total size of data needed to view page</li>
<li>Load times with empty cache and with full cache:
<ul><li>Server processing time</li>
<li>Start render &#8211; until then page is blank</li>
<li>Onload / document ready &#8211; JS starts</li>
<li>Fully loaded and executed.</li></ul></li>
</ul>

<p>Test in several browsers, as load times will vary.
Test from several worldwide locations.
<a href="http://www.webpagetest.org">webpagetest.org</a></p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/v9W-u7iXHAA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/notes-from-oreillys-website-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/notes-from-oreillys-website-optimization/</feedburner:origLink></item>
		<item>
		<title>You’d be happier without your television. Sell it on Craigslist.</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/pHFR5V7lSp0/</link>
		<comments>http://www.darkcoding.net/behaviour/youd-be-happier-without-your-television-sell-it-on-craigslist/#comments</comments>
		<pubDate>Sun, 23 May 2010 00:29:48 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[positive psychology]]></category>
		<category><![CDATA[seligman]]></category>
		<category><![CDATA[television]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=778</guid>
		<description><![CDATA[A quote by Martin Seligman, from his book Authentic Happiness.

In the nightly choice between reading a good book and watching a sitcom on television, we often [make the wrong choice] &#8211; although surveys show again and again that the average mood while watching sitcoms on television is mild depression.

]]></description>
			<content:encoded><![CDATA[<p>A quote by <a href="http://en.wikipedia.org/wiki/Martin_Seligman">Martin Seligman</a>, from his book <a href="http://www.amazon.com/gp/product/0743222989?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0743222989">Authentic Happiness</a>.</p>

<blockquote>In the nightly choice between reading a good book and watching a sitcom on television, we often [make the wrong choice] &#8211; although surveys show again and again that the average mood while watching sitcoms on television is mild depression.
</blockquote>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/pHFR5V7lSp0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/youd-be-happier-without-your-television-sell-it-on-craigslist/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/youd-be-happier-without-your-television-sell-it-on-craigslist/</feedburner:origLink></item>
		<item>
		<title>Scientific proof: You need to get rid of that TV</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/C7JFTNwkuPY/</link>
		<comments>http://www.darkcoding.net/behaviour/scientific-proof-you-need-to-get-rid-of-that-tv/#comments</comments>
		<pubDate>Thu, 13 May 2010 05:46:13 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[social psychology]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=768</guid>
		<description><![CDATA[Two observations found in the literature on social psychology, which explain succinctly why, whatever you personally think about it, you would be mentally much better off without your TV.

Mean World Syndrome

People who watch a lot of television believe the world is more violent and intimidating than it actually is.


  If you are growing up [...]]]></description>
			<content:encoded><![CDATA[<p>Two observations found in the literature on <strong>social psychology</strong>, which explain succinctly why, whatever you personally think about it, you would be mentally <strong>much better off without your TV</strong>.</p>

<h2>Mean World Syndrome</h2>

<p>People who watch a lot of television believe the world is more violent and intimidating than it actually is.</p>

<blockquote>
  <p>If you are growing up in a home where there is more than say three hours of television per day, for all practical purposes you live in a meaner world &#8211; and act accordingly &#8211; than your next-door neighbor who lives in the same world but watches less television.</p>
  
  <p>Our surveys tell us that the more television people watch, the more they are likely to be afraid to go out on the street in their own community, especially at night. They are afraid of strangers and meeting other people.</p>
  
  <p>George Gerbner</p>
</blockquote>

<ul>
<li><a href="http://www.context.org/ICLIB/IC38/Gerbner.htm">George Gerbner articles on Mean World Syndrome</a></li>
<li><a href="http://www.metafilter.com/91365/Mean-World-Syndrome">Mean World Syndrome at Metafilter</a></li>
<li><a href="http://en.wikipedia.org/wiki/Mean_World_Syndrome">Mean World Syndrome at Wikipedia</a></li>
</ul>

<h2>Third-person effect</h2>

<p>The belief that the mass media has a greater effect on others than it does on oneself. I like to call this the &#8220;adverts-don&#8217;t-affect-me&#8221; effect.</p>

<ul>
<li><a href="http://en.wikipedia.org/wiki/Third-person_effect">Third Person Effect at Wikipedia</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/C7JFTNwkuPY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/scientific-proof-you-need-to-get-rid-of-that-tv/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/scientific-proof-you-need-to-get-rid-of-that-tv/</feedburner:origLink></item>
		<item>
		<title>Television and your brain maps</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/6K4sGfpYD5w/</link>
		<comments>http://www.darkcoding.net/behaviour/television-and-your-brain-maps/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 19:03:13 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[brain]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[plasticity]]></category>
		<category><![CDATA[television]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=754</guid>
		<description><![CDATA[The Brain That Changes Itself, by Norman Doidge is a fascinating book about brain plasticity, the ability of our brain to re-wire itself to cope with changing conditions. In a chapter about culture&#8217;s influence on our brain maps, he says:


  Television watching, one of the signature activities of our culture, correlates with brain problems.


How [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0143113100?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0143113100">The Brain That Changes Itself</a>, by Norman Doidge is a fascinating book about brain plasticity, the ability of our brain to re-wire itself to cope with changing conditions. In a chapter about culture&#8217;s influence on our brain maps, he says:</p>

<blockquote>
  <p>Television watching, one of the signature activities of our culture, correlates with brain problems.</p>
</blockquote>

<p>How do we know this?</p>

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

<blockquote>
  <p>A recent study of more than 2,600 toddlers shows that early exposure to television between the ages of one and three correlates with problems paying attention and controlling impulses later in childhood.</p>
  
  <p><strong>For every hour of TV the toddlers watched each day, their chances of developing serious attentional difficulties at age seven increased by 10%</strong>.</p>
</blockquote>

<p>Surely this only applies to children? No. Most of the book is about the recent discoveries that adult brains are also plastic, and how that is being used to treat stroke, alzheimer&#8217;s, and brain injuries.</p>

<p>Or you might be tempted to think that this applies only to children&#8217;s programming, and to MTV. Not so. In the words of Marshall McLuhan, &#8220;The medium is the message&#8221;:</p>

<blockquote>
  <p>Most people think that the dangers created by the media are a result of content. [..] Erica Michael and Marcel Just of Carnegie Mellon University did a brain scan study to test whether the medium is indeed the message. They showed that different brain areas are involved in hearing speech and reading it,  and different comprehension centers in hearing words and reading them.</p>
  
  <p>The pragmatic implication is that the medium is part of the message. [..] each medium creates a different sensory and semantic experience &#8211; and, we might add, develops different circuits in the brain.</p>
</blockquote>

<p>Why and how does television alter your brain patterns?</p>

<blockquote>
  <p>It is the <em>form</em> of the television medium &#8211; cuts, edits, zooms, pans, and sudden noises &#8211; that alters the brain, by activating what Pavlov called the &#8220;orienting response&#8221;, which occurs whenever we sense a sudden change in the world around us, especially a sudden movement. We instinctively interrupt whatever we are doing to turn, pay attention, and get our bearings.</p>
</blockquote>

<p>The result?</p>

<blockquote>
  <p>The response is physiological: the heart rate decreases for 4 or 5 seconds.Television triggers this response at a far more rapid rate than we experience it in life, which is why we can&#8217;t keep our eyes off the TV screen, even in the middle of an intimate conversation, and why people watch TV a lot longer than they intend.</p>
  
  <p>Because typical music videos, action sequences, and commercials trigger orienting responses at a rate of one per second, watching them puts us into continuous orienting response with no recovery. </p>
  
  <p>No wonder people report feeling drained from watching TV. </p>
  
  <p>Yet we acquire a taste for it and find slower changes boring. The cost is that such activities such as reading, complex conversation, and listening to lectures becomes more difficult.</p>
</blockquote>

<p><a href="http://www.amazon.com/gp/product/0143113100?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0143113100">The Brain That Changes Itself</a> is a fascinating book that will change the way you think about your brain, and how you go about your daily activities.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/6K4sGfpYD5w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/television-and-your-brain-maps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/television-and-your-brain-maps/</feedburner:origLink></item>
		<item>
		<title>Open up your WiFi</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/ua80VAC4W9c/</link>
		<comments>http://www.darkcoding.net/software/open-up-your-wifi/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 00:28:27 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Society]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=748</guid>
		<description><![CDATA[A few months back, I took the password off my WiFi router, and opened it up to the world, with SSID yes_we_are_sharing. Why?

The best answers are given by security expert Bruce Shneier &#8211; why open wireless. The second best answer is that Tor hacker Jacob Applebaum also runs open WiFi.

Here are my answers, and the [...]]]></description>
			<content:encoded><![CDATA[<p>A few months back, I took the password off my WiFi router, and opened it up to the world, with SSID <code>yes_we_are_sharing</code>. Why?</p>

<p>The best answers are given by security expert <a href="http://www.schneier.com/blog/archives/2008/01/my_open_wireles.html">Bruce Shneier &#8211; why open wireless</a>. The second best answer is that <a href="http://en.wikipedia.org/wiki/Tor_%28anonymity_network%29">Tor</a> hacker <a href="http://en.wikipedia.org/wiki/Jacob_Appelbaum">Jacob Applebaum</a> also runs open WiFi.</p>

<p>Here are my answers, and the reasons why you should join us.</p>

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

<h2>What&#8217;s changed?</h2>

<p>The only difference between an encrypted wireless network and an open wireless network is that the part between your computer and the router is no longer encrypted by the router. Anyone can listen in, and anyone can connect to your router and access the big wide Internet.</p>

<p>The part between your computer and your router is only a tiny part of the journey your data takes between you and, say, your online bank. None of the part after the router has changed; if it was encrypted before, it still is, and if it wasn&#8217;t is still isn&#8217;t, and you should fix that. Read one for how.</p>

<h2>Reason: It&#8217;s nice</h2>

<p>Have you ever used anyone else&#8217;s open router? Maybe one named &#8216;dlink&#8217;, &#8216;linksys&#8217;, or a Mac AirPort? I bet you were happy that was there for you. When you move into a new home, when you have problems with your connection, or simply when you&#8217;re out and about, it&#8217;s great to have a free network. Opening up my network is my small way of giving back.</p>

<h2>Myth: Bad people in your front garden</h2>

<p>The first question most people ask about open wifi is this: What if someone uses my connection to do something bad?</p>

<p>To use your connection, they would have to be a direct neighbour of yours, or sitting outside your house. </p>

<p>Isn&#8217;t it more likely they would go that extra block to the warm and dry coffee shop?</p>

<p>Do you hear of coffee shop owners going to jail much? What about the &#8216;dlink&#8217; and &#8216;linksys&#8217; people? &#8220;Bad People&#8221; typically have their own Internet connection.</p>

<h2>Real Risk: Eavesdropping</h2>

<p>You might be worried that other people will steal your secrets. Again, they&#8217;d have to be sitting in your front garden. </p>

<p>There&#8217;s a much better place to steal people&#8217;s online banking data, than your front garden: in a coffee shop, at a conference, or, best of all, in an airport. </p>

<h2>Reason: It makes you safer</h2>

<p>You should setup your machine so that <em>all</em> your connections are encrypted, wherever you are. Opening your home wireless gives you that extra discipline.</p>

<ul>
<li><p>Secure your web browsing. When doing anything senstive, make sure you are using the &#8216;https&#8217; protocol (your browser will be showing a padlock).</p></li>
<li><p>Secure your email. If using webmail, make sure it&#8217;s over https. GMail, to Google&#8217;s great credit, has that as the default. If you are using regular email, makes sure you use the encrypted protocol &#8211; IMAPS or POPS.</p></li>
<li><p>Secure you IM conversations. <a href="http://en.wikipedia.org/wiki/Google_Talk#Encryption">Google Talk is encrypted</a> if your client supports it (<a href="http://www.pidgin.im/">Pidgin</a> does). <a href="http://forum.skype.com/index.php?showtopic=18543">Skype is encrypted</a>. As far as I could tell, Yahoo Messenger isn&#8217;t, so avoid it.</p></li>
</ul>

<h2>Weak Risk: Your neighbourhood hacker</h2>

<p>If you&#8217;re using Windows, you should be running a personal firewall on your machine. I believe there is now one built-in to Windows. Make sure it is switched on.</p>

<h2>Administration</h2>

<p>Most computers will auto-connect to any available wireless network when they start up. If you notice the same machines on your network every day for a while, they are probably auto-connecting. You&#8217;ll need to add rules to your router to ban their MAC address, shunting them back to their own router.</p>

<p>The point of open wireless isn&#8217;t to make your neighbours Internet connection redundant, but to temporarily help people out. Your neighbours don&#8217;t want to use your connection, as their is typically faster for them (they are closer to their router).</p>

<p>Happy sharing!</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/ua80VAC4W9c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/open-up-your-wifi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/open-up-your-wifi/</feedburner:origLink></item>
		<item>
		<title>Setting up Monit on Ubuntu</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/bLpMaVwkNcU/</link>
		<comments>http://www.darkcoding.net/software/setting-up-monit-on-ubuntu/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 23:18:23 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[monit]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=737</guid>
		<description><![CDATA[Monit tells you if something goes wrong on your server, and tries to fix it. It can, for example, alert you:


When a process dies.
When a machine stops responding to network requests
When your machine has too high load average, memory consumption, or CPU usage.
When a file changes, hasn&#8217;t changed for a period of time, or grows [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mmonit.com/monit/">Monit</a> tells you if something goes wrong on your server, and tries to fix it. It can, for example, alert you:</p>

<ul>
<li>When a process dies.</li>
<li>When a machine stops responding to network requests</li>
<li>When your machine has too high load average, memory consumption, or CPU usage.</li>
<li>When a file changes, hasn&#8217;t changed for a period of time, or grows beyond a certain size.</li>
</ul>

<p>It can run a script of your choosing to attempt to fix the problem. It has an <a href="http://mmonit.com/monit/screenshots/monit.html">HTTP interface</a> that shows you essential stats about the services you are monitoring. For detailed graphs, I recommend <a href="http://www.darkcoding.net/software/setting-up-munin-on-ubuntu/">Munin</a>.</p>

<p>Here&#8217;s how to get it working on Ubuntu:</p>

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

<h2>Editing the config file</h2>

<div class="quickcodenoclick"><code><br />
sudo apt-get install monit<br />
sudo vim /etc/default/monit<br />
</code></div>

<p>Edit the single line to <code>startup=1</code>. </p>

<p>The config file that comes with monit is well commented, but just in case here&#8217;s the breakdown.</p>

<div class="quickcodenoclick"><code><br />
sudo vim /etc/monit/monitrc<br />
</code></div>

<p>Set Monit to check services every two minutes (120 seconds), and log to <code>/var/log/daemon.log</code></p>

<div class="quickcodenoclick"><code><br />
set daemon 120<br />
set logfile syslog facility log_daemon<br />
</code></div>

<p>Setup email alerts:</p>

<div class="quickcodenoclick"><code><br />
set mailserver localhost<br />
set mail-format { from: monit@myserver.domain.com }<br />
set alert sysadmin@domain.com<br />
</code></div>

<p>Switch on the HTTP interface, allow access from anywhere, and require a username and password. Make it a decent password, because the HTTP interface allows you to stop and start services.</p>

<div class="quickcodenoclick"><code><br />
set httpd port 2812&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;use address myserver.domain.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;allow 0.0.0.0/0.0.0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;allow myusername:mypassword<br />
</code></div>

<p>Monitor the machine itself:</p>

<div class="quickcodenoclick"><code><br />
check system myserver.domain.com<br />
&nbsp;&nbsp;&nbsp;&nbsp;if loadavg (1min) &gt; 4 then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if loadavg (5min) &gt; 3 then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if memory usage &gt; 75% then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if cpu usage (user) &gt; 70% then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if cpu usage (system) &gt; 30% then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if cpu usage (wait) &gt; 20% then alert<br />
</code></div>

<p>Then monitor all the services running on that box.</p>

<p>If you monitor the <code>totalcpu</code> resource, note that is a percentage of <em>all</em> CPUs. On a 4 CPU machine, 25% represents a process consuming 100% of one CPU.</p>

<p>For the Apache monitor, the PID file is defined in <code>/etc/apache2/envvars</code>, and is usually <code>/var/run/apache2.pid</code>.</p>

<p>Here are the service monitoring lines from my config:</p>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode7377');">Quick Code</a></p></p>

<div id="quickcode7377" class="quickcode"><code><br />
check process apache with pidfile /var/run/apache2.pid<br />
&nbsp;&nbsp;&nbsp;&nbsp;start program = &quot;/etc/init.d/apache2 start&quot; with timeout 20 seconds<br />
&nbsp;&nbsp;&nbsp;&nbsp;stop program&nbsp;&nbsp;= &quot;/etc/init.d/apache2 stop&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;if totalcpu &gt; 20% for 2 cycles then alert<br />
&nbsp;&nbsp;&nbsp;&nbsp;if totalcpu &gt; 20% for 5 cycles then restart<br />
&nbsp;<br />
check process nginx with pidfile /var/run/nginx.pid<br />
&nbsp;&nbsp;&nbsp;&nbsp;start program = &quot;/etc/init.d/nginx start&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;stop program = &quot;/etc/init.d/nginx stop&quot;<br />
&nbsp;<br />
check process gearmand with pidfile /var/run/gearman/gearmand.pid<br />
&nbsp;&nbsp;&nbsp;&nbsp;start program = &quot;/etc/init.d/gearman-job-server start&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;stop program = &quot;/etc/init.d/gearman-job-server stop&quot;<br />
&nbsp;<br />
check process memcached with pidfile /var/run/memcached.pid<br />
&nbsp;&nbsp;&nbsp;&nbsp;start program = &quot;/etc/init.d/memcached start&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;stop program = &quot;/etc/init.d/memcached stop&quot;<br />
&nbsp;<br />
check process mysqld with pidfile /var/run/mysqld/mysqld.pid<br />
&nbsp;&nbsp;&nbsp;&nbsp;start program = &quot;/etc/init.d/mysql start&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;stop program = &quot;/etc/init.d/mysql stop&quot;<br />
</code></div>

<p>Start monit, and query it:</p>

<div class="quickcodenoclick"><code><br />
sudo /etc/init.d/monit start<br />
sudo monit status<br />
</code></div>

<p>You need the HTTP interface to use the &#8217;status&#8217; command.</p>

<h2>Monitoring MySQL replication</h2>

<p>To monit MySQL replication, create a script to touch a file if replication is still running. Put that script in cron. Get monit to check that file. </p>

<p>The idea comes from <a href="http://www.elevatedrails.com/articles/2007/12/05/replication-monitoring-with-monit/">replication monitoring with monit</a>, where they use Ruby. </p>

<p>I ported the script to Python, as a Django management command.</p>

<p>The crontab:</p>

<div class="quickcodenoclick"><code><br />
# m h&nbsp;&nbsp;dom mon dow&nbsp;&nbsp; command<br />
* * * * * /usr/local/myproject/mysql-watchdog-cron.sh<br />
</code></div>

<p>The shell script:</p>

<div class="quickcodenoclick"><code><br />
#!/bin/bash<br />
cd /usr/local/myproject<br />
/usr/bin/python manage.py mysql_replication_monit &gt;&gt; /dev/null 2&gt;&amp;1<br />
</code></div>

<p>The Django command:</p>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode73711');">Quick Code</a></p></p>

<div id="quickcode73711" class="quickcode"><code><br />
import os<br />
import logging<br />
&nbsp;<br />
from django.core.management.base import NoArgsCommand<br />
from django.db import connection<br />
&nbsp;<br />
WATCH = &#039;/usr/local/myproject/mysql_monit_watchdog&#039;<br />
&nbsp;<br />
def mysql_fetch_one_dict(cursor):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&quot;Like DB-API&#039;s fetch_one but returns a dict instead of a tuple&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;data = cursor.fetchone()<br />
&nbsp;&nbsp;&nbsp;&nbsp;if not data:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return None<br />
&nbsp;&nbsp;&nbsp;&nbsp;desc = cursor.description<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;dict = {}<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;for (name, value) in zip(desc, data):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dict[name[0]] = value<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return dict<br />
&nbsp;<br />
class Command(NoArgsCommand):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#039;Touch a file if MySQL replication is running&#039;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;help = &#039;Touch a file if MySQL replication is running. Call from cron. Monit checks that file&#039;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;def handle_noargs(self, **options):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;Called by NoArgsCommand&#039;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor = connection.cursor()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor.execute(&#039;SHOW SLAVE STATUS&#039;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row = mysql_fetch_one_dict(cursor)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if row[&#039;Slave_IO_Running&#039;] == &#039;Yes&#039; and row[&#039;Slave_SQL_Running&#039;] == &#039;Yes&#039;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with file(WATCH, &#039;a&#039;):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;os.utime(WATCH, None)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logging.error(&#039;*ERROR*: Slave IO not running&#039;)<br />
</code></div>

<p>Add these lines to /etc/monit/monitrc:</p>

<div class="quickcodenoclick"><code><br />
check file mysql_replication with path /usr/local/myproject/mysql_monit_watchdog&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;if timestamp &gt; 3 minutes then alert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</code></div>

<p>Happy monitoring!</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/bLpMaVwkNcU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/setting-up-monit-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/setting-up-monit-on-ubuntu/</feedburner:origLink></item>
		<item>
		<title>Setting up Munin on Ubuntu</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/nGQ6nvSULdw/</link>
		<comments>http://www.darkcoding.net/software/setting-up-munin-on-ubuntu/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 05:50:14 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[munin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=723</guid>
		<description><![CDATA[Munin is a system monitoring tool. It produces graphs for Apache, MySQL, Nginx, CPU, Memory, Disk, etc. Example munin installation &#8211; Live.

Here are my notes from setting it up, they are brief, but should help you get going.

All the monitored machines run a small daemon called munin-node. One machine is the  central server. Every [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://munin.projects.linpro.no/">Munin</a> is a system monitoring tool. It produces graphs for Apache, MySQL, Nginx, CPU, Memory, Disk, etc. <a href="http://munin.ping.uio.no/ping.uio.no/knuth.ping.uio.no.html">Example munin installation &#8211; Live</a>.</p>

<p>Here are my notes from setting it up, they are brief, but should help you get going.</p>

<p>All the monitored machines run a small daemon called <code>munin-node</code>. One machine is the  central server. Every few minutes it gathers data from all the nodes (including itself), generates the graphs, and writes out some HTML files.</p>

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

<p>In my case I have a proxy running <a href="http://wiki.nginx.org/Main">Nginx</a> and acting as the Munin central server, and two nodes each with <a href="http://en.wikipedia.org/wiki/Apache_HTTP_Server">Apache</a> and <a href="http://en.wikipedia.org/wiki/MySQL">MySQL</a>.</p>

<p>Everything that Munin monitors is in a separate plugin. Most of the ones you&#8217;ll need are bundled, but might need switching on.</p>

<p>If you only have one machine, that is your only node. Do both steps on that machine.</p>

<h2>On each node</h2>

<div class="quickcodenoclick"><code><br />
sudo apt-get install munin-node munin-plugins-extra<br />
</code></div>

<p>Edit <code>/etc/munin/munin-node.conf</code> and add these lines:</p>

<div class="quickcodenoclick"><code><br />
host_name mynode.mydomain.com&nbsp;&nbsp;# Hostname of the node machine<br />
allow 192.168.122.201&nbsp;&nbsp; # IP address of the central server<br />
host 192.168.122.203&nbsp;&nbsp;&nbsp;&nbsp;# Host IP address<br />
</code></div>

<p>If your Apache is not on port 80, edit the plugin config file <code>/etc/munin/plugin-conf.d/munin-node</code> and change or add these lines:</p>

<div class="quickcodenoclick"><code><br />
[apache_*]<br />
env.url&nbsp;&nbsp; http://127.0.0.1:%d/server-status?auto<br />
env.ports 81<br />
</code></div>

<p>Link the Apache plugin (it may already be linked, no problem)</p>

<div class="quickcodenoclick"><code><br />
cd /etc/munin/plugins/<br />
sudo ln -s /usr/share/munin/plugins/apache_processes apache_processes<br />
</code></div>

<p>Switch on Apache ExtendedStatus</p>

<div class="quickcodenoclick"><code><br />
sudo vi /etc/apache2/mods-available/status.conf<br />
</code></div>

<p>Outside of the <code>Location</code> section, add <code>ExtendedStatus On</code>
<a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode7236');">Quick Code</a></p></p>

<div id="quickcode7236" class="quickcode"><code><br />
&lt;IfModule mod_status.c&gt;<br />
&nbsp;<br />
ExtendedStatus On<br />
&lt;Location /server-status&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;SetHandler server-status<br />
&nbsp;&nbsp;&nbsp;&nbsp;Order deny,allow<br />
&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br />
&nbsp;&nbsp;&nbsp;&nbsp;Allow from localhost ip6-localhost<br />
&lt;/Location&gt;<br />
&nbsp;<br />
&lt;/IfModule&gt;<br />
</code></div>

<p>Install the Perl www packages (the Munin Apache plug needs them):</p>

<div class="quickcodenoclick"><code><br />
sudo apt-get install libwww-perl<br />
</code></div>

<p>Bounce munin-node and apache</p>

<div class="quickcodenoclick"><code><br />
sudo /etc/init.d/munin-node restart<br />
sudo /etc/init.d/apache2 reload<br />
</code></div>

<h2>On the central server</h2>

<div class="quickcodenoclick"><code><br />
sudo apt-get install munin munin-node munin-plugins-extra<br />
</code></div>

<p>Setup a crontab to run the data gathering task every five minutes</p>

<div class="quickcodenoclick"><code><br />
sudo -u munin crontab -e<br />
</code></div>

<p>Add this line</p>

<div class="quickcodenoclick"><code><br />
*/5 * * * *&nbsp;&nbsp;&nbsp;&nbsp; /usr/bin/munin-cron<br />
</code></div>

<p>Edit <code>/etc/munin/munin.conf</code> and set the nodes you want to gather data from, and their IP addresses.</p>

<div class="quickcodenoclick"><code><br />
[central.mydomain.com]<br />
&nbsp;&nbsp;&nbsp;&nbsp;address 127.0.0.1<br />
&nbsp;&nbsp;&nbsp;&nbsp;use_node_name yes<br />
&nbsp;<br />
[node1.mydomain.com]<br />
&nbsp;&nbsp;&nbsp;&nbsp;address 192.168.122.203<br />
&nbsp;&nbsp;&nbsp;&nbsp;use_node_name yes<br />
&nbsp;<br />
[node2.mydomain.com]<br />
&nbsp;&nbsp;&nbsp;&nbsp;address 192.168.122.202<br />
&nbsp;&nbsp;&nbsp;&nbsp;use_node_name yes<br />
</code></div>

<p>Run it!</p>

<div class="quickcodenoclick"><code><br />
sudo -u munin munin-cron<br />
</code></div>

<p>Look in <code>/var/www/</code>. You should see a <code>munin</code> directory.</p>

<p>Setup your web server to point to the HTML files. If like me you&#8217;re using Nginx, edit <code>/etc/nginx/sites-available/mydomain.com</code>, and add these lines</p>

<div class="quickcodenoclick"><code><br />
location /munin/ {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root /var/www/;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expires off;<br />
&nbsp;&nbsp;auth_basic &quot;Munin&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_basic_user_file /etc/nginx/.htpasswd;<br />
&nbsp;&nbsp;&nbsp;&nbsp; }<br />
</code></div>

<p>Create the htpasswd file, or see <a href="http://snippets.aktagon.com/snippets/109-Password-protecting-a-folder-resource-with-Nginx">password protecting a folder with Nginx</a>.</p>

<div class="quickcodenoclick"><code><br />
htpasswd -c /etc/nginx/.htpasswd username<br />
</code></div>

<p>Try it out, by browsing to http://myserver.com/munin. <em>myserver.com</em> is of course the address your Nginx is serving.</p>

<p>You should see some graphs, but they will be blank, or display Nan instead of numbers. Be patient. In 10 &#8211; 15 minutes Nan will be replaced by numbers, and the graphs will slowly start appearing.</p>

<h2>Add nginx monitoring</h2>

<p>A bit of fancy footwork required here. This might of improved by the time you read this.</p>

<div class="quickcodenoclick"><code><br />
sudo apt-get install libwww-perl<br />
</code></div>

<p>Download Munin plugins <a href="http://munin.projects.linpro.no/browser/trunk/plugins/node.d/nginx_request.in?rev=2167">nginx request</a> and <a href="http://munin.projects.linpro.no/browser/trunk/plugins/node.d/nginx_status.in?rev=2167">nginx status</a>.</p>

<p>Replace the very first line of each one, the one that says <code>@@PERL@@</code> with this line</p>

<div class="quickcodenoclick"><code><br />
#!/usr/bin/perl -w<br />
</code></div>

<p>Comment out the rest of the header. Open the file in vim, hit Esc, and type</p>

<div class="quickcodenoclick"><code><br />
:3,56s/^/#/&nbsp;&nbsp;&lt;Enter&gt;<br />
:wq &lt;Enter&gt;<br />
</code></div>

<p><em>Note: I&#8217;m obviously missing an install step here. If you know, please help me in the comments</em></p>

<p>Copy the plugins into munin&#8217;s available plugins directory</p>

<div class="quickcodenoclick"><code><br />
cp nginx_request /usr/share/munin/plugins<br />
cp nginx_status /usr/share/munin/plugins<br />
sudo chmod ug+x /usr/share/munin/plugins/nginx_*<br />
</code></div>

<p>Edit your nginx config to switch on status. Edit <code>/etc/nginx/sites-available/mydomain.com</code> and add these lines:</p>

<div class="quickcodenoclick"><code><br />
location /nginx_status {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stub_status on;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;access_log&nbsp;&nbsp; off;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#allow 127.0.0.1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#deny all;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allow all;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</code></div>

<p>Restart nginx: <code>sudo /etc/init.d/nginx restart</code></p>

<p>Link the plugins into the active plugins directory</p>

<div class="quickcodenoclick"><code><br />
cd /etc/munin/plugins/<br />
perl nginx_request autoconf<br />
&nbsp;<br />
sudo ln -s /usr/share/munin/plugins/nginx_request nginx_request<br />
sudo ln -s /usr/share/munin/plugins/nginx_status nginx_status<br />
</code></div>

<p>And you should be set. Happy monitoring!</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/nGQ6nvSULdw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/setting-up-munin-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/setting-up-munin-on-ubuntu/</feedburner:origLink></item>
		<item>
		<title>Restarting MySQL master-master replication</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/gR_TfsoxXQU/</link>
		<comments>http://www.darkcoding.net/software/restarting-mysql-master-master-replication/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 20:24:13 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=699</guid>
		<description><![CDATA[If your MySQL (5.0+) replication is broken, there&#8217;s two ways to fix it: The easy way, and the right way.

Run commands starting with $ on Unix. Run commands starting with mysql> in the MySQL client.

The easy way: Skip the problem

If you hit both databases at the same time, with the same INSERT, they will create [...]]]></description>
			<content:encoded><![CDATA[<p>If your MySQL (5.0+) replication is broken, there&#8217;s two ways to fix it: The easy way, and the right way.</p>

<p><em>Run commands starting with <strong>$</strong> on Unix. Run commands starting with <strong>mysql></strong> in the MySQL client.</em></p>

<h2>The easy way: Skip the problem</h2>

<p>If you hit both databases at the same time, with the same INSERT, they will create their own record, and try and replicate to the other, which already has that record, causing a duplicate error. </p>

<p>In a simple case like that, you just want to skip the offending statement:</p>

<div class="quickcodenoclick"><code><br />
mysql&gt;SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;<br />
</code></div>

<p>More details on <a href="http://www.ducea.com/2008/02/13/mysql-skip-duplicate-replication-errors/">skipping MySQL duplicate errors</a></p>

<p>Most of the time, you skip one statement, and replication breaks again straight away, because there&#8217;s a whole queue of problem statements coming up. </p>

<h2>The right way: Rebuild</h2>

<p>If you are not sure that you can skip the duplicate, or if replication has been broken long enough that your two servers are out of synch, pick one database to be the master, and rebuild the other from a copy of that master.</p>

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

<p>First make sure your site is only using the master server. Stop any processes that might modify data on the server you need to rebuild.</p>

<p>We have two database servers:</p>

<ul>
<li>Good Server: The good one, with the correct data. </li>
<li>Rebuilding Server: The one we are fixing. All it&#8217;s data will be erased with the Good Server data.</li>
</ul>

<p>You&#8217;ll need a unix command line and SQL command line on both servers. If you don&#8217;t already use it, after you&#8217;ve got this fixed, I recommend checking out <a href="http://en.wikipedia.org/wiki/GNU_Screen">Screen</a>.</p>

<h3>1. On the Good Server</h3>

<p>Dump data from the Good Server. The <code>master-data</code> switch adds a statement at the end of the file to start replication. </p>

<p>The <code>quick</code> switch makes dumping large tables use a lot less memory, so on a <a href="http://linode.com">VPS</a> it&#8217;s much faster.</p>

<p>All tables will locked during the dump.</p>

<p>Replace &#8216;my_database&#8217; with your database name.</p>

<div class="quickcodenoclick"><code><br />
$ mysqldump &#45;-add-drop-table &#45;-master-data <br />
&#45;-quick -u root -p my_database &gt; my_database.sql<br />
$ bzip2 my_database.sql<br />
</code></div>

<h3>2. On the Rebuilding Server</h3>

<p>Copy the dump onto the Rebuilding Server. Replace &#8216;myuser&#8217;, &#8216;good-server&#8217; and &#8216;my_database&#8217; as appropriate.</p>

<div class="quickcodenoclick"><code><br />
$ scp myuser@good-server:my_database.sql.bz2 .<br />
$ bunzip my_database.sql<br />
</code></div>

<p>Load the dump. This can take a few minutes for a large database.</p>

<div class="quickcodenoclick"><code><br />
mysql&gt; stop slave;<br />
$ mysql -u root -p my_database &lt; my_database.sql <br />
mysql&gt; show slave status\G<br />
</code></div>

<p>You should see <code>Slave_IO_Running: Yes</code> and <code>Slave_SQL_Running: Yes</code>. The <code>master-data</code> switch to <code>mysqldump</code>, in step 1, started replication at the right place for us. How nice. I love MySQL.</p>

<p>The \G means show vertical instead of the usual horizontal. It works with any MySQL command.</p>

<p>Now you have statements flowing Good Server &#8211;> Rebuilding Server. Next we need to get data going the other way.</p>

<div class="quickcodenoclick"><code><br />
mysql&gt; flush tables with read lock;<br />
mysql&gt; show master status;<br />
</code></div>

<p>Make a note of the File and Position rows.</p>

<h3>3. On the Good Server</h3>

<p>Set the slave here to be in synch with Rebuilding Server. Use the file name and log position from the previous step.</p>

<div class="quickcodenoclick"><code><br />
mysql&gt; stop slave;<br />
mysql&gt; change master to master_log_file=&#039;mysql-bin.000044&#039;, <br />
master_log_pos=132059667;<br />
mysql&gt; start slave;<br />
mysql&gt; show slave status\G<br />
</code></div>

<h3>4. On the Rebuilding Server</h3>

<div class="quickcodenoclick"><code><br />
mysql&gt; unlock tables;<br />
</code></div>

<p>Start the processes that point to the Rebuilding Server&#8217;s database. Done!</p>

<h2>Monitor replication</h2>

<p>The database is done, but you&#8217;re not done yet. </p>

<p>If you don&#8217;t already have good monitoring, take 15 minutes to setup <a href="http://mmonit.com/monit/">Monit</a> on all your production servers. </p>

<p>Monit is easy to setup (a word away from the monster that is Nagios), and will save again and again.</p>

<p>Once you have Monit working, take another 15 mins to <a href="http://www.elevatedrails.com/articles/2007/12/05/replication-monitoring-with-monit/">monitor MySQL replication with Monit</a>.</p>

<p><em>Now</em> you&#8217;re done :-)</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/gR_TfsoxXQU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/restarting-mysql-master-master-replication/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/restarting-mysql-master-master-replication/</feedburner:origLink></item>
		<item>
		<title>Treating the common cold</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/cGgthKusy5U/</link>
		<comments>http://www.darkcoding.net/misc/treating-the-common-cold/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 06:59:08 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[cold]]></category>
		<category><![CDATA[echinacea]]></category>
		<category><![CDATA[health]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[vitaminc]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=690</guid>
		<description><![CDATA[	Will Vitamin C really prevent or cure your cold?

	What about Echinacea?

	

	The best way to find out is to follow these simple steps:

	Gather 2000 people who have the common cold
Split them randomly into two groups of 1000
Give vitamin C to one group, and a sugar pill (the placebo) to the other
Make sure the people receiving the [...]]]></description>
			<content:encoded><![CDATA[	<p>Will Vitamin C really prevent or cure your cold?</p>

	<p>What about Echinacea?</p>

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

	<p>The best way to find out is to follow these simple steps:<br />
<ol></p>
	<p><li>Gather 2000 people who have the common cold</li><br />
<li>Split them randomly into two groups of 1000</li><br />
<li>Give vitamin C to one group, and a sugar pill (the placebo) to the other</li><br />
<li>Make sure the people receiving the pills and those dispensing the pills don&#8217;t know which is which (to make your trial double-blind)</li><br />
<li>Wait a bit</li><br />
<li>See if the Vitamin C group gets over their colder faster than the other group</li><br />
</ol></p>

	<p>You will of conducted a double-blind placebo controlled scientific trial.</p>

	<p>Luckily for us, we don&#8217;t have to do it ourselves. Several of these trials have already been done. Enough trials, in fact, that one can do a <a href="http://en.wikipedia.org/wiki/Meta-analysis">Meta analysis</a>, a statistical review and summary of all the trials.</p>

	<p><b>A comprehensive meta analysis, by an unbiased organization, is the gold standard of scientific inquiry; it is our best chance of knowing the truth.</b></p>

	<p>The <a href="http://en.wikipedia.org/wiki/Cochrane_Collaboration">Cochrane Collaboration</a> is an international not for profit organisation set up 15 years ago to create transparent, systematic, unbiased reviews of the medical literature on everything from drugs, through surgery, to community interventions. And I have a cold. I read their review to find out whether Vitamin C or Echinacea would be effective in treating it.</p>

	<p><h2>Vitamin C</h2></p>

	<p>Here is the review of research on <a href="http://www.cochrane.org/reviews/en/ab000980.html">Vitamin C for preventing and treating the common cold</a>.</p>

	<p><blockquote><br />
Thirty trials involving 11,350 participants suggest that regular ingestion of vitamin C has no effect on common cold incidence in the ordinary population.</p>

	<p>It reduced the duration and severity of common cold symptoms slightly, although the magnitude of the effect was so small its clinical usefulness is doubtful.</p>

	<p>Nevertheless, in six trials with participants exposed to short periods of extreme physical or cold stress or both (including marathon runners and skiers) vitamin C reduced the common cold risk by half.</p>

	<p>The failure of vitamin C supplementation to reduce the incidence of colds in the normal population indicates that routine mega-dose prophylaxis is not rationally justified for community use. But evidence suggests that it could be justified in people exposed to brief periods of severe physical exercise or cold environments.<br />
</blockquote></p>

	<p><h2>Echinacea</h2></p>

	<p>Here is their review of research on <a href="http://www.cochrane.org/reviews/en/ab000530.html">Echinacea for preventing and treating the common cold</a>.</p>

	<p><blockquote><br />
Echinacea preparations tested in clinical trials differ greatly. There is some evidence that preparations based on the aerial parts of E. purpurea might be effective for the early treatment of colds in adults but the results are not fully consistent.</p>

	<p>Beneficial effects of other Echinacea preparations, and Echinacea used for preventative purposes might exist but have not been shown in independently replicated, rigorous RCTs.<br />
</blockquote></p>

	<p>Get well soon!</p>

 <img src="http://feeds.feedburner.com/~r/darkcoding/~4/cGgthKusy5U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/misc/treating-the-common-cold/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/misc/treating-the-common-cold/</feedburner:origLink></item>
		<item>
		<title>Predictably Irrational, by Dan Ariely</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/OAzyi3ufRB8/</link>
		<comments>http://www.darkcoding.net/behaviour/predictably-irrational-by-dan-ariely/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 07:12:43 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[dan ariely]]></category>
		<category><![CDATA[predictably irrational]]></category>
		<category><![CDATA[social psychology]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=668</guid>
		<description><![CDATA[
My short notes on Predictably Irrational, by Dan Ariely. An excellent book. Entertaining, and covers much fascinating ground from social psychology and behavioral economics. Some of the experiments Dan and his team designed are fiendish!



Value is relative

We only know what we want when we see it in context. The bike the Tour de France winner [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=FFFFFF&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=darkcoding-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0061854549" style="float:left;width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

<p>My short notes on <a href="http://www.amazon.com/gp/product/0061854549?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0061854549">Predictably Irrational</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0061854549" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, by Dan Ariely. An excellent book. Entertaining, and covers much fascinating ground from social psychology and behavioral economics. Some of the experiments Dan and his team designed are fiendish!</p>

<hr />

<h2>Value is relative</h2>

<p>We only know what we want when we see it in context. The bike the Tour de France winner rides. A set of speakers compared to another. </p>

<p>We only know what something is worth, or how much we like it, when comparing to other similar things (purchases, partners, jobs, etc..</p>

<p><strong>We tend to choose the middle option</strong>. A high price option on a restaurant menu increases average order price, because it makes the rest seem cheap in comparison.</p>

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

<p>If we have several difficult to compare items, but two are easily comparable and one of those two is clearly superior to the other, we will prefer that one to <em>all</em> the other options. We can introduce a &#8216;decoy&#8217; version of one item, slightly less appealing, so that the target item is chosen. In A v B, introduce -A, and most people will choose B.</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=151">The truth about relativity</a></p>

<h2>Arbitrary coherence</h2>

<p>When we seriously contemplate buying something at a given price, that price becomes our <strong>anchor</strong>. From then on we judge other similar items relative to that price. We are coherent with our first valuation of something, even if that price is now irrelevant, arbitrary. </p>

<p>Items on sale attempt to get you to anchor at the &#8216;pre-sale&#8217; price, before introducing the sale price.</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=176">Starbucks, Dunkin Donuts, and Anchors</a></p>

<h2>Herding</h2>

<p>Joining a queue because other people are in it. Preferring a busy restaurant. Assuming something is good (or bad) on the basis of other people&#8217;s behavior.</p>

<p>Self-herding is when you do what you did before, because, well, that&#8217;s what you do. (See also: <a href="http://changingminds.org/explanations/theories/commitment.htm">commitment</a>)</p>

<p>We are irrationally attracted to FREE(!) things. We often pay a high cost in time and opportunity cost for them. Discounting from  cent to free has a much higher influence than 2 cents to 1 cent. Free is a whole different place than something that has a cost.</p>

<h2>Social Norms vs Market Norms</h2>

<p>Pay someone cheap, they don&#8217;t work much, because they use market norms and don&#8217;t feel it is worthwhile. Pay someone nothing, they work hard, because they use social norms.</p>

<p>Gifts stay within social norms, <em>unless</em> you mention the price of it, in which case people revert to market norms.  </p>

<p>Thinking about money makes people more self-reliant, selfish, solitary, individualistic.</p>

<p>Counting money is a pain buffer, makes people feel more powerful.</p>

<p>If both are present, market norms displace social norms, and it is very difficult to get the social norm back.</p>

<p>With gifts, benefits, and a good atmosphere, companies try and create a social contract with their employees. The employees hence expect the other side, the company to be there for them when they needed. Social norms require a high level of commitment from the company. Google and lots of startups get this right.</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=192">The Cost of Social Norms</a></p>

<h2>Emotions</h2>

<p>When not experiencing the emotion, we are bad at predicting our responses in a <strong>strong emotional state</strong>, such as sexual arousal, anger, hunger, excitement, jealousy, etc.</p>

<p>It is not easy to look from one emotional state to another.</p>

<p>Most people are aware that they procrastinate. Giving them tools to commit to a deadline helps them overcome it. </p>

<p>The best remedy for procrastination is <strong>an external force</strong>: Automatic payroll deductions for saving, teacher imposed assignment deadlines, exercising with a partner, etc. </p>

<p><strong>Engineer the world to force you to achieve your goal</strong>.</p>

<p>Simpler schedules are easier to commit to and more likely to be followed.</p>

<p>Package actions up into something that feels important enough to avoid procrastination. The same way auto-dealers package up our servicing into large mileage increments, and do all of it at once.</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=218">The Influence of Arousal</a></p>

<h2><a name="endowment">Endowment effect</a></h2>

<p>We value what we own more than other people do. Sellers usually value their items more than buyers do.</p>

<p>The sellers focuses on the loss of the enjoyment of the item. The buyer focuses on alternate uses for the money. Seller and buyer expect the other to see things the same was as them. </p>

<p>The more work you put into something, the more ownership you feel. The <a href="http://hbr.org/web/2009/hbr-list/ikea-effect-when-labor-leads-to-love">Ikea Effect</a>, because you assembled it yourself.</p>

<p>The endowment effect is why companies offer &#8216;trial&#8217; rates and &#8216;money back guarantees&#8217;. Once we have something, own it, we value it more. A &#8216;virtual ownership&#8217; applies to trying on clothes, and especially to online auctions. </p>

<p>The endowment effect applies to ideas too. We don&#8217;t want to let go of them, so they become a rigid ideology.</p>

<p>People dislike losing options, and will work quite hard to keep all their options open, eve if that means occasionally ignore their best option.</p>

<p>Often, we are presented with two or more very similar options. In this case <strong>the biggest cost is that of not choosing</strong> &#8211; the time spent deciding is time we are enjoying neither option.</p>

<p>Life usually conforms to our expectations, so you can influence results by setting expectations. Marketing sets expectations.</p>

<p>Video: <a href="[http://www.predictablyirrational.com/?page_id=348">Dating, doors, and loss aversion</a></p>

<h2>Priming</h2>

<p>Priming is putting thoughts into someones head. </p>

<p>Often, an experiment will ask people to unscramble a word, that word is chosen to make them think the priming thought.</p>

<p>Priming is a <a href="http://en.wikipedia.org/wiki/Context_effects">context effect</a>: Being influenced by something irrelevant in our immediate environment. </p>

<p>Two parties in a conflict, having already strongly committed to one side, need a neutral third party to resolve their conflict.</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=350">The Effect of Expectations</a></p>

<h2>Placebos</h2>

<p>Placebos are <em>belief</em> and <em>conditioning</em>. Many, maybe most, surgical procedures are not placebo tested.</p>

<h2>Honesty</h2>

<p>We internalize social virtues, so our conscience keeps us broadly honest.</p>

<p><strong>Given the opportunity, most people will cheat a little bit.</strong> A greater potential and reward for cheating doesn&#8217;t increase the cheating. Being reminded of the Ten Commandments, or of honor systems, eliminates the cheating.</p>

<p>People are more likely to cheat for non-monetary items &#8211; steal a pen from work, but not the value of the pen from the petty cash box.</p>

<p>It seems that people will only cheat within the limits their conscience (super-ego) allows them. <strong>We cheat to the extent we can justify it to ourselves.</strong></p>

<p>&#8220;It is difficult to get a man to understand something when his salary depends upon his not understanding it&#8221; &#8211; Upton Sinclair</p>

<p>Video: <a href="http://www.predictablyirrational.com/?page_id=224">The Context of our Character</a></p>

<hr />

<p>Dan Ariely maintains an excellent website with links to research papers from the book, and much more, here: <a href="http://www.predictablyirrational.com/">http://www.predictablyirrational.com/</a>.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/OAzyi3ufRB8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/predictably-irrational-by-dan-ariely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/predictably-irrational-by-dan-ariely/</feedburner:origLink></item>
		<item>
		<title>Influence, by Robert Cialdini</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/5hTVAJM_j8w/</link>
		<comments>http://www.darkcoding.net/behaviour/influence-by-robert-cialdini/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 06:42:09 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[influence behavior cialdini presuasion social psychology socialpsychology]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=652</guid>
		<description><![CDATA[
As an Amazon reviews says, &#8220;arguably the best book ever on what is increasingly becoming the science of persuasion.&#8221;

If you want to understand why you felt compelled to give money to a Hare Krishna devotee, how car salesman or realtor&#8217;s work, and much more, you should read this.  

It&#8217;s also a very easy and [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=FFFFFF&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=darkcoding-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=006124189X" style="float:left;width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

<p>As an Amazon reviews says, <strong>&#8220;arguably the best book ever on what is increasingly becoming the science of persuasion.&#8221;</strong></p>

<p>If you want to understand why you felt compelled to give money to a Hare Krishna devotee, how car salesman or realtor&#8217;s work, and much more, you should read this.  </p>

<p>It&#8217;s also a very easy and enjoyable read. These are my notes. They cover all the content in the book, but don&#8217;t link to research. In the book, most of the statements have links to research papers to back them up.</p>

<p>Get <a href="http://www.amazon.com/gp/product/006124189X?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=006124189X">Influence: The Psychology of Persuasion</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=006124189X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
 from your local library, this has sold so many copies they are bound to have some.</p>

<hr />

<p><a name="heuristics" /></p>

<h1>Heuristics</h1>

<p>We can process incoming information cognitively in one of two ways: </p>

<ul>
<li><strong>Controlled responding</strong>, which is subjecting information to a thorough analysis. This is when we think a problem through, research it, etc. We only do this if we have the desire and the ability. It is intellectually taxing and time consuming.</li>
<li><p>Use <strong>judgmental heuristics</strong> such as:</p>

<ul><li><em>Price as surrogate for value</em>. Applies particularly to items which are hard to value: Wine, jewelry, art, employee salaries, etc.</li>
<li><em>Trust experts</em>. This is why pseudo-science books always have &#8216;PhD&#8217; or &#8216;MD&#8217; after the author&#8217;s name.</li>
<li><em>Because</em> &#8211; we want reasons to do something, even bogus ones.</li></ul></li>
</ul>

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

<p><strong><a href="http://changingminds.org/principles/contrast.htm">Contrast principle</a></strong>: Two different things presented together or sequentially will feel more different than they really are. Hence <em>sell the expensive item first</em>, as the other items will seem cheap after that. <a href="http://en.wikipedia.org/wiki/Good_cop/bad_cop">Good cop / bad cop</a> is about creating a contrast between the two, to increase liking of the &#8216;good cop&#8217;.</p>

<p>A <strong>fixed action pattern</strong> is an automatic behavior pattern often triggered by a single item in the information. Also known as a <em>heuristic</em>.
<a name="reciprocity" /></p>

<h2>Reciprocity</h2>

<p>A <a href="http://en.wikipedia.org/wiki/International_Society_for_Krishna_Consciousness">Hare Krishna</a> devotee presses a flower or a copy of the Bhagavad-gītā into your hand (that happened to me), or a store gives you free samples, and you feel awkward about taking it for free. You end up giving money or buying something you don&#8217;t want. That&#8217;s the <a href="http://en.wikipedia.org/wiki/Norm_of_reciprocity">norm of reciprocity</a> at work.</p>

<p>We also reciprocate to <strong>concessions</strong>. Start witha large but not unreasonable request, which gets rejected, then &#8216;retreat&#8217; to the target request. People who comply after this technique has been used on them feel more satisfied with their decision than those who agree straight away, because they &#8216;bargained&#8217; for it. They shaped the outcome, so they feel ownership for it.</p>

<p>A recent research article I read (apologies, can&#8217;t locate link right now) supports this, by saying that when the seller of a product is the first to quote a price (typically quite high), the product sells for more than when the buyer opens the negotiation (with typically a low price).</p>

<p><strong>Surprise</strong> increase the likelihood of the target using heuristics instead of controlled responding. A shaved headed person in orange robes shoving an ancient Indian text at you, that&#8217;s surprising.
<a name="commitments" /></p>

<h2>Consistency / Commitments</h2>

<p>We wish to think of ourselves, and appear to others, as being consistent in our behavior, we apply the <a href="http://changingminds.org/principles/consistency.htm">consistency principle</a> heuristic. We make up reasons to justify our behavior, to seem logical and in line with our previous behaviors.</p>

<p><a href="http://en.wikipedia.org/wiki/Foot-in-the-door_technique">Foot in the door technique</a>: Start small and build. Extract a small inconsequential commitment, then a slightly bigger one, and so on.</p>

<p><strong>Commitments</strong> are most effective when they are:</p>

<ul>
<li><strong>Public</strong>: Forces us to stick to it to look consistent. Especially effective for those whith lots of pride or public self-consciousness.</li>
<li><strong>Active</strong>: Perform some action to take the commitment, such as writing, swearing an oath (also public), etc.</li>
<li><strong>Effort-full</strong>: The bigger the price the bigger the commitment. Hazing / initiation ceremonies. Extract a bigger effort with foor-in-the-door technique.</li>
<li><strong>Freely chosen</strong>:Avoid threats, or any external reward such as prizes. The commitment must feel freely chosen for the person to accept responsibility for it, it must feel internally motivated.</li>
</ul>

<p>Caveat: If the commitment alone gets the same result as the goal, we may not pursue the goal. For example if you are going to attend law school so that people will think you are clever, and telling people you are going to attend gets the response and recognition desired, the motivation to actually attend is removed.</p>

<p>Commitments get internally justified, they grow their own legs. Car salesman will often <em>low ball</em> you, offer an artificially low price.<br />
You gladly accept the low price. Time passes as you fill in some forms, test drive, etc. They take the paperwork to their manager for final approval. Manager comes out and explains the salesman made a mistake, the price is higher.<br />
You would of refused the higher price originally, but now you are committed, and much more likely to accept the high price.
<a name="socialproof" /></p>

<h2>Social Proof</h2>

<p>The greater the number of people who find any idea correct, the more a given individual will perceive the idea to be correct. This is the <a href="http://en.wikipedia.org/wiki/Social_proof">Social Proof</a> heuristic.</p>

<p><strong>We look to others for behavioral guidance when we are unsure, in an unclear, unfamiliar, or ambiguous situation.</strong> Often in such situations others do the same thing, which leads to <em>pluralistic ignorance</em>. </p>

<p>In an unclear emergency situation, a lone bystander will help, but a group looks to each other to decide how to act, and does nothing. This is the <a href="http://en.wikipedia.org/wiki/Bystander_effect">Bystander effect</a>.</p>

<p>In an emergency situation you need to reduce the uncertainty experienced by bystanders:</p>

<ul>
<li>Pick one and speak directly to him</li>
<li>Say you need help</li>
<li>Tell him how to help (&#8221;Call an ambulance&#8221;, &#8220;Help me out of my car&#8221;, etc)</li>
</ul>

<p>Social proof is strongest when the others we look to for guidance are similar to ourselves. Hence Joe Average in television adverts.</p>

<p>Individuals in psychological pain look to others in similar situations to see how to deal with it. After a widely reported high-profile suicide, suicides increase, often using a similar method. Copycat crimes work in a similar fashion.</p>

<p>Books, products, feature <em>One Million Sold</em> or <em>New York Times Bestseller</em> on the packaging. Informing someone that many people like him (NY Times readers) have adopted a certain behavior makes them more likely to also adopt that behavior. Testimonials.
<a name="liking" /></p>

<h2>Liking</h2>

<p>We prefer to buy from people we like. <strong>The strength of the social bond is twice as likely to determine product purchase as is preference for the product itself.</strong></p>

<p>So, what makes us like people?</p>

<h3>Physical attractiveness</h3>

<p>More attractive people, all other things being equal, are:</p>

<ul>
<li>paid higher salaries</li>
<li>less likely to be sent to jail</li>
<li>more likely to be helped in an emergency</li>
<li>more persuasive</li>
<li>seen as possessing more of the desirable personality traits</li>
<li>seen as having higher intellectual capacity</li>
</ul>

<p>It&#8217;s pretty shocking, I know, but the <a href="http://www.google.ca/search?q=attractive+people+more+successful">evidence is plentiful</a>.</p>

<p>Physical attractiveness triggers the <a href="http://en.wikipedia.org/wiki/Halo_effect">Halo Effect</a>, where one positive characteristic dominates the way that person is viewed by others.</p>

<h3>Similarity</h3>

<p><strong>We like people like us</strong>, whether that &#8216;like us&#8217; is because they share opinions, personality traits, background, or lifestyle. To influence, try and match the target in as many ways as possible:</p>

<ul>
<li>Dress</li>
<li>Interests</li>
<li>Background</li>
<li>Age, religion, politics, specific habits</li>
<li>Posture, verbal style, mood, etc. See <a href="http://en.wikipedia.org/wiki/Mirroring_%28psychology%29">Mirroring</a>.</li>
</ul>

<h3>Compliments</h3>

<p>People want to be liked. Be nice, pay compliments, send a greeting card. There is evidence that positive comments make the giver more likable even when the receiver knows the compliment is not genuine.</p>

<h3>Contact and co-operation</h3>

<p>Positive familiarity. <strong>Familiarity caused by contact leads to liking, <em>unless</em> the contact occurs under unpleasant circumstances.</strong></p>

<p>Here is a recipe for creating cross-group hatred: Split people into two groups. Name each one, to increase group identity (creating a <a href="http://www.darkcoding.net/behaviour/how-we-know-what-isnt-so-by-thomas-gilovich/">minimum group</a>). Wait. Then mix  the two groups in competitive actions.</p>

<p>And here&#8217;s how to fix it: Successful joint ventures towards common goals.</p>

<h3>Association</h3>

<p><strong>An innocent association with good or bad things will influence the way people think about that us</strong></p>

<ul>
<li>Showing a credit card logo to people with positive associations to credit cards (most people) made them tip more, even when paying cash. </li>
<li>Killing the messenger: An association with bad news, used to be bad news for the messenger.</li>
<li>Celebrity endorsments. Sponsorship of the Olympics, or whatever cultural event is popular, even if the connection doesn&#8217;t make sense. </li>
<li>Stand attractive people by your product. Their beauty somehow &#8216;rubs off&#8217; to make your product more appealing. </li>
<li>Hometown team victory makes us feel good, even though we obviously had no part in the victory.  </li>
<li><a href="http://en.wikipedia.org/wiki/Reductio_ad_Hitlerum">Reductio ad Hitlerum</a>: &#8220;Hitler was a vegetarian, so vegetarianism is wrong.&#8221;  </li>
</ul>

<p>Taken to extremes this is a personality flaw, showing low self worth, exhibited by groupies, sports fans, etc.
<a name="authority" /></p>

<h2>Authority</h2>

<p><strong>We trust experts, we obey experts</strong>. Often the appearance (symbols) of authority are enough, symbols such as:</p>

<ul>
<li>Titles: PhD, M.D., Dr., Professor.</li>
<li>Clothes: Medicine is advertised on TV by actors in white lab coats.</li>
<li>Trappings: Car, house, &#8216;lifestyle&#8217;.</li>
</ul>

<p>The seminal research on obedience to authority, and probably the most famous study in social psychology, is the <a href="http://en.wikipedia.org/wiki/Milgram_experiment">Stanley Milgram experiment</a>.
<a name="scarcity" /></p>

<h2>Scarcity</h2>

<p>Opportunities seem more valuable when they are less available. <a href="http://changingminds.org/principles/scarcity.htm">Scarcity heuristic</a> applies to information and goods.</p>

<p>If something is in short supply, everyone else must of wanted it, so it must be good.<br />
If something is in short supply, we are about to lose the freedom of acquiring it. </p>

<p><a href="http://en.wikipedia.org/wiki/Reactance_%28psychology%29">Reactance theory</a> says that an attempt to restrict something makes us want it more, and hence assume it is more valuable and desirable than we previously thought.</p>

<p>Things that recently became scarce are perceived as more valuable than things that have been scarce a long time. We react to a freedom being taken away.</p>

<p>Competition for a scarce item increases perceived value of the item, beyond scarcity alone, or social proof alone. Hence: Auctions.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/5hTVAJM_j8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/influence-by-robert-cialdini/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/influence-by-robert-cialdini/</feedburner:origLink></item>
		<item>
		<title>How we know what isn’t so, by Thomas Gilovich</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/EhJXSY1a8V8/</link>
		<comments>http://www.darkcoding.net/behaviour/how-we-know-what-isnt-so-by-thomas-gilovich/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 06:27:59 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[social psychology socialpsychology reason influence]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=622</guid>
		<description><![CDATA[
By Thomas Gilovich, social psychologist and CSI Fellow, this well written book explains some of the reasoning and deduction errors we make when trying to understand the world, and ways to avoid making those errors.

This is an easy and engaging read, and offers several straightforward techniques to avoid making common reasoning errors. I recommend you [...]]]></description>
			<content:encoded><![CDATA[<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&#038;bc1=FFFFFF&#038;IS2=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=darkcoding-20&#038;o=1&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;md=10FE9736YVPPT7A0FBG2&#038;asins=0029117062" style="width:120px;height:240px;float:left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>

<p>By <a href="http://en.wikipedia.org/wiki/Thomas_Gilovich">Thomas Gilovich</a>, social psychologist and <a href="http://www.csicop.org/about/csi_fellows_and_staff/">CSI Fellow</a>, this well written book explains some of the reasoning and deduction errors we make when trying to understand the world, and ways to avoid making those errors.</p>

<p>This is an easy and engaging read, and offers several straightforward techniques to avoid making common reasoning errors. I recommend you look up <a href="http://www.amazon.com/gp/product/0029117062?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0029117062">How We Know What Isn&#8217;t So: The Fallibility of Human Reason in Everyday Life</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0029117062" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
 in your local library, or get it second-hand from Amazon for less than a posh cup of coffee. </p>

<p>These are my notes / summary of the book.</p>

<hr />

<h2>I. Cognitive determinants of belief</h2>

<h3>2. Something out of nothing: The mis-perception and misinterpretation of random data</h3>

<p>We are predisposed to see order, pattern, and meaning in the world, and we find randomness, chaos, and meaninglessness unsatisfying.<br />
As a consequence we tend to &#8217;see&#8217; order where there is none, and we spot meaningful patterns where only the vagrancies of chance are operating.</p>

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

<p>Detecting patterns and seeing connections is very useful, leads to discovery and advance. But the tendency is so strong we sometimes do it when there was nothing to spot.</p>

<p>Example of <a href="http://www.google.ca/search?q=Gilovich+1985+The+hot+hand+in+basketball">hot hand in basketball</a>. Why?</p>

<ul>
<li><strong>Availability heuristic</strong>: We remember the long streaks, forget the single shots. Can interpret near-misses as evidence of &#8216;hot&#8217; or &#8216;cold&#8217; player.</li>
<li><p>People have faulty intuitions about what chance sequences look like.</p>

<p>See: <em>R. Falk (1981) The perception of randomness. In Proceedings, Fifth international conference for the psychology of mathematics education.</em></p>

<p>In a coin toss, people expect a near perfect alternation of heads and tails. In a series of 20 tosses, there is a 50/50 chance of getting 4 heads in a row, and 10% chance of six in a row. <a href="http://en.wikipedia.org/wiki/Clustering_illusion">Clustering illusion</a>.</p></li>
</ul>

<p><a href="http://images.google.ca/images?q=st+louis+gateway+arch">St Louis Gateway Arch</a> is one of the worlds largest optical illusion. It appears much taller than it is wide, yet height and base width are the same.</p>

<p><strong>Representativeness heuristic</strong>: &#8220;Like goes with like&#8221;. We expect things that go together to look similar. We expect instances of a type (librarian) to look like the prototype (a cliche librarian). Complex effect stem from complex causes. Effects look like their causes: Jagged handwriting means jagged nerves, heartburn comes from hot/spicy foods, etc.</p>

<p>Representativeness usually very helpful. Occasionally mis-applied. The salient (&#8217;prominent or conspicuous&#8217;) feature of something is what we remember, and apply the representativeness heuristic to that. The salient feature of a random sequence is the even mix of all the outcomes.</p>

<p>Law of averages is, by statisticians, correctly called the <strong>law of large numbers</strong>. The even mix of outcomes is only true for very large random sample. There is no &#8216;law of small numbers&#8217;.</p>

<p>Stock market: <a href="http://www.amazon.com/gp/product/0393330338?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0393330338">Random walk</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0393330338" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, but chartists insist they see patterns in the randomness.</p>

<p>In any random distribution (e.g. x,y plots on a graph), there will be a way of segmenting it (along the axes, diagonally, in bands, etc) that will appear non-random. Carving up data after the fact is meaningless. If we <em>think</em> we see a pattern in the data, test that pattern on other independent sets of data.<br />
Unfortunately, for most people hypotheses constructed on one set of data are considered proved by that same data.
This is why medical trials announce their goal, the expected outcome, ahead of time.</p>

<p>Once we think we see order in randomness, humans are exceptionally good at justifying it with a post-hoc theory. Improv comedy teaches &#8216;jump and justify&#8217;; say something random then justify it, it&#8217;s surprisingly easy.<br />
For example people let to believe they are above or below the average at some task can explain the difference quite easily, even when the experimenters assigned the above/below at random.<br />
Experiments with split-brain patients, where they justify what the other part of the brain just did.</p>

<p>Once a person has (mis)identified a random pattern as a &#8216;real&#8217; phenomenon, it will not exist as a puzzling, isolated fact about the world. Rather, it is quickly explained and readily integrated into the person&#8217;s pre-existing theories and beliefs. These theories then serve to bias that persons evaluation of new information. People cling tenaciously to their beliefs in the face of hostile evidence.</p>

<p><strong>Regression to the mean</strong>: When two variables are related, but imperfectly so, an extreme value on one tends to be matched by a less extreme value on the other. A high number roll on the dice tends to be followed by a lower number, and a low number by a higher one.
A companies disastrous years tend to be followed by betters ones. Students with exceptionally good grades in high-school tend to do slightly less well in college.</p>

<p>Regression can be understood than in any performance (game, test, financial year, etc) there is a part of talent and a part of chance. An very high score is more likely to be a good student with luck in their favor, rather than an extremely good student with luck working against them, simply because there are more &#8216;good&#8217; students than &#8216;extremely good&#8217; students. So a very high score is likely to be followed by a slightly lower one, because it is unlikely to get chance that much in favor two times in a row.</p>

<p>Most people understand regression, but make two mistakes:</p>

<ul>
<li>Insufficiently &#8216;regressive&#8217; when making predictions. The &#8216;next&#8217; value after an extreme one is closer to the average than they tend to predict.</li>
<li>Regression fallacy: Fail to recognize statistical regression, and explain it away with a superfluous and often complex causal theory. Ad-hoc justification where none was needed.</li>
</ul>

<p>The regression fallacy shapes people (parents and teachers, mostly) perception of the effectiveness of rewards and punishments. A good performance is likely to be followed by a less good one, and a bad one by a less bad one. If the good performance is rewarded, the reward will be perceived as ineffective because the good performance was not repeated. If a bad performance is punished the punishment will be perceived as effective because the bad performance will not be repeated.<br />
That notwithstanding, psychologists have known for some time that rewarding desirable behavior is generally more effective in shaping behavior than punishing undesirable responses.<br />
See: <em>B. F. Skinner (1953) Science and human behavior.</em></p>

<h3>3. Too much from too little: The misinterpretation of incomplete and unrepresentative data</h3>

<p>Using empirical evidence as proof: &#8220;I&#8217;ve seen it happen&#8221;, &#8220;I know someone who did&#8221;, etc. If a phenomenon exists, there must be some positive evidence &#8211; &#8216;instances&#8217; of its existence visible to us. So empirical positive statements are <em>necessary</em> for a belief to be true, but they are not <em>sufficient</em>. We also need to know <strong>what goes in the other boxes</strong>. </p>

<p>Many of the beliefs we hold are about the relationships between two variables (&#8217;takes vitamin C&#8217; and &#8216;gets better&#8217;).
Say we were investigating &#8216;vitamin C megadose&#8217; on cancer patients. We notice some patients get better after taking mega-doses of vitamin C. That prompts us to <em>start</em> investigating. Positive outcomes under treatment are one box, we need to know the other three:</p>

<table>
<tr><th></th><th>Takes Vitamin C</th><th>Doesn&#8217;t take Vitamin C</th></tr>
<tr><th>Gets better</th><td>a</td><td>b</td></tr>
<tr><th>Doesn&#8217;t get better</th><td>c</td><td>d</td></tr>
</table>

<p>If we stop at noticing some patients getting better, all we have is box a. All we have is the &#8216;illusion of validity&#8217;.</p>

<p>For vitamin C to be effective, the probability of getting better after taking it <code>[a / (a + b)]</code> must be higher than the probability of getting better after not taking it <code>[c / (c + d)]</code>.</p>

<p>This is often difficult to do intuitively, because box &#8216;a&#8217; is the most salient. <strong>We notice things happening, not things not happening</strong>. </p>

<p>We often <strong>seek only evidence to confirm our beliefs</strong>; we should also seek information to disprove them, and only hold our beliefs if such evidence is not available.</p>

<p>Often the evidence in the other boxes is not available, particularly in evaluating selection criteria. How do we test whether a companies interview process is effective? We are asking the relationship between &#8216;passes interview&#8217; and &#8216;performs well at job&#8217;. But it&#8217;s very nature, we don&#8217;t have the data on job performance for people who didn&#8217;t pass the interview.</p>

<table>
<tr><th></th><th>Passes selection</th><th>Doesn&#8217;t pass</th></tr>
<tr><th>Performs</th><td>a</td><td>?</td></tr>
<tr><th>Doesn&#8217;t perform</th><td>c</td><td>?</td></tr>
</table>

<p>The only data we have is a and c, we can only compare the success rate of those who pass the selection. If the base rate of success is high (most people could perform well, only the best performers apply, etc), a would be higher than c whatever the selection criteria, so we would spuriously conclude our criteria are good.</p>

<p>It is not possible to be confident about the selection process without the data on those who were not selected.</p>

<p>Furthermore, simply being accepted can give someone a competitive advantage. Being admitted to a better school, getting a research grant, or working with high-performing colleagues will all improve an individuals performance compared to someone of similar initial ability who didn&#8217;t get selected.</p>

<p>Effectiveness of public policy is similarly difficult to measure, because we can&#8217;t both set the policy and not set it.</p>

<p>Often the lifestyles we lead, the roles we play, and the positions we occupy in a social network, deny us access to important classes of information and thus distort our view of the world. Overcoming that bias is difficult: We must first recognize the existence of a class of information we have not been exposed to, and then accurately characterize what that information is like.</p>

<p><strong>Self-fulfilling prophecies</strong>: Have got a lot of attention. For a prophecy to be self-fulfilling there must be a mechanism that translates the expectation into confirmatory action. They often serve to exagerate a belief that holds a kernel of truth.<br />
Thinking a bank is in trouble (usually with good reason), creditors will withdraw their money, and the bank will <em>really</em> be in trouble. Behaving in an unfriendly and defensive manner because you think someone is hostile will often produce that very hostility.</p>

<p>True self-fulfilling prophecies are ones in which a persons belief elicits the very behavior originally anticipated.<br />
A <strong>seemingly self-fulfilling prophecy</strong> is one which alters a persons world or limits their responses, in such a way to make it very difficult or impossible for that expectation to be proved wrong. If someone thinks that I am unfriendly, they will avoid me, so I will have no opportunity to prove them wrong. If a sports player is thought incompetent, he won&#8217;t get to play, so won&#8217;t be able to prove himself competent. The continued absence of positive contribution can easily be mistaken for an absence of talent, when it is simply an absence of opportunity.</p>

<p>Negative first-impressions are generally more stable than positive ones, because we keep interacting only with people who created positive first impressions.</p>

<h3>4. Seeing what we expect to see: The biased evaluation of ambiguous and inconsistent data</h3>

<p>Information consistent with our pre-existing beliefs is generally accepted at face value, whereas evidence that contradicts them is critically scrutinized and discounted. Our beliefs are much less responsive than they should be to the implications of new information.
This is a sane and necessary strategy. If a belief has a lifetime of support, it is perfectly valid to be skeptical of evidence that contradicts it.<br />
Well supported beliefs have earned their inertia. We need to be wary of the beliefs that don&#8217;t have a solid foundation, such as cultural stereotypes, social norms, and traditions.</p>

<p><strong>Ambiguous information</strong> is usually perceived in a way that fits out expectations. We may not even be aware of the ambiguity &#8211; it gets resolved before reaching conscious awareness.</p>

<p>Gamblers tend to attribute their losses to outside forces (chance, the referee, a team injury), but their wins to themselves (knew the team well, studied the form). We re-write our history to discount our losses and bolster our wins.</p>

<p>By carefully scrutinizing information that does not fit our beliefs, we can usually find a way of either discounting or re-interpreting it.</p>

<p>Scientists use a set of formal safeguards to prevent their own erroneous thinking affecting their results:</p>

<ul>
<li>Statistical measures to guard against the mis-perception of randomness</li>
<li>Control groups and random sampling to avoid drawing inference from incomplete or unrepresentative data</li>
<li>&#8216;Blind&#8217; observers to eliminate experimenter bias.</li>
<li>Precisely specify in advance the meaning of various outcomes, and objectively determine those outcomes.
These rules are the &#8216;context of justification&#8217;, used when testing an idea. Idea generating is much more open. Science works by flashes of inspiration followed by rigorous testing. The rigorous testing is what differentiates scientific inquiry from everyday life.</li>
</ul>

<p><strong>Multiple endpoints</strong>: By not precisely specifying an expected outcome, we can pick any one and claim it as success. Psychics will use very vague descriptions, so that we can apply them to our lives and perceive them as true. If the subject is fuzzy (&#8217;personal well-being&#8217; for example), we are likely to seize upon any subsequent measure of it that fits our initial beliefs.</p>

<p><strong>Variable windows</strong>: By not specifying an endpoint to a prediction, it stays &#8216;open&#8217; until it comes true. &#8216;Thing happen in threes&#8217; because we could &#8216;things happening&#8217; after the third one has occured, whenever that may be. The third event defines the time window for our prediction.
With a wide enough variable window, beliefs can <em>only</em> be confirmed.</p>

<p><strong>Multi-faceted expectation</strong>: For any two sufficiently complex entities, we can produce a mapping of one onto the other that will produce a certain amount of overlap, and allows us to claim they are similar in some way. Often used with the representativeness heuristic. </p>

<blockquote>
  <p>You have a strong need for other people to like you and for them to admire you. At times you are extroverted, affable, and sociable, while at other times you are introverted, wary, and reserved. You have a great deal of unused energy which you have not turned to your advantage. While you have some personality weaknesses, yo are generally able to compensate for them. You prefer a certain amount of change and variety and become dissatisfied whne hemmed in by restrictions and limitations. You pride yourself on being an independent thinker and do not accept others opinions without satisfactory proof. You have a tendency to be critical of yourself. Some of your aspirations tend to be pretty unrealistic.</p>
</blockquote>

<p>If you see yourself in that description, you are not alone. It is multi-faceted, so most people will find the part that related to them the most salient, and the statements are so general (multiple endpoints) that they are bound to ring true. This is how horoscopes work.</p>

<p><strong>One-sided</strong> versus <strong>two-sided events</strong>: </p>

<ul>
<li>One-sided events are ones that are memorable only when they turn out a certain way: &#8216;The phone always rings when I&#8217;m in the bath&#8217;, &#8216;You wait forever for a bus and three come along at once&#8217;, etc. If the phone does not ring whilst you are in the bath, the non-event does not register.</li>
<li>Two-sided events are ones that register regardless of the outcome: Vacations, dates, gambling, buying a stock, etc. Both outcomes stand out from the stream of experience.</li>
</ul>

<p>In two-sided events, often negative outcomes are remembered better than positive ones, as they require more rationalization to incorporate them into our self-image and understanding of the world.<br />
In one-sided events, we are more likely to remember the &#8217;side&#8217; of events that has meaning to us, which is usually the one that reinforces our world-view. If I believe my dreams are prophetic, I will remember those much more than the other dreams. If I believe that strange things happen during a new moon, I will notice and remember the strange things, not the ordinary things (strange things not happening).</p>

<p>Many one-sided events only &#8216;exist&#8217; when they are confirmed. If a fortune teller says you will have twins, and you have twins, you remember the fortune teller, link the two events, and form a strong memory. If you have one child, you probably won&#8217;t think of the fortune teller at all. And even if you did, the fortune is not contradicted, simple un-confirmed. You could have twins later in life.</p>

<p>One-sided events tend to be temporally unfocused, they have variable windows to be confirmed in. A &#8216;prophetic&#8217; dream, a fortune, doesn&#8217;t have a fixed date, so only the positive outcome is acknowledged.<br />
Two-sided events tend to have fixed windows: A sporting event, a vacation, a job interview. The closed window forces us to acknowledge both outcomes.</p>

<p>In two-sided events, both outcomes produce the same intensity of emotion (winning or losing a bet). In a one-sided event, only one of the outcomes has any emotional weight: It &#8216;always&#8217; seems to rain when you forget your umbrella, because getting wet has an emotional attachment (hair ruined, clothes soaked, etc), whereas not-getting-wet doesn&#8217;t.</p>

<p><strong>Definitional asymmetries</strong>: &#8216;American tourists in London are loud&#8217;, &#8216;I can always spot fake breasts&#8217;, &#8216;You need to hit rock-bottom to bounce back&#8217;. All of these are difficult or impossible to disprove: We only notice the loud people, we don&#8217;t notice fake breasts that we didn&#8217;t spot, and how can you say if someone has hit rock-bottom or not? Definitional asymmetries are all one-sided events.</p>

<p>One-sided events tend to have a &#8216;normal&#8217; outcome with a high base rate, which we don&#8217;t notice because it is part of everyday life (&#8217;look, it&#8217;s not a full moon&#8217;), and an less usual more salient outcome (&#8217;o oh, it&#8217;s a full moon!&#8217;).</p>

<p>All of the above relate to the <strong><a href="http://en.wikipedia.org/wiki/Availability_heuristic">availability heuristic</a></strong>.</p>

<h2>II. Motivational and social determinants of questionable beliefs</h2>

<h3>5. Seeing what we want to see: Motivational determinants of belief</h3>

<p><strong><a href="http://en.wikipedia.org/wiki/Endowment_effect">Endowment effect</a></strong>: We value something more when it is ours. Ownership creates an inertia that prevents many potentially beneficial transactions from occurring.</p>

<p>The endowment effect applied to humans is the <strong>Lake Wobegon effect</strong>, or <strong><a href="http://en.wikipedia.org/wiki/Illusory_superiority">Illusory superiority</a></strong>. This is particularly true on ambiguous traits (&#8217;intelligence&#8217;, &#8217;sensitivity&#8217;, &#8216;idealism&#8217;), and less true on more specific traits (&#8217;thriftiness&#8217;, &#8216;being well-read&#8217;). If a specific definition is given in the question, the above average effect tends to disappear: People are not lying or cheating, it&#8217;s just that the first thing that comes to mind when asked an ambiguous question is usually something they are good at, something salient in their lives.</p>

<p><strong>We attribute success internally and failure externally</strong>. Thanks to their own resources, they succeeded. Because of the others/the environment, they failed.<br />
Many psychologists hold that we do this to maintain self-esteem. There is also a cognitive explanation: Succeeding at something is at least partly due to our own effort, and thus warrants some internal attribution. Failing at something usually happens despite our best efforts, so often invovles an unfavorable external situation. </p>

<p>People <em>are</em> more likely to believe things they want to believe, but are constrained by objective evidence and the need to construct a justification that would presuade a dispassionate observer. We draw the desired conclusion only if we can muster up enough evidence to support it. It is in this sense that most people think of themselves are objective.<br />
People often do not realize that their selection and interpretation of data is biased by their goals &#8211; the data could be interpreted a different way, and there is other data they ignored. They may well be able to justify opposite conclusions on different occasions.</p>

<p>How we &#8216;filter&#8217; data to ensure it supports our goals:</p>

<ul>
<li>Seeking only to confirm</li>
<li>Select who we consult. By judiciously choosing whom we consult on an issue, we can increase our chances of hearing what we want to hear.</li>
<li>Amount of information: If the initial results confirm out expectations, we stop looking. If they don&#8217;t, we keep looking.</li>
</ul>

<p>We should not stop at <code>Can I believe this?</code>, but should progress to <code>Must I believe this?</code>.</p>

<p>These are some of the ways we skew the evidence in the world, frame it to support our beliefs. This is healthy. People who can&#8217;t frame effectively run the risk of depression.</p>

<p>Beliefs are like possessions: We acquire the ones we think will make us feel good, and cling tightly to the ones we have.</p>

<h3>6. Believing what we are told: The biasing effects of secondhand information</h3>

<p>Telling a good story: The speaker needs their message to be worthy of the listeners attention. For the listener the interaction must be worthwhile in some way. The message must be understandable (not assume too much knowledge of the listener) and yet not too detailed (not assume too little knowledge of the listener).</p>

<p><strong>Sharpening and Leveling</strong>: What the speaker construes as the gist of the message is emphasized, &#8217;sharpened&#8217;, where are details thought to be less important are de-emphasized, &#8216;leveled&#8217;.</p>

<p>One results of sharpening and leveling is that we often develop exaggerated or extreme views of people we have only been told about. </p>

<p>One way to make a message more entertaining or seemingly informative is to <strong>increase it&#8217;s immediacy</strong>. Instead of the story happening to a friend of a friend&#8217;s colleague, have it happen directly to friend or family member, or even better, you. Often such alterations are intended for the self-aggrandizement of the speaker. It places them closer to center-stage. Other times it is simply an effort to make the story more salient, more vivid and concrete.</p>

<p>Increasing immediacy makes it difficult for the listener to accurately gauge the reliability of your message:</p>

<ul>
<li>Reducing the hops: We all know that the more hops a message has been through, the less reliable it is. Increasing the immediacy of a message for the sake of entertainment or self-aggrandizement also makes a message seem more reliable than it is.</li>
<li>Changing the origination (&#8217;my brother&#8217;, instead of &#8216;my brother&#8217;s friend from work&#8217;): Your brother might be trustworthy, so we trust the message, but your brother&#8217;s friend is an inveterate liar. The original source of the message has been obscured.</li>
</ul>

<p>Presenting and accepting remote accounts as secondhand is misleading when estimating the prevalence of a phenomenon in the general population. If something happened to lots of your friends cousins, it is happening a lot. If lots of your friends cousins heard a story about someone else&#8217;s friends cousin, and passed it on, there might be a single case.</p>

<p>In attempting to be informative, we might level some of the qualifications in the original message. This is often the case when scientific findings are reported in the news media.<br />
Sometimes the facts are stretched to &#8216;help&#8217; their audience get the message. This results in hysterical public service campaigns, that elicit far more fear than the original risk warranted (drugs, &#8217;stranger danger&#8217;, terrorism, etc). The facts are stretched beyond recognition to make a more compelling story.<br />
Parents are often guilty of this distortion in attempting to motivate behavior in their children.</p>

<p>The desire to <strong>entertain</strong> often creates a conflict for the speaker between satisfying the goal of accuracy and the goal of entertainment. There is often a tacit agreement between speaker and audience that the truth may be stretched: Tabloids and &#8216;light entertainment&#8217; news shows are granted this permission. &#8220;One of the most common sources of such inaccuracy is the dissemination of unfounded or fallacious claims by news and other media organizations that try and entice by their ability to entertain.&#8221; The demand for news has been met by and artificial increase in supply.</p>

<p><strong>Plausibility</strong>: Inaccurate or fictitious stories are sometimes told and retold because they just seem so plausible, that we let our critical guard down. Our standards for plausibility are often very low, a decent irony is often enough (the creator of the song &#8220;Don&#8217;t worry be happy&#8221; committing suicide, for example, or someone at the patent office resigning because there was nothing left to invent).</p>

<p><strong>Summary</strong>: As we have seen in previous chapters, the data from our own experience is often biased and incomplete. In this chapter we saw that data from others is also. It is therefore important to locate unbiased, complete sources of base-rate data (scientific inquiry mainly), and use those to asses how likely it is that our own perceptions or those of our social group are true.
If the base rate data and our personal experience concur, then we are likely correct. If they don&#8217;t a reliable base rate should be our guide. If the base rate data is to reliable, at least we know that we don&#8217;t know.</p>

<p>How to assess secondhand information:</p>

<ul>
<li>Consider the source: The New York Times or the National Enquirer? A rock star or a researcher? An actor who plays a doctor on TV, or a practicing medical doctor.</li>
<li>Trust facts, distrust projections: Predicting the future is hard, even for an expert. What looks like an <a href="http://images.google.ca/images?q=exponential">exponential</a> curve can turn out to be <a href="http://images.google.ca/images?q=sigmoidal">sigmoidal</a>.</li>
<li>Watch for Sharpening and Leveling.</li>
<li>Be wary of testimonials. One striking human interest story does not tell you anything about prevalence or risk.</li>
</ul>

<h3>7. The imagined agreement of others: Exaggerated impressions of social support</h3>

<p>What we believe is heavily influenced by what we think others believe. This is usually a good strategy. However we often exaggerate the extent to which others hold the same beliefs as us. We think we have more social support for our opinions than we really do.</p>

<p>This is the <strong><a href="http://en.wikipedia.org/wiki/False_consensus_effect">false consensus effect</a></strong>: This is a <em>relative</em> effect. We realize if our belief is in the minority. We underestimate by how much in the minority.</p>

<p>Reasons:</p>

<ul>
<li>Motivational: A desire to maintain a positive assessment of our own judgment.</li>
<li>Social: We interact with people who agree with us</li>
<li>Context interpretation: We assume that given the same context, everyone will infer the same thing. As we see others in the same context, we assume they come to the same conclusions as us. As a result the false consensus effect is strongest for beliefs we attribute to external factors (buy stock in Ford or Google), and weakest for ones we attribute internally (name your son Jacob or Ian). The context is often ambiguous, and different people resolve the ambiguity in different ways, often without noticing it.</li>
</ul>

<p><strong>Inadequate feedback from others</strong>: People are generally reluctant to openly question another person&#8217;s beliefs (<em>Adults</em>, that is. Children do it all the time). Only intimate friends and relatives can be counted upon for honest feedback. More casual acquaintances often side-step the awkwardness of disagreement and thus leave us without essential corrective feedback.
Because so much disagreement remains hidden, our beliefs are not properly shaped by healthy scrutiny and debate.</p>

<h2>III. Examples of questionable and erroneous beliefs</h2>

<p>(not summarized)</p>

<h2>IV. Where do we go from here</h2>

<h3>11. Challenging dubious beliefs: The roles of social science</h3>

<blockquote>
  <p>The real purpose of [the] scientific method is to make sure Nature hasn&#8217;t misled you into thinking you know something you actually don&#8217;t know. 
  R. Pirsig, Zen and the Art of Motorcycle Maintenance.</p>
</blockquote>

<p>To avoid erroneous beliefs it is necessary that we deveop certain habits of mind that can shore up various deficiencies in our everyday inferential abilities. Fortunately, there is reason to believe that these corrective habits of mind are not difficult to develop. Students familiar with the work on errors and biases readily apply the learning to their everyday lives.</p>

<p>Most important mental habit is realizing the folly of trying to draw conclusions from incomplete and unrepresentative data.</p>

<p>Ask: <code>What do the other three cells look like?</code></p>

<p>Information presented as firsthand is often secondhand or more remote, and from a less trustworthy source. Be sure you know where you information originated before assessing it&#8217;s value.</p>

<p>Many of these habits are core to scientific research. Familiarity with that world helps. Gives you valuable exposure to uncertainty and doubt, a healthy skepticism, and the awareness of how hard it can be to really know something with certainty.</p>

<p>Exposure to the &#8216;probabilistic&#8217; sciences (psychology, economics, social sciences, etc) may be more effective in teaching these habits than the &#8216;deterministic&#8217; (physics, chemistry, etc) sciences.<br />
Probabilistic sciences deal with phenomena that are not perfectly predictable, and with causes that are generally neither necessary nor sufficient. The death of a spouse is associated with deterioration in health. However not all partners health deteriorates (not sufficient), and people&#8217;s health deteriorates for other reasons (not necessary).<br />
To compensate for this lack of determinism, probabilistic sciencists must be aware of statistical regression, sample bias, and the importance of control groups.</p>

<p>Social sciences deal with everyday phenomenon, so it easier for them than physical sciences to make the probabilistic tools of reasoning readily understandable and available.</p>

<p>Social scientists should no longer suffer from physics envy. They cannot match their explanatory power or predictive precision, but specifically because of this, they are better equipped to deal with the messy, complex phenomena of real life. Their tools and process, rather than their content, may turn out to be the social sciences most valuable discoveries.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/EhJXSY1a8V8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/how-we-know-what-isnt-so-by-thomas-gilovich/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/how-we-know-what-isnt-so-by-thomas-gilovich/</feedburner:origLink></item>
		<item>
		<title>Memcached: List all keys</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/2IpOwHTf9yo/</link>
		<comments>http://www.darkcoding.net/software/memcached-list-all-keys/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 16:50:30 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[memcached cache keys list]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=596</guid>
		<description><![CDATA[	In the general case, there is no way to list all the keys that a memcached instance is storing. You can, however, list something like the first 1Meg of keys, which is usually enough during development. Here&#8217;s how:

	Telnet to your server:

	telnet 127.0.0.1 11211

	

	List the items, to get the slab ids:

	stats items
STAT items:3:number 1
STAT items:3:age 498
STAT [...]]]></description>
			<content:encoded><![CDATA[	<p>In the general case, there is <a href="http://code.google.com/p/memcached/wiki/FAQ#Can_I_iterate_the_items_of_the_memcached_server?">no way to list all the keys</a> that a <a href="http://www.danga.com/memcached/">memcached</a> instance is storing. You can, however, list something like the first 1Meg of keys, which is usually enough during development. Here&#8217;s how:</p>

	<p>Telnet to your server:</p>

	<p><blockquote>telnet 127.0.0.1 11211</blockquote></p>

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

	<p>List the items, to get the slab ids:</p>

	<p><blockquote>stats items<br />
<span class="caps">STAT</span> items:3:number 1<br />
<span class="caps">STAT</span> items:3:age 498<br />
<span class="caps">STAT</span> items:22:number 1<br />
<span class="caps">STAT</span> items:22:age 498<br />
<span class="caps">END</span></blockquote></p>

	<p>The first number after &#8216;items&#8217; is the slab id. Request a cache dump for each slab id, with a limit for the max number of keys to dump:</p>

	<p><blockquote>stats cachedump 3 100<br />
<span class="caps">ITEM</span> views.decorators.cache.cache_header..cc7d9 [6 b; 1256056128 s]<br />
<span class="caps">END</span><br />
stats cachedump 22 100<br />
<span class="caps">ITEM</span> views.decorators.cache.cache_page..8427e [7736 b; 1256056128 s]<br />
<span class="caps">END</span></blockquote></p>

	<p>Thanks to Boris Partensky in the Memcached group <a href="http://groups.google.com/group/memcached/browse_thread/thread/632ce89cff47522d?pli=1">here</a></p>

	<p>There you go!</p>

 <img src="http://feeds.feedburner.com/~r/darkcoding/~4/2IpOwHTf9yo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/memcached-list-all-keys/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/memcached-list-all-keys/</feedburner:origLink></item>
		<item>
		<title>Guy Kawasaki’s 10-20-30 presentation rule</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/at_QTTNo9Ls/</link>
		<comments>http://www.darkcoding.net/misc/guy-kawasakis-10-20-30-presentations-rule/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 17:41:22 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[presentation youtube guykawasaki 10-20-30]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=587</guid>
		<description><![CDATA[	Funny, practical, and well worth 1 minute 50 seconds of your life:

	

	via the BootUp Labs Blog.

 ]]></description>
			<content:encoded><![CDATA[	<p>Funny, practical, and well worth 1 minute 50 seconds of your life:</p>

	<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/liQLdRk0Ziw&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/liQLdRk0Ziw&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object></p>

	<p>via the <a href="http://blog.bootuplabs.com/2009/09/29/3-investor-pitch-conditions-why-you-get-conflicting-advice/">BootUp Labs Blog</a>.</p>

 <img src="http://feeds.feedburner.com/~r/darkcoding/~4/at_QTTNo9Ls" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/misc/guy-kawasakis-10-20-30-presentations-rule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/misc/guy-kawasakis-10-20-30-presentations-rule/</feedburner:origLink></item>
		<item>
		<title>I’m on identi.ca and Twitter</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/Jr9EV5nq8gg/</link>
		<comments>http://www.darkcoding.net/misc/im-on-identi-ca-and-twitter/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 16:08:35 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[microblogging twitter identica]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=578</guid>
		<description><![CDATA[I am sharing my thoughts, mainly about web technologies, on identi.ca and twitter.


Graham King on identi.ca
Graham King on Twitter


The nature of the medium means those thoughts will be generally raw and truncated, but timely.
]]></description>
			<content:encoded><![CDATA[<p>I am sharing my thoughts, mainly about web technologies, on identi.ca and twitter.</p>

<ul>
<li><a href="http://identi.ca/grahamking">Graham King on identi.ca</a></li>
<li><a href="http://twitter.com/grahamking">Graham King on Twitter</a></li>
</ul>

<p>The nature of the medium means those thoughts will be generally raw and <a href="http://identi.ca/notice/9739093">truncated</a>, but timely.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/Jr9EV5nq8gg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/misc/im-on-identi-ca-and-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/misc/im-on-identi-ca-and-twitter/</feedburner:origLink></item>
		<item>
		<title>Social psychology in sales copy: Good copy writing</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/4GbKdZ3lyYw/</link>
		<comments>http://www.darkcoding.net/behaviour/social-psychology-in-sales-copy-good-copy-writing/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 18:03:35 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[behavior socialpsychology influence copy copywriting sales]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=560</guid>
		<description><![CDATA[I recently received an advert for an investment fund in which, as the amateur social psychologist that I am, I noticed illustrated a couple of psychological principles. The are both covered in the email title:


  Last chance to invest in a firm favourite


They are covered again in more detail in this paragraph:


  The [...]]]></description>
			<content:encoded><![CDATA[<p>I recently received an advert for an investment fund in which, as the amateur social psychologist that I am, I noticed illustrated a couple of psychological principles. The are both covered in the email title:</p>

<blockquote>
  <p>Last chance to invest in a firm favourite</p>
</blockquote>

<p>They are covered again in more detail in this paragraph:</p>

<blockquote>
  <p>The x y z Fund only launched six months ago, but has already attracted considerable interest. To keep it small and flexible the number of units has been capped at 200 million. Last week they had reached two-thirds of that total and interest is intensifying. In the last two days alone they sold over 6 million units, so it is likely to close very soon.</p>
</blockquote>

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

<h2>Social Proof</h2>

<p>The first principle is <a href="http://en.wikipedia.org/wiki/Social_Proof">Social Proof</a>. This fund is <em>&#8220;a firm favorite&#8221;</em> and <em>&#8220;has already attracted considerable interest&#8221;</em> and already <em>&#8220;sold over 6 million units&#8221;</em>. In other words, other people think it&#8217;s a very good idea to invest in this fund, so you should to.<br />
Many of the top researchers in the field of influence (social psychology, behavioral economics, etc) <a href="http://www.time.com/time/printout/0,8816,1889153,00.html">worked with the Obama campaign</a>, Their last minute get-out-the-vote message was <em>&#8220;A Record Turnout Is Expected&#8221;</em>. People are more likely to vote if they think other people will vote. The most beautiful part of social proof is that it is undetected &#8211; most people will deny that this is the case.</p>

<p>No-one know which fund to invest in, because most of them under-perform the index, and if the stock market really is a <a href="http://en.wikipedia.org/wiki/Random_walk_hypothesis">random walk</a>, then there is no sane way to invest. It is in exactly that type of ambiguous situation where people look to other people to decide how to react.</p>

<h2>Scarcity</h2>

<p>We want what we may not be able to have in the future, that&#8217;s the <a href="http://changingminds.org/principles/scarcity.htm">Scarcity Principle</a>. This is the <em>&#8220;Last chance&#8221;</em> to invest in this fund because it is <em>&#8220;likely to close very soon&#8221;</em>. Fear of losing out on something can be an extremely powerful motivator, and you see it every day when stores have end-of-line or closing-down sales, or when something is offer in &#8216;limited quantity&#8217;.</p>

<h2>Invest with your calculator, not your heart</h2>

<p>That email is an emotional appeal, not a rational one. Selling a new fund during a recession must be difficult, and there&#8217;s no reason to think this one is selling well. The language doesn&#8217;t promise anything concrete, so it doesn&#8217;t lie. It just influences. And that is good copy writing.</p>

<p>The seminal book on this topic is  <a href="http://www.amazon.com/gp/product/0205609996?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0205609996">Robert Cialdini&#8217;s &#8220;Influence&#8221;</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0205609996" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, which I highly recommend. It&#8217;s a New York Times best seller, and Fortune Magazine lists Influence in their &#8220;75 Smartest Business Books.&#8221; You see what I did there? :-)</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/4GbKdZ3lyYw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/social-psychology-in-sales-copy-good-copy-writing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/behaviour/social-psychology-in-sales-copy-good-copy-writing/</feedburner:origLink></item>
		<item>
		<title>Choosing a message queue for Python on Ubuntu on a VPS</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/xO-uPwO5HSE/</link>
		<comments>http://www.darkcoding.net/software/choosing-a-message-queue-for-python-on-ubuntu-on-a-vps/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 05:05:13 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gearman]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=539</guid>
		<description><![CDATA[More and more, my web apps need to run things in the background: Sending email, re-calculating values, fetching website thumbnails, etc. In short, I need a message queue in my toolbox.

Luckily for me, message queues are this years Hot New Thing, so there&#8217;s some good options. I looked at RabbitMQ, Gearman, Beanstalkd and StompServer.


I&#8217;d like [...]]]></description>
			<content:encoded><![CDATA[<p>More and more, my web apps need to run things in the background: Sending email, re-calculating values, fetching website thumbnails, etc. In short, I need a message queue in my toolbox.</p>

<p>Luckily for me, message queues are this years <a href="http://simonwillison.net/tags/messagequeues/">Hot New Thing</a>, so there&#8217;s some good options. I looked at <a href="http://www.rabbitmq.com/">RabbitMQ</a>, <a href="http://gearman.org">Gearman</a>, <a href="http://xph.us/software/beanstalkd/">Beanstalkd</a> and <a href="http://stompserver.rubyforge.org/">StompServer</a>.</p>

<p><span id="more-539"></span>
I&#8217;d like the message queue to play nice with Python, with Ubuntu, and take almost no memory, as I&#8217;m on a <a href="http://linode.com">Virtual Private Server</a>, and I&#8217;d like it to stay up forever. I want small and solid.</p>

<h2>Summary</h2>

<table border="1" cellpadding="2">
<tr>
  <td></td>
  <th>RabbitMQ</th>
  <th>Gearman</th>
  <th>Beanstalkd</th>
  <th>StompServer</th>
</tr>

<tr>
 <th>Language</th>
 <td>Erlang</td>
 <td>C</td>
 <td>C</td>
 <td>Ruby</td>
</tr>

<tr>
 <th>In Ubuntu?</th>
 <td>Yes: rabbitmq-server</td>
 <td>Yes: gearman-job-server</td>
 <td>No</td>
 <td>No, it&#8217;s a Ruby gem</td>
</tr>

<tr>
 <th>Python lib</th>
 <td>amqplib</td>
 <td>gearman</td>
 <td>pybeanstalk</td>
 <td>stomp-py</td>
</tr>

<tr>
 <th>In PyPI?</th>
 <td>Yes</td>
 <td>Yes</td>
 <td>No</td>
 <td>No</td>
</tr>

<tr>
  <th>Memory</th>
  <td>9Mb</td>
  <td>1.4Mb</td>
  <td>0.5Mb</td>
  <td>7Mb</td>
</tr>

<tr>
 <th>Protocol</th>
 <td>AMQP</td>
 <td>Custom</td>
 <td>Custom</td>
 <td>STOMP</td>
</tr>

<tr>
 <th>License</th>
 <td>MPL</td>
 <td>BSD</td>
 <td>GPL</td>
 <td>MIT</td>
</tr>

</table>

<p>Memory size is the resident set size, obtained like so: <code>ps -Ao pid,rsz,args | grep &lt;name&gt;</code>. If there is a better way of estimating memory please let me know in the comments.</p>

<h2>RabbitMQ</h2>

<p>An all-singing all-dancing &#8220;complete and highly reliable Enterprise Messaging system&#8221;. With language like that you&#8217;d expect horrible bloat and per-cpu licensing, but happily that&#8217;s not the case. It&#8217;s straightforward to setup and relatively lean.</p>

<p>The protocol, <a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol">AMQP</a>, comes from the financial world, and is intended to replace Tibco&#8217;s RendezVous, the backbone of most investment banks. There&#8217;s lots of documentation, lots of users, a healthy ecosystem, and it looks good on your CV.<br />
I tried RabbitMQ first, and liked it so much I almost stopped my evaluation right there and deployed it.</p>

<p>The best tutorial for using it from Python is here: <a href="http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/">Rabbits and Warrens</a></p>

<h4>Publisher</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5391');">Quick Code</a></p></p>

<div id="quickcode5391" class="quickcode"><code><br />
import sys<br />
import time<br />
&nbsp;<br />
from amqplib import client_0_8 as amqp<br />
&nbsp;<br />
conn = amqp.Connection(host=&quot;localhost:5672&quot;, userid=&quot;guest&quot;, password=&quot;guest&quot;, virtual_host=&quot;/&quot;, insist=False)<br />
chan = conn.channel()<br />
&nbsp;<br />
i = 0<br />
while 1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;msg = amqp.Message(&#039;Message %d&#039; % i)<br />
&nbsp;&nbsp;&nbsp;&nbsp;msg.properties[&quot;delivery_mode&quot;] = 2<br />
&nbsp;&nbsp;&nbsp;&nbsp;chan.basic_publish(msg,exchange=&quot;sorting_room&quot;,routing_key=&quot;testke y&quot;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;i += 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(1)<br />
&nbsp;<br />
chan.close()<br />
conn.close()<br />
</code></div>

<h4>Consumer</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5392');">Quick Code</a></p></p>

<div id="quickcode5392" class="quickcode"><code><br />
from amqplib import client_0_8 as amqp<br />
&nbsp;<br />
conn = amqp.Connection(host=&quot;localhost:5672&quot;, userid=&quot;guest&quot;, password=&quot;guest&quot;, virtual_host=&quot;/&quot;, insist=False)<br />
chan = conn.channel()<br />
&nbsp;<br />
chan.queue_declare(queue=&quot;po_box&quot;, durable=True, exclusive=False, auto_delete=False)<br />
chan.exchange_declare(exchange=&quot;sorting_room&quot;, type=&quot;direct&quot;, durable=True, auto_delete=False,)<br />
&nbsp;<br />
chan.queue_bind(queue=&quot;po_box&quot;, exchange=&quot;sorting_room&quot;, routing_key=&quot;testkey&quot;)<br />
&nbsp;<br />
def recv_callback(msg):<br />
&nbsp;&nbsp;&nbsp;&nbsp;print msg.body<br />
&nbsp;<br />
chan.basic_consume(queue=&#039;po_box&#039;, no_ack=True, callback=recv_callback, consumer_tag=&quot;testtag&quot;)<br />
&nbsp;<br />
while True:<br />
&nbsp;&nbsp;&nbsp;&nbsp;chan.wait()<br />
&nbsp;<br />
#chan.basic_cancel(&quot;testtag&quot;)<br />
#chan.close()<br />
#conn.close()<br />
</code></div>

<h2>Gearman</h2>

<p>Gearman is a system to farm out work to other machines, dispatching function calls to machines that are better suited to do work, to do work in parallel, to load balance lots of function calls, or to call functions between languages.</p>

<p>Developed by <a href="http://www.danga.com/">Danga Interactive</a> (essentially Brad Fitzpatrick, who brought us Memcached and Perlbal). Used by LiveJournal, Digg and Yahoo.</p>

<p><em>Ubuntu users:</em> Make sure you install package <code>gearman-job-server</code>, which is the newer leaner C version of Gearman. Don&#8217;t install gearman-server, that is the old Perl version. Also install package <code>gearman-tools</code> to get the command line tool.</p>

<h4>Client</h4>

<div class="quickcodenoclick"><code><br />
import sys<br />
import time<br />
&nbsp;<br />
from gearman import GearmanClient, Task<br />
&nbsp;<br />
client = GearmanClient([&quot;127.0.0.1&quot;])<br />
&nbsp;<br />
i = 0<br />
while 1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;client.dispatch_background_task(&#039;speak&#039;, i)<br />
&nbsp;&nbsp;&nbsp;&nbsp;print &#039;Dispatched %d&#039; % i<br />
&nbsp;&nbsp;&nbsp;&nbsp;i += 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(1)<br />
</code></div>

<h4>Worker</h4>

<div class="quickcodenoclick"><code><br />
import time<br />
&nbsp;<br />
from gearman import GearmanWorker<br />
&nbsp;<br />
def speak(job):<br />
&nbsp;&nbsp;&nbsp;&nbsp;r = &#039;Hello %s&#039; % job.arg<br />
&nbsp;&nbsp;&nbsp;&nbsp;print r<br />
&nbsp;&nbsp;&nbsp;&nbsp;return r<br />
&nbsp;<br />
worker = GearmanWorker(&quot;[127.0.0.1]&quot;)<br />
worker.register_function(&#039;speak&#039;, speak, timeout=3)<br />
worker.work()<br />
</code></div>

<h2>Beanstalkd</h2>

<p>Beanstalkd is a fast, distributed, in-memory workqueue service. Its interface is generic, but was designed for use in reducing the latency of page views in high-volume web applications by running most time-consuming tasks asynchronously.</p>

<p>Developed for a very popular Facebook Application. The smallest memory footprint: after startup, connecting, sending a few messages, it&#8217;s resident memory size (rsz) was still only <strong>0.5 Mb</strong>!</p>

<p>To install the server:</p>

<ul>
<li>sudo apt-get install libevent-dev</li>
<li>wget http://xph.us/dist/beanstalkd/beanstalkd-1.3.tar.gz</li>
<li>tar xvzf beanstalkd-1.3.tar.gz</li>
<li>./configure</li>
<li>make (there&#8217;s no install step, it just generates the file &#8216;beanstalkd&#8217;)</li>
</ul>

<p>To install the Python library:</p>

<ul>
<li>wget http://pybeanstalk.googlecode.com/files/pybeanstalk-0.11.1.tar.gz</li>
<li>extract it</li>
<li>sudo python setup.py install</li>
</ul>

<p>There&#8217;s a good tutorial here: <a href="http://parand.com/say/index.php/2008/10/12/beanstalkd-python-basic-tutorial/">http://parand.com/say/index.php/2008/10/12/beanstalkd-python-basic-tut orial/</a></p>

<h4>Producer</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5395');">Quick Code</a></p></p>

<div id="quickcode5395" class="quickcode"><code><br />
import time<br />
&nbsp;<br />
from beanstalk import serverconn<br />
from beanstalk import job<br />
&nbsp;<br />
def producer_main(connection):<br />
&nbsp;&nbsp;&nbsp;&nbsp;i = 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;while True:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data = &#039;This is data to be consumed (%s)!&#039; % (i,)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print data<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data = job.Job(jid=i,data=data, conn=connection)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.Queue()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i += 1;<br />
&nbsp;<br />
connection = serverconn.ServerConn(&#039;localhost&#039;, 11300)<br />
#connection.job = job.Job<br />
producer_main(connection)<br />
</code></div>

<h4>Consumer</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5396');">Quick Code</a></p></p>

<div id="quickcode5396" class="quickcode"><code><br />
from beanstalk import serverconn<br />
from beanstalk import job<br />
&nbsp;<br />
def consumer_main(connection):<br />
&nbsp;&nbsp;&nbsp;&nbsp;while True:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = connection.reserve()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#039;got work: %s&#039; % j.data<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j.Finish()<br />
&nbsp;<br />
connection = serverconn.ServerConn(&#039;localhost&#039;, 11300)<br />
connection.job = job.Job<br />
consumer_main(connection)<br />
</code></div>

<h2>StompServer</h2>

<p>StompServer is a lightweight pure Ruby <a href="http://en.wikipedia.org/wiki/Streaming_Text_Orientated_Messaging_Protocol">STOMP</a> server. </p>

<p>To install the server on Ubuntu:</p>

<ul>
<li>sudo apt-get install ruby-dev rubygems</li>
<li>sudo gem install stompserver</li>
</ul>

<p>To install the Python library:</p>

<ul>
<li>wget http://stomppy.googlecode.com/files/stomp.py-2.0.1.tar.gz</li>
<li>extract it</li>
<li>sudo python setup.py install</li>
</ul>

<p>There&#8217;s a good Python / Stompserver tutorial here: <a href="http://morethanseven.net/2008/09/14/using-python-and-stompserver-get-started-message-q/">http://morethanseven.net/2008/09/14/using-python-and-stompserver-get-s tarted-message-q/</a></p>

<h4>Sender</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5397');">Quick Code</a></p></p>

<div id="quickcode5397" class="quickcode"><code><br />
import time<br />
&nbsp;<br />
import stomp<br />
&nbsp;<br />
conn = stomp.Connection()<br />
conn.start()<br />
conn.connect()<br />
&nbsp;<br />
i = 0<br />
while 1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;conn.send(&#039;Message %d&#039; % i, destination=&#039;/queue/test&#039;)<br />
&nbsp;&nbsp;&nbsp;&nbsp;i += 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(1)<br />
&nbsp;<br />
conn.disconnect()<br />
</code></div>

<h4>Listener</h4>

<p><a class="quickcode" title="Code" href="javascript:toggleLayer('quickcode5398');">Quick Code</a></p></p>

<div id="quickcode5398" class="quickcode"><code><br />
import time<br />
import sys<br />
&nbsp;<br />
import stomp<br />
&nbsp;<br />
class MyListener(object):<br />
&nbsp;&nbsp;&nbsp;&nbsp;def on_error(self, headers, message):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#039;received an error %s&#039; % message<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;def on_message(self, headers, message):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#039;received a message %s&#039; % message<br />
&nbsp;<br />
conn = stomp.Connection()<br />
conn.set_listener(&#039;&#039;, MyListener())<br />
conn.start()<br />
conn.connect()<br />
&nbsp;<br />
conn.subscribe(destination=&#039;/queue/test&#039;, ack=&#039;auto&#039;)<br />
&nbsp;<br />
while 1:<br />
&nbsp;&nbsp;&nbsp;&nbsp;time.sleep(2)<br />
</code></div>

<h2>Results and Conclusions</h2>

<p>I&#8217;d be happy working with any of these four. All four were easy to setup, fast, decent in memory consumption, and had good Python libraries.</p>

<p>RabbitMQ has the most mindshare (it is the only one which registers on <a href="http://www.google.com/trends?q=rabbitmq%2C+gearman%2C+beanstalkd%2C+stompserver&#038;ctab=0&#038;geo=all&#038;date=all&#038;sort=0">Google Trends</a>), but it took the most memory and is the most complex to use. It looks like a great product, but it&#8217;s Message Oriented Middleware, not an in-memory job queue, so it&#8217;s not what I&#8217;m looking for.</p>

<p>StompServer had the least documentation, and took several times more memory than Gearman and Beanstalkd. In seems the most immature project, but would probably be a good choice for someone working in Ruby.</p>

<p>Beanstalkd is great. I would like to see it in the Ubuntu repositories, and it&#8217;s Python lib in PyPI, but aside from that, I can&#8217;t fault it. I&#8217;m not choosing it, because Gearman is even better.</p>

<p>Gearman was designed for exactly the problem I have, takes almost no memory (1.4Mb), has a great pedigree (Danga), is widely deployed (LiveJournal, Digg, Yahoo), is in Ubuntu, has a Python library in PyPI, and someone helped me out on the #gearman IRC channel straight away. It even has queue persistence and clustering. So, <a href="http://twitter.com/jacobian/status/2761378698">Gearman it is</a>.</p>
<img src="http://feeds.feedburner.com/~r/darkcoding/~4/xO-uPwO5HSE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/choosing-a-message-queue-for-python-on-ubuntu-on-a-vps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/software/choosing-a-message-queue-for-python-on-ubuntu-on-a-vps/</feedburner:origLink></item>
		<item>
		<title>Quote of the day – monkeys</title>
		<link>http://feedproxy.google.com/~r/darkcoding/~3/NsPI-aDIxnk/</link>
		<comments>http://www.darkcoding.net/misc/quote-of-the-day-monkeys/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 19:09:11 +0000</pubDate>
		<dc:creator>Graham King</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[quote monkey business]]></category>

		<guid isPermaLink="false">http://www.darkcoding.net/?p=535</guid>
		<description><![CDATA[	In response to monkeys stealing his coffee beans, an Indian farmer observes: If you start shooting monkeys, you&#8217;ll spend the rest of your life shooting monkeys.



	via  Bruce Eckel
 ]]></description>
			<content:encoded><![CDATA[	<p><blockquote>In response to monkeys stealing his coffee beans, an Indian farmer observes: <em>If you start shooting monkeys, you&#8217;ll spend the rest of your life shooting monkeys.</em></blockquote></p>



	<p>via <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=264047"> Bruce Eckel</a></p>
 <img src="http://feeds.feedburner.com/~r/darkcoding/~4/NsPI-aDIxnk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/misc/quote-of-the-day-monkeys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.darkcoding.net/misc/quote-of-the-day-monkeys/</feedburner:origLink></item>
	</channel>
</rss>
