<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Graham King</title>
	<atom:link href="http://www.darkcoding.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.darkcoding.net</link>
	<description>Solvitas perambulum</description>
	<lastBuildDate>Fri, 03 May 2013 22:04:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>We are all polyglots</title>
		<link>http://www.darkcoding.net/software/we-are-all-polyglots/</link>
		<comments>http://www.darkcoding.net/software/we-are-all-polyglots/#comments</comments>
		<pubDate>Thu, 02 May 2013 16:24:11 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1849</guid>
		<description><![CDATA[I used to know two programming languages at any one time; what I called a serious language and a what I called a scripting language. My initial serious language was C, my scripting language was Perl. The serious language was for client work, it paid the bills. The scripting language was for tools and toys [...]]]></description>
			<content:encoded><![CDATA[<p>I used to know two programming languages at any one time; what I called a <em>serious</em> language and a what I called a <em>scripting</em> language. My initial <em>serious</em> language was <strong>C</strong>, my <em>scripting</em> language was <strong>Perl</strong>. The serious language was for client work, it paid the bills. The scripting language was for tools and toys (which is why many early web-apps were Perl CGI scripts).</p>

<p>We&#8217;ve been replacing C as our serious language since the 70s. C++ mostly succeeded, and became the official language of Microsoft Windows. Objective-C got a solid niche when Apple chose it for OSX, and later iOS. Java, became the serious language of web apps, and is now the language of Android. The two recent exciting developments here are <a href="http://www.darkcoding.net/software/go-lang-after-four-months/">Go</a> and <a href="http://www.darkcoding.net/software/rust-what-i-learnt-so-far/">Rust</a>.</p>

<p>In scripting-language world, Perl was largely replaced by Python and Ruby, and for web-app work by PHP.</p>

<p>So by now my <em>serious</em> language was <strong>Java</strong>, and my <em>scripting</em> language <strong>Python</strong>. But then three interesting things happened.</p>

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

<p>One, everyone had to learn Javascript. Clearly this wasn&#8217;t going to be my serious language, because it was client-side only, but it wasn&#8217;t really a scripting language either. So now I have to know three languages at once.</p>

<p>Two, Rails and Django came along and blew my precious artificial distinction all to hell.</p>

<p><em>Serious</em> work was being done in <em>scripting</em> languages. In retrospect, serious work was being done in PHP on the web for a while before that (Yahoo, Flickr, etc), but the web-only nature of PHP made it easier to avoid noticing. Later, Node.js allowed us to do server-side programming (previously a serious language only space) in Javascript!</p>

<p>The two recent serious-language choices I mentioned earlier, Go and Rust, both make good scripting languages too. The distinction is completely gone.</p>

<p>Three, mobile. Java for Android, or Objective-C for iOS. Soon Javascript for Firefox OS.</p>

<p>Today, in a single day I will get paid to write code in <strong>Python</strong>, <strong>Javascript</strong>, and <strong>Go</strong>. In the evening I will write <strong>Java</strong> (Android) and recently <strong>Rust</strong>. And talking to friends and colleagues, that is by no means unusual. Today, we are all polyglots.</p>

<p>There&#8217;s always more to learn than I have time for. It makes my brain hurt sometimes. But in the words of <a href="http://www.darkcoding.net/society/ward-cunningham-quotes/">Ward Cunningham</a>, I am excited to go down the stairs because there is a lot more to it than I even knew and I learned it last night and I am going to go apply it and in another week I will be an expert. And you can do it too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/we-are-all-polyglots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rust: What I learnt so far</title>
		<link>http://www.darkcoding.net/software/rust-what-i-learnt-so-far/</link>
		<comments>http://www.darkcoding.net/software/rust-what-i-learnt-so-far/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 21:58:13 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1796</guid>
		<description><![CDATA[Rust is an open-source programming language being developed mostly by Mozilla. It&#8217;s goal is the type of applications currently written in C++ (such as Firefox). Details at the Rust Wikipedia page. I&#8217;ve been learning bits of it the past few days, and whilst Rust is still rough around the edges there&#8217;s a lot to enjoy. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rust-lang.org/" target="_blank" class="external">Rust</a> is an open-source programming language being developed mostly by Mozilla. It&#8217;s goal is the type of applications currently written in C++ (such as Firefox). Details at the <a href="https://en.wikipedia.org/wiki/Rust_%28programming_language%29" target="_blank" class="external">Rust Wikipedia page</a>.</p>

<p>I&#8217;ve been learning bits of it the past few days, and whilst Rust is still rough around the edges there&#8217;s a lot to enjoy. Rust is only at v0.7pre and changing daily, so you may have to adjust some of the code here.</p>

<p>Rust is a <strong>big</strong> language, and unless you come from C++ it will probably make your head hurt. In a good way :-)</p>

<p>The two most helpful introductions I have found so far are:</p>

<ul>
<li><a href="http://static.rust-lang.org/doc/tutorial.html" target="_blank" class="external">Official Rust tutorial</a> </li>
<li><a href="http://www.rustforrubyists.com/" target="_blank" class="external">Rust for Rubyists</a> book. </li>
</ul>

<p>I&#8217;d encourage you to run through both of those, starting with Rust for Rubyists. When you get stuck reading one of them (and you will), switch back here.</p>

<p>Contents:</p>

<ul>
<li><a href="#install">Install</a></li>
<li><a href="#hello_world">Hello world</a>: Creating functions. Compiling.</li>
<li><a href="#ask_your_name">Ask your name</a>: Declaring variables. Using a macro.</li>
<li><a href="#memory">Memory management</a>: Best of three</li>
<li><a href="#looping">Looping</a>: Loops, closures, traits, functional style.</li>
<li><a href="#read_a_file">Read a file</a>: I/O, error handling, generics, pattern matching.</li>
<li><a href="#connect_to_a_socket">Connect to a socket</a>: Networking, non-blocking I/O, using libraries.</li>
<li><a href="#objects">Objects</a>: struct + impl</li>
<li><a href="#sqlite3">sqlite3</a>: Building and using a third-party module.</li>
<li><a href="#mutable_pointers">Mutable pointers</a>: Changing a variable is different from changing the data it points at.</li>
<li><a href="#files">Multiple files</a>: Splitting a project over multiple .rs files.</li>
</ul>

<h2><a id="install"></a>Install</h2>

<p>At time of writing Rust is v0.7pre:</p>

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

<pre><code>git clone git://github.com/mozilla/rust.git
cd rust
git checkout incoming
./configure
make
sudo make install
</code></pre>

<p>The <code>make</code> step will take a while and heat up your machine nicely.</p>

<h2><a id="hello_world"></a>Hello world</h2>

<script src="https://gist.github.com/grahamking/5468191.js"></script>

<p>So far so normal. We have curly braces, semi-colons at end-of-line, <code>fn</code> to declare a function, and <code>main</code> as the entry point of executables. Let&#8217;s run it.</p>

<p>Compile: <code>rustc hello_world.rs</code>. This makes a regular binary, <code>hello_world</code></p>

<p>Run: <code>./hello_world</code>.</p>

<p>Instead of the compile / run cycle you can: <code>rust run hello_world.rs</code>.</p>

<p>You can even make your rust file a shell script by adding as the first line:</p>

<pre><code>#!/usr/local/bin/rust run
</code></pre>

<p>(don&#8217;t forget to <code>chmod +x hello_world.rs</code>).</p>

<h2><a id="ask_your_name"></a>Ask your name</h2>

<script src="https://gist.github.com/grahamking/5468331.js"></script>

<p>You declare a variable with <code>let</code>, and optionally give a type. The compiler will try and infer the type, and complain if it can&#8217;t. Here&#8217;s some variables:</p>

<pre><code>let x;
x = 10;   // Compiler will infer  x: int
let pi: float;
let name: ~str;
</code></pre>

<p>The built-in types are what you would expect, plus some: <a href="http://static.rust-lang.org/doc/rust.html#types" target="_blank" class="external">List of Rust built-in types</a></p>

<p>The <code>~</code> is (briefly) explained in the next section. For now <code>~str</code> is just how you declare a string on the heap. You use it for string literals too, as in <code>let name = ~"Bob"</code>.</p>

<p>All variables are <em>immutable by default</em>, you can&#8217;t change their value once set.</p>

<pre><code>let x;
x = 10;
x = 42;  // Compile error
</code></pre>

<p>You allow yourself to change a variable by prefixing it&#8217;s name with <code>mut</code>:</p>

<pre><code>let mut x;
x = 10;
x = 32;  // All good
</code></pre>

<p>Each .rs file is a module. The line <code>io::stdin().read_line()</code> is using an <code>io.rs</code> file from the <a href="http://static.rust-lang.org/doc/core/index.html" target="_blank" class="external">core library</a>. Modules are grouped into <em>crates</em> (libraries) and on unix compile to a standard <code>.so</code> file. The <code>core</code> library, which contains the <code>io</code> module, is imported by default, which is why you don&#8217;t see an import statement here.</p>

<p>Modules are explained in the tutorial under <a href="http://static.rust-lang.org/doc/tutorial.html#modules-and-crates" target="_blank" class="external">Modules and crates</a>.</p>

<p>The final new part in this section is <code>fmt!</code>. The <code>!</code> means it&#8217;s a macro, i.e. it&#8217;s expanded by the compiler. <code>fmt</code> is a very useful macro, because it does the <code>printf</code> style formatting with all the <code>%s</code>, <code>%d</code>, etc that you would expect.</p>

<p>The <em>most</em> useful part is <code>%?</code> which formats anything. You will probably use <code>println(fmt!("%?", thing))</code> quite a lot. Unlike C&#8217;s printf, <code>fmt</code> is type checked at compile time.</p>

<h2><a id="memory"></a>Memory management</h2>

<p>The hardest part of Rust for me to understand is the memory management, and the three pointer types which declare it. Rust wants you to tell it how the memory for each pointer should be managed and checked.</p>

<p><code>~</code> and <code>@</code> both mean you have a pointer, you are using heap memory. Without one of those you have a normal local variable (stack memory).</p>

<p><code>@</code> means several places can point at that memory, and you want Rust to track who points there and garbage collect the memory. It&#8217;s like pointers in Go, and what happens internally in Java and Python.</p>

<p><code>~</code> means one place owns that memory. For garbage collection Rust only needs to track who the current owner is, and whether that owner is still in scope. Other pointers can refer to this memory, by &#8220;borrowing&#8221; it (using the third type of pointer, <code>&amp;</code>), but only as long as the owner is in scope.</p>

<script src="https://gist.github.com/grahamking/5470333.js"></script>

<p>The last line in that example <code>println(name)</code> won&#8217;t compile because by then you have given away the unique access to that piece of memory, to <code>other</code>. Change all the <code>~</code> to <code>@</code> and it works.</p>

<p>This is the most exciting part of Rust for me, because I hope that once I get it, it will improve my programming in other languages too.</p>

<p>Because <code>@</code> is the type of pointer you&#8217;re probably familiar with, right now I bet you&#8217;re thinking &#8220;I&#8217;ll just use @&#8221; everywhere&#8221;. But you can&#8217;t, because the standard library will return unique pointers (<code>~</code>), and you can&#8217;t just put those into managed pointers <code>@</code>.</p>

<p>You can however put either owned or managed pointers into the third type, the borrowed pointer, written <code>&amp;</code>. Don&#8217;t worry, the compiler will tell you when to use one of those :-) In general the compiler is very good at telling you when you have to wrong type of pointer, so I just do what the compiler tells me and move on.</p>

<p>There&#8217;s lots of other good stuff in Rust, so don&#8217;t get too caught up in the memory management, at least at first. Onwards!</p>

<h2><a id="looping"></a>Looping</h2>

<script src="https://gist.github.com/grahamking/5468729.js"></script>

<p>The loop syntax will look familiar to Ruby programmers. The two important features here are traits and closures.</p>

<p>Firstly, integers don&#8217;t have a method called <code>times</code> and vectors (<code>[1,2,3]</code> is a vector in Rust, meaning an array) don&#8217;t have a method called <code>each</code>. Those are added to the type by a trait, which I think is somewhere between an interface and a mixin. That can make it tricky to find which methods you can call on a given type.</p>

<p>Second, loops 1 and 2, and loops 3 and 4 are the same. <code>for</code> is just a nicer way of writing the loop beneath it.</p>

<p>Look at the <a href="http://static.rust-lang.org/doc/core/iter.html#trait-times" target="_blank" class="external">documentation for times</a> to see what I mean. See how it&#8217;s a method which takes a function? The first parameter will be familiar to Python programmers, it&#8217;s the object the method is called on. Ignore that, and look at the second parameter, which is a function with no arguments, returning a boolean.</p>

<p>Closures are well explained near the end of the <a href="http://www.rustforrubyists.com/book/chapter-06.html" target="_blank" class="external">Rust for Rubyists, Fizzbuzz chapter</a>. They are essentially an anonymous function, declared by listing their parameters within <code>||</code>, and their code in a block afterwards.</p>

<p>You give a closure to your iterator, and it calls it once each time through the loop. This will be familiar if you know Javascript.</p>

<p>The <code>bool</code> that the closure returns tells the iterator whether to keep running or not. With the <code>for</code> sugar, true is assumed unless you call <code>break</code>. With the un-sugared version you have to explicitly say <code>true</code>.</p>

<p>Finally (yes there&#8217;s a lot going on in Rust) notice that it just says <code>true</code>, not <code>return true;</code>. A block in Rust is an expression (as opposed to a statement), so it can evaluate to something. If you end your block with a semi-colon, it doesn&#8217;t have a value. If you don&#8217;t end with a semi-colon, it has the last thing you wrote. So you can set a variable like this:</p>

<pre><code>let has_sanity = 
    if 1 == 1 { true }
    else { false }
</code></pre>

<p>By just saying <code>true</code> at the end of the closure you give to the iterator, the whole block evaluates to true, and the loop keeps going.</p>

<p>This is clearly explained in the tutorial&#8217;s <a href="http://static.rust-lang.org/doc/tutorial.html#syntax-basics" target="_blank" class="external">Syntax basics</a> section, in <em>Expressions and semicolons</em>.</p>

<h2><a id="read_a_file"></a>Read a file</h2>

<script src="https://gist.github.com/grahamking/5468983.js"></script>

<p>The loading itself is straightforward: Turn the string filename into a <code>Path</code> object (with <code>path::Path</code>), build a <code>Reader</code> object (with <code>io:file_reader</code>) and return all the lines (with <code>file.read_lines()</code>).</p>

<p>The interesting thing here is the Result object which wraps multiple returns, and is how error handling in Rust is often done.</p>

<p><a href="http://static.rust-lang.org/doc/core/result.html#enum-result" target="_blank" class="external">Result</a> is a disjoint enumeration, containing either the success result (a <code>Reader</code> here), or an error (here a string). Many Rust methods return a Result, and Rust&#8217;s <a href="http://static.rust-lang.org/doc/tutorial.html#control-structures" target="_blank" class="external">pattern matching</a> is often used to check for errors.</p>

<p>A more &#8220;Rustic&#8221; way of writing this uses <a href="http://static.rust-lang.org/doc/tutorial.html#control-structures" target="_blank" class="external">Pattern matching</a>:</p>

<script src="https://gist.github.com/grahamking/5469290.js"></script>

<p><code>match</code> is similar to <code>switch</code>. The Result enum contains two variants: <code>Ok</code> and <code>Err</code>.</p>

<p>Oh, and the angle brackets in <code>Result&lt;@Reader, ~str&gt;</code>? Yes, Rust has <a href="http://static.rust-lang.org/doc/tutorial.html#generics" target="_blank" class="external">generics</a>. Hopefully you know them from Java or C#. They&#8217;re a way of making static typing more flexible, so that you can for example define a Map which works on any type, but is still type checked by the compiler. The types in the map are specified when you create an instance of it.</p>

<h2><a id="connect_to_a_socket"></a>Connect to a socket</h2>

<script src="https://gist.github.com/grahamking/5469829.js"></script>

<p>First we declare that we&#8217;re using the <code>std</code> external crate (meaning library). Until now we were only using <code>core</code>, which is imported by default.</p>

<p>Then we declare which parts of <code>std</code> we <code>use</code>. We don&#8217;t have to do this, but it allows us to avoid prefixing everything with <code>std::</code>.</p>

<p>We turn the IP address we&#8217;re connecting to (US weather service) into an internal representation, <code>connect</code> to port 80, wrap the socket in a <code>Reader</code> (at the <code>socket_buf</code> call) and finally in the last line read everything and return it (<code>sock.read_lines()</code>).</p>

<p>Of particular interest is this line:</p>

<pre><code>let iotask = uv::global_loop::get();
</code></pre>

<p>All IO in Rust is non-blocking, so that Rust can be highly concurrent using <a href="http://static.rust-lang.org/doc/tutorial-tasks.html" target="_blank" class="external">tasks</a>, lightweight threads similar to Go&#8217;s go-routines, Python&#8217;s gevent greenlets, or node.js. It uses <a href="http://nikhilm.github.io/uvbook/introduction.html" target="_blank" class="external">libuv</a> for this.</p>

<p>Here we say to run the blocking I/O task on libuv&#8217;s global loop. Yeah, I don&#8217;t know what that means either. Let&#8217;s move on.</p>

<h2><a id="objects"></a>Objects</h2>

<p>Objects in Rust are a <code>struct</code> to hold the data, plus some functions grouped in an <code>impl</code> block.</p>

<script src="https://gist.github.com/grahamking/5470970.js"></script>

<p>The first function <code>new</code> is static. That&#8217;s the preferred way to define constructors. It doesn&#8217;t have to be called <code>new</code>, and constructors are optional (we&#8217;re just making a struct).</p>

<p>The second and third functions are the methods. They take the object itself as their first argument <code>&amp;self</code>, just like in Python.</p>

<p>In <code>new</code> and <code>when</code> we&#8217;re using a functional style, without explicit <code>return</code> statements. The other item of note is that you cast with <code>as</code>. We&#8217;re casting an <code>i32</code> (32-bit int) coming from <code>time::now().tm_year</code> to a regular <code>int</code> (size machine dependant).</p>

<h2><a id="sqlite3"></a>Use an external module &#8211; sqlite3</h2>

<p>Let&#8217;s build and use an external module &#8211; a sqlite wrapper. Rust has a package manager called <code>rustpkg</code> which will install modules for you, but for now we&#8217;ll do it manually. Make sure you have SQLite 3 development files, package <code>libsqlite3-dev</code> in Ubuntu / Debian.</p>

<pre><code>git clone git://github.com/linuxfood/rustsqlite.git
cd rustsqlite
rustc sqlite.rc
</code></pre>

<p>Compiling it will give you <code>libsqlite-&lt;something&gt;.so</code>. The <code>.rc</code> is just a convention for <code>.rs</code> files which contain libraries, and that convention may change soon. Anyway, let&#8217;s use that library:</p>

<script src="https://gist.github.com/grahamking/5470148.js"></script>

<p>First we declare usage of the <code>sqlite</code> library, just like we did for <code>std</code> previously.</p>

<p>In the <code>let database =</code> part we&#8217;re using pattern matching, and the functional style evaluation. In the Ok case, we just wrote <code>db</code>, so db gets returned. This behaves like <code>database = db</code>.</p>

<p>At line 12 we set <code>result</code> (a <code>Result</code>) to be mutable, because we re-use it at line 16.</p>

<p>There are more example of using sqlite in the test suite at the bottom of <a href="https://github.com/linuxfood/rustsqlite/blob/master/sqlite.rc" target="_blank" class="external">rustsqlite&#8217;s sqlite.rc</a>.</p>

<p>To compile it you need to tell <code>rustc</code> where to find the library you are using. Assuming you copied <code>libsqlite-&lt;something&gt;.so</code> into the current directory, you just:</p>

<pre><code>rustc -L . use_sqlite.rs
</code></pre>

<h2><a id="mutable_pointers"></a>Mutable pointers</h2>

<p>There&#8217;s one more bit related to memory management that might trip you up. Everything in Rust is immutable by default (constant). To make a variable mutable, you simply say <code>mut</code> in front of it.</p>

<pre><code>let mut x: int;
</code></pre>

<p>Easy enough, right? The trick is that in the case of a managed (<code>@</code>) pointer, there are two things which can change &#8211; the data the pointer points to, or the pointer itself. This is also the case for unique pointers, but unique pointer contents inherit the mutability of the variable pointing to them. Managed pointers do not.</p>

<script src="https://gist.github.com/grahamking/5470560.js"></script>

<h2><a id="files"></a>Multiple files</h2>

<p>Each file is a module, and several files can make up a binary or library. This is module <code>m2</code>:</p>

<p><strong>m2.rs</strong></p>

<script src="https://gist.github.com/grahamking/5484823.js"></script>

<p>Names (functions, structs, etc) are private by default. Adding <code>pub</code> makes them public, accessible from other modules.</p>

<p><strong>m1.rs</strong></p>

<script src="https://gist.github.com/grahamking/5484836.js"></script>

<p>You reference other modules with <code>mod &lt;name&gt;</code>. By default module x is stored in file x.rs. Directories create a hierarchy of modules.</p>

<p>To compile: <code>rustc m1.rs</code>  The compiler will include <code>m2.rs</code> automatically.</p>

<p>That&#8217;s everything I&#8217;ve learnt so far! More soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/rust-what-i-learnt-so-far/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PyCon 2013: My two favorite talks</title>
		<link>http://www.darkcoding.net/software/pycon-2013-my-favorite-talks/</link>
		<comments>http://www.darkcoding.net/software/pycon-2013-my-favorite-talks/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 15:41:59 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[pycon]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1785</guid>
		<description><![CDATA[PyCon is an annual gathering of Python programmers. All the talks are recorded and distributed freely on the web. My two favorite talks were: EduPsych Theory for Python Hackers: A Whirlwind Overview: How learning works, in 30 minutes. The speaker can be difficult to understand, but stick with it. I learnt so much, and took [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://us.pycon.org/2013/" target="_blank" class="external">PyCon</a> is an annual gathering of Python programmers. All the talks are recorded and distributed freely on the web. My two favorite talks were:</p>

<ul>
<li><p><a href="http://pyvideo.org/video/1783/edupsych-theory-for-python-hackers-a-whirlwind-o" target="_blank" class="external">EduPsych Theory for Python Hackers: A Whirlwind Overview</a>: How learning works, in 30 minutes. The speaker can be difficult to understand, but stick with it. I learnt so much, and took about 18 pages of notes. Here&#8217;s <a href="http://blog.melchua.com/2013/03/18/edupsych-theory-for-python-hackers-slides-and-an-extended-qa-with-further-readings/" target="_blank" class="external">her blog post about the talk</a>. To me, this was <strong>the best talk of PyCon 2013</strong>.</p></li>
<li><p><a href="http://pyvideo.org/video/1778/crypto-101" target="_blank" class="external">Crypto 101</a>: After this you&#8217;ll finally understand Crypto. He builds from a basic block cipher, to a stream cipher, then covers hashes (and why they aren&#8217;t secure), key exchange, message authentication codes, etc. Really interesting and easy to follow.</p></li>
</ul>

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

<p>A few other interesting or noteworthy talks I attended:</p>

<ul>
<li><p><a href="http://pyvideo.org/video/1667/keynote-1" target="_blank" class="external">Guido&#8217;s keynote</a>. Python 3.4 will have non-blocking co-routines, very similar to Go&#8217;s go-routines, and inspired by C#&#8217;s <code>async</code> / <code>await</code> operators. The syntax is a little awkward for three reasons: because it&#8217;s being added later (versus Go it&#8217;s there from the start), because Guido doesn&#8217;t want to add any more keywords (so it&#8217;s <code>yield from my_coroutine()</code>), and because it&#8217;s partly based on Twisted. Still cool though.</p></li>
<li><p><a href="http://pyvideo.org/video/1700/making-disqus-realtime-0" target="_blank" class="external">Making DISQUS Realtime</a>: Interesting to see the path DISQUS took to get real-time comments in their widget. The key component is nginx&#8217;s <code>nginx_push_stream</code>.</p></li>
<li><p><a href="http://pyvideo.org/video/1764/beyond-passwords-secure-authentication-with-mozi-0" target="_blank" class="external">Beyond Passwords: Secure Authentication with Mozilla Persona</a>: Nice demo of Persona / BrowserID by a Mozilla evangelist.</p></li>
<li><p><a href="http://pyvideo.org/video/1787/porting-django-apps-to-python-3" target="_blank" class="external">Porting Django apps to Python 3</a> by Jacob Kaplan-Moss. Nicely summarizes the state of Django on Python 3, and gives advice on upgrading apps to work on both 2 and 3.</p></li>
</ul>

<p>Here are <a href="http://pyvideo.org/category/33/pycon-us-2013" target="_blank" class="external">all the PyCon 2013 talks</a>. Are there any great talks that I missed? Please let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/pycon-2013-my-favorite-talks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chapter books for a three / four year old</title>
		<link>http://www.darkcoding.net/misc/chapter-books-for-a-three-four-year-old/</link>
		<comments>http://www.darkcoding.net/misc/chapter-books-for-a-three-four-year-old/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 22:32:12 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1732</guid>
		<description><![CDATA[Starting in summer 2012, when my son was 3.5, I started reading chapter books to him, a chapter or two a night. Before we started chapter books, it was always easy to find good books to read to them (from board books upwards). Now though, I struggled finding good chapter books for this age group. [...]]]></description>
			<content:encoded><![CDATA[<p>Starting in summer 2012, when my son was 3.5, I started reading chapter books to him, a chapter or two a night. Before we started chapter books, it was always easy to find good books to read to them (from board books upwards). Now though, I struggled finding good chapter books for this age group.</p>

<p>I&#8217;ve collected a list of the ones we tried, in order, with notes if appropriate. I&#8217;m linking all the books to Amazon to be clear which book it was, but we got most from our local library.</p>

<p><a href="http://www.amazon.com/gp/product/B000N750GY/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B000N750GY&#038;linkCode=as2&#038;tag=darkcoding-20">Jason&#8217;s Quest</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=B000N750GY" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; A lovely book to start with. A wonderful adventure, which never gets too frightening, or too hard to follow, and the good folks win in a good way.</p>

<p><a href="http://www.amazon.com/gp/product/0142410349/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0142410349&#038;linkCode=as2&#038;tag=darkcoding-20">Fantastic Mr. Fox</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0142410349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Might have been a little too frightening at the beginning, with the mean farmers trying to kill the fox. In retrospect I would have saved it till he was a few months older.</p>

<p><a href="http://www.amazon.com/gp/product/0316186465/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0316186465&#038;linkCode=as2&#038;tag=darkcoding-20">Mr. Popper&#8217;s Penguins</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0316186465" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>

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

<p>&#8211; He turned four around here</p>

<p>We tried Harry Potter, but aborted it after a few chapters. Some parts were too scary, but mainly it was too socially advanced. The story relies on understand relationships between people that were beyond a four year old.</p>

<p><a href="http://www.amazon.com/gp/product/0061124958/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0061124958&#038;linkCode=as2&#038;tag=darkcoding-20">Charlotte&#8217;s Web</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0061124958" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>

<p><a href="http://www.amazon.com/gp/product/0143106333/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0143106333&#038;linkCode=as2&#038;tag=darkcoding-20">Charlie and the Chocolate Factory</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0143106333" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; this was definitely a favorite. We watched the movie (the original, with Gene Wilder) the weekend after we finished the book.</p>

<p><a href="http://www.amazon.com/gp/product/0064400565/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0064400565&#038;linkCode=as2&#038;tag=darkcoding-20">Stuart Little</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0064400565" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; I found this one a bit boring, although we finished it and it seemed to keep his interest.</p>

<p><a href="http://www.amazon.com/gp/product/0142410357/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0142410357&#038;linkCode=as2&#038;tag=darkcoding-20">George&#8217;s Marvelous Medicine</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0142410357" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Short and really fun. Some laugh out loud moments.</p>

<p><a href="http://www.amazon.com/gp/product/0143106341/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0143106341&#038;linkCode=as2&#038;tag=darkcoding-20">James and the Giant Peach</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0143106341" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Strangely I don&#8217;t remember liking this one when I was a kid, but my son loved it. He particularly liked the evil aunts getting squished, and the insect characters are a lot of fun.</p>

<p><a href="http://www.amazon.com/gp/product/0316085278/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0316085278&#038;linkCode=as2&#038;tag=darkcoding-20">How to Train Your Dragon</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0316085278" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Clearly written for older kids (Harry Potter age), but he had no trouble following it, and it never got too scary. It has dragons and vikings and little kids saving their tribe.</p>

<p><a href="http://www.amazon.com/gp/product/0140309578/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0140309578&#038;linkCode=as2&#038;tag=darkcoding-20">Pippi Longstocking</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0140309578" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Who <em>doesn&#8217;t</em> love Pippi! I wished this one would have kept on going.</p>

<p>We tried How to be a Pirate, the sequel to How To Train Your Dragon, but aborted rapidly, it was too violent.</p>

<p><a href="http://www.amazon.com/gp/product/0061704121/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0061704121&#038;linkCode=as2&#038;tag=darkcoding-20">A Nest for Celeste: A Story About Art, Inspiration, and the Meaning of Home</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0061704121" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; I thought this would be too boring, but it turned out to be quite exciting. Fantastic pencil drawings too.</p>

<p>&#8211; From here on he was reading parts of these books himself during the day</p>

<p><a href="http://www.amazon.com/gp/product/1865085634/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1865085634&#038;linkCode=as2&#038;tag=darkcoding-20">The Big Big Big Book of Tashi</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=1865085634" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; also a definite favorite. We bought this one, and he has re-read it several times. Some parts are a little scary, but they always resolve nicely. Tashi defeats pretty much every fear a child could have &#8211; quite cathartic.</p>

<p><a href="http://www.amazon.com/gp/product/0440422280/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0440422280&#038;linkCode=as2&#038;tag=darkcoding-20">How to Save Your Tail</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0440422280" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; on the importance of cookies and story telling.</p>

<p><a href="http://www.amazon.com/gp/product/1741148332/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1741148332&#038;linkCode=as2&#038;tag=darkcoding-20">The 2nd Big Big Book of Tashi</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=1741148332" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; More of the same, Tashi is a clever fellow!</p>

<p><a href="http://www.amazon.com/gp/product/0385736614/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0385736614&#038;linkCode=as2&#038;tag=darkcoding-20">Toys Go Out</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0385736614" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; sweet and entertaining. We would have read this when he was younger if I&#8217;d known about it.</p>

<p><a href="http://www.amazon.com/gp/product/0375800662/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0375800662&#038;linkCode=as2&#038;tag=darkcoding-20">A Mouse Called Wolf</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0375800662" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; A mouse with a brilliant singing voice, and an old lady piano player. Lovely.</p>

<p><a href="http://www.amazon.com/gp/product/0547850794/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0547850794&#038;linkCode=as2&#038;tag=darkcoding-20">The Unicorn&#8217;s Tale (Nathaniel Fludd: Beastologist, Book 4)</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0547850794" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; I&#8217;ve no idea why we started with book 4, we should have started at 1. Oh well, it was engaging and exciting anyway.</p>

<p><a href="http://www.amazon.com/gp/product/1481824783/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1481824783&#038;linkCode=as2&#038;tag=darkcoding-20">My Father&#8217;s Dragon</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=1481824783" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Would also have read this when he was younger if I&#8217;d know. Still enjoyable at this age.</p>

<p><a href="http://www.amazon.com/gp/product/0547408455/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0547408455&#038;linkCode=as2&#038;tag=darkcoding-20">Flight of the Phoenix (Nathaniel Fludd, Beastologist, Book I)</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0547408455" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; We went back to book one to continue his adventures.</p>

<p><a href="http://www.amazon.com/gp/product/0486275590/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0486275590&#038;linkCode=as2&#038;tag=darkcoding-20">Treasure Island</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0486275590" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; Disappointing. I had fond memories from my Dad reading it to me in my youth, but I think it had grown in my mind. There&#8217;s not a whole lot of pirate type adventures here, and it hasn&#8217;t aged particularly well.</p>

<p><a href="http://www.amazon.com/gp/product/0064409422/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0064409422&#038;linkCode=as2&#038;tag=darkcoding-20">The Lion, the Witch and the Wardrobe</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0064409422" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> &#8211; we both loved this. Talking animals, a bad witch, swords and shields, and Father Christmas.</p>

<p><a href="http://www.amazon.com/gp/product/0061231134/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0061231134&#038;linkCode=as2&#038;tag=darkcoding-20">Prince Caspian</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0061231134" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
I&#8217;ll update this page as we read more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/misc/chapter-books-for-a-three-four-year-old/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google World</title>
		<link>http://www.darkcoding.net/society/google-world/</link>
		<comments>http://www.darkcoding.net/society/google-world/#comments</comments>
		<pubDate>Sat, 23 Feb 2013 04:54:09 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Society]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1770</guid>
		<description><![CDATA[First thing in the morning, I check my gmail on my Google Nexus 7 tablet, or my Nexus 4 phone, whichever is nearest. I have a conference call so I fire up my Chromebook. Google&#8217;s browser, Chrome, uses Google&#8217;s public DNS servers (8.8.8.8) and Google network&#8217;s protocol (SPDY), to connect to gmail. In the Google [...]]]></description>
			<content:encoded><![CDATA[<p>First thing in the morning, I check my gmail on my Google Nexus 7 tablet,
or my Nexus 4 phone, whichever is nearest. I have a conference call so I fire
up my Chromebook. Google&#8217;s browser, Chrome, uses Google&#8217;s public DNS
servers (8.8.8.8) and Google network&#8217;s protocol (SPDY), to connect to gmail.</p>

<p>In the Google Calendar invite, I click the Google Hangouts link and
video conference. I&#8217;m lucky to live in Kansas City, with it&#8217;s super-fast
Google Fiber internet connection. We update a Google Doc, stored on Google Drive,
with notes during the meeting.</p>

<p>I tell the team that the next version of our web app,
written in Go (Google&#8217;s server language) was just uploaded onto Google App Engine (their app hosting
platform). The client side is in Javascript, but we might update it to use
Dart (Google&#8217;s client-side language), when that&#8217;s ready.</p>

<p>We&#8217;ve already got Google Checkout payment integrated, which makes measuring
our Google Ads conversions with Google Analytics easy. We&#8217;re hoping to rank
highly in Google Search, or no-one will find us. We&#8217;ve just started promoting
it on our G+ page (we migrated from Blogger), and our Youtube demo video
seemed popular.</p>

<p>Who knows, if the product goes really well, Google might acquire us.</p>

<hr />

<p>It&#8217;s just a silly story. Move along. :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/society/google-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Keyword arguments in C</title>
		<link>http://www.darkcoding.net/software/keyword-arguments-in-c/</link>
		<comments>http://www.darkcoding.net/software/keyword-arguments-in-c/#comments</comments>
		<pubDate>Tue, 15 Jan 2013 05:03:49 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[c]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1746</guid>
		<description><![CDATA[This is valid C nowadays: my_func(.username="Bob", .is_admin=true); I found it in 21st Century C. It requires a macro and a structure, and relies on three features introduced in C99. #include &#60;stdio.h&#62; // printf #include &#60;stdbool.h&#62; // bool - there's a bool type now // Macro that turns the kwargs into an struct #define my_func(...) my_func_base(\ [...]]]></description>
			<content:encoded><![CDATA[<p>This is valid C nowadays:</p>

<pre><code>my_func(.username="Bob", .is_admin=true);
</code></pre>

<p>I found it in <a href="http://shop.oreilly.com/product/0636920025108.do" target="_blank" class="external">21st Century C</a>. It requires a macro and a structure, and relies on three features introduced in C99.</p>

<pre><code>#include &lt;stdio.h&gt;      // printf
#include &lt;stdbool.h&gt;    // bool - there's a bool type now

// Macro that turns the kwargs into an struct
#define my_func(...) my_func_base(\
    (struct user){.is_admin=false, __VA_ARGS__});

struct user {
    char *username;
    bool is_admin;
};

// The actual function - and yes there's single line comments too
void my_func_base(struct user u) {
    printf("Hello %s\n", u.username);
}

int main(int argc, char *argv[]) {
    my_func(.username="Bob", .is_admin=true);
}
</code></pre>

<p>The three new features introduced in <a href="http://en.wikipedia.org/wiki/C99" target="_blank" class="external">C99</a> that make this possible are:</p>

<ul>
<li><a href="http://www.drdobbs.com/the-new-c-compound-literals/184401404" target="_blank" class="external">Compound literals</a> which allow <code>my_user = (user) {"Bob", true}</code>.</li>
<li><a href="http://www.drdobbs.com/the-new-c-declarations-initializations/184401377" target="_blank" class="external">Designated initializers</a> which give us <code>struct user my_user = {.username="Test", .is_admin=true}</code></li>
<li><a href="http://en.wikipedia.org/wiki/Variadic_macro" target="_blank" class="external">Variadic macros</a> which allow <code>#define</code>&#8216;s to take <code>...</code> as a parameter and have it substituted wherever <code>__VA_ARGS__</code> appears in that macro.</li>
</ul>

<p>All the keyword arguments are optional, because compound literal rules state that any unspecified arguments are set to zero / null of the appropriate type.</p>

<p>We even have default arguments, like the <code>.is_admin=false</code> in the macro above, because designated initializer rules state that if the argument is repeated, the last argument wins.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/keyword-arguments-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How will you measure  your life? &#8211; book notes</title>
		<link>http://www.darkcoding.net/society/how-will-you-measure-your-life-book-notes/</link>
		<comments>http://www.darkcoding.net/society/how-will-you-measure-your-life-book-notes/#comments</comments>
		<pubDate>Mon, 31 Dec 2012 18:37:58 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Society]]></category>
		<category><![CDATA[book]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1734</guid>
		<description><![CDATA[How Will You Measure Your Life?, by Clayton M. Christensen is life advice for M.B.A. graduates. It dispenses valuable career, relationship, and ethics advice in business-school language. High-achieving individuals (he&#8217;s a Harvard business-school professor) often over-invest themselves in their career and under-invest themselves in their family, and regret this later in life. This book is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0062102419/ref=as_li_ss_tl?ie=UTF8&#038;tag=darkcoding-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0062102419">How Will You Measure Your Life?</a><img src="http://www.assoc-amazon.com/e/ir?t=darkcoding-20&#038;l=as2&#038;o=1&#038;a=0062102419" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, by Clayton M. Christensen is life advice for M.B.A. graduates. It dispenses valuable career, relationship, and ethics advice in business-school language.</p>

<p>High-achieving individuals (he&#8217;s a Harvard business-school professor) often over-invest themselves in their career and under-invest themselves in their family, and regret this later in life. This book is his attempt to correct that.</p>

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

<p>I didn&#8217;t agree with all his advice, and some of it reflects his strong <a href="http://en.wikipedia.org/wiki/The_Church_of_Jesus_Christ_of_Latter-day_Saints" target="_blank" class="external">Mormon</a> faith. However, this book made me pause to reflect on my life, and re-examine various parts of it. It felt like a valuable exercise.</p>

<h3>2. What makes us tick</h3>

<p><a href="http://en.wikipedia.org/wiki/Two-factor_theory" target="_blank" class="external">Two-factor theory</a>, or how to achieve job satisfaction and avoid job dissatisfaction.</p>

<ul>
<li>Hygiene factors (money, status, job security, work conditions, company policies, supervisory practices, etc). Typically external. Absence of these causes job dissatisfaction.</li>
<li>Motivators (challenging work, recognition, responsiblity, personal growth). Typically internal. Ask: Is this work meaningful to me? Am I going to develop and learn new things? Presence of these creates job satisfaction.</li>
</ul>

<h3>3. The balance of calculation and serendipity</h3>

<p>Emergent and Deliberate strategy. Life won&#8217;t follow your five year plan. Stay on lookout for unexpected opportunities. Experiment. Pivot. Adjust.</p>

<p>Test assumptions before jumping. Do a &#8220;spike&#8221;. What has to prove true for your expectations to pan out?</p>

<h3>4. Your strategy is not what you say it is</h3>

<p>You have a set of resources: Time, money, energy. Your strategy is how you spend those, on a daily basis. To make sure your real strategy is what you want it to be, watch where you are spending your time, money, and energy &#8211; where you allocate your resources.</p>

<p>You intended strategy may be to put your family first, but if you are spending all your time and energy on work, your actual strategy is to put your work first.</p>

<h3>5. The ticking clock</h3>

<p>Invest in your personal relationships (spouse and children) whilst everything still seems fine, when it doesn&#8217;t seem necessary. By the time problems arise it is often too late.</p>

<p>Work has a more immediate and more obvious payoff than family, and family rarely shouts the loudest for your attention, so it is tempting to focus our resources / life-investments on work. That is a big mistake.</p>

<p>You cannot sequence life investments. You cannot &#8220;focus on your career&#8221; for a few years, and then &#8220;take a step back&#8221; to focus on your family later. By then you will be too entrenched in your career, and too distant from your family. Run both in parallel.</p>

<p>Plant trees before you need the shade.</p>

<h3>6. What job did you hire that milkshake for?</h3>

<p>Too often we think about what we get out of a relationship. Instead, think of what is important for the other person.</p>

<p>What job did your spouse (or friends) hire you for? What job do your kids need a parent for?</p>

<h3>7. Sailing your kids on Theseus&#8217;s ship</h3>

<p><a href="http://en.wikipedia.org/wiki/Capability_management_in_business" target="_blank" class="external">Capabilities</a>: What Resources, Processes, and Priorities will your children need in the future?</p>

<ul>
<li>Resources are financial and material, time and energy, knowledge, relationships.</li>
<li>Processes are what your child does with the resources he has, to accomplish and create new things for themselves. They are relatively intangible. How they think, how they ask questions, how they solve problems, how they work with others.</li>
<li>Priorities determine how a child makes decisions in life &#8211; which things go to the top of the list, which are procastinated, and which are ignored.</li>
</ul>

<p>Many parents flood their children with resources, when what they really need are processes. Allow them to shoulder responsiblity and solve complicated problems for themselves and others. Sometimes the biggest gift is what you <em>don&#8217;t</em> do for your child. Children learn when they are ready to learn, not when you are ready to teach (c.f. teachable moment).</p>

<p>Don&#8217;t outsource too much of your children&#8217;s education. Otherwise they learn priorities from others, not from your family.</p>

<h3>8. The schools of experience</h3>

<p>Plan your (and your children&#8217;s) classes in the school of experience (coping with a difficult teacher, failing at a sport, navigating the social structure of school cliques). Find small opportunities for them to take important &#8220;courses&#8221; early on. Encourage them to fail forward.</p>

<p>Think about what your want your child to learn and look for experiences that will help them acquire that learning (by doing (processes), rather than being taught (resources)). Work backwards from the learning to craft the experience.</p>

<h3>9. The invisible hand inside your family.</h3>

<p><a href="http://en.wikipedia.org/wiki/Organizational_culture" target="_blank" class="external">Culture</a>. Decide explicitly what you want your familiy&#8217;s culture to be, and live it. Culture is the informal but powerful set of guidelines about how your family behaves. The family norms and values.</p>

<p>Culture will become your children&#8217;s auto-pilot, enabling them to do the right thing when on their own. Culture is created in all the small everyday interactions within a family.</p>

<h3>10. Staying out of jail</h3>

<p><a href="http://en.wikipedia.org/wiki/Marginal_cost" target="_blank" class="external">Marginal thinking</a>. The road to hell is not marked with signposts &#8211; the first step to a big mistake rarely seems like an imporant decision. To avoid taking that small first step, don&#8217;t ever give in &#8220;just this once&#8221;. Decide what you stand for. And then stand for it all the time.</p>

<h3>Epilogue. Find your purpose</h3>

<p>A useful Purpose statement needs three parts:</p>

<ul>
<li>Likeness: What you want to become, what you sincerely hope to be.</li>
<li>Commitment: A deep commitment, almost a conversion, to the likeness you are trying to create.</li>
<li>Metrics: How you measure your approach to that likeness.</li>
</ul>

<p>Purpose must be deliberately conceived and chosen, and then pursued. The purpose is deliberate, but the path to the likeness is typically emergent, as opportunities and challenges arise. It can take time to find your purpose.</p>

<p>Purpose is your rudder in the rough seas of life. Finding it is the most important thing you can learn. How will you measure <em>your</em> life?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/society/how-will-you-measure-your-life-book-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I prefer Android to iOS</title>
		<link>http://www.darkcoding.net/software/why-i-prefer-android-to-ios/</link>
		<comments>http://www.darkcoding.net/software/why-i-prefer-android-to-ios/#comments</comments>
		<pubDate>Mon, 31 Dec 2012 17:53:58 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[tablet]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1729</guid>
		<description><![CDATA[Our house has two iOS devices (an iPad and and iPod Touch), and two Android devices (Nexus 7 tablet, Samsung Galaxy phone). The Androids are newer than the iOS. So far, I prefer the Android devices for these reasons: Android is multi-user. Just swipe down, select a different account. iOS seems designed for individuals living [...]]]></description>
			<content:encoded><![CDATA[<p>Our house has two iOS devices (an iPad and and iPod Touch), and two Android devices (Nexus 7 tablet, Samsung Galaxy phone). The Androids are newer than the iOS. So far, I prefer the Android devices for these reasons:</p>

<ul>
<li>Android is multi-user. Just swipe down, select a different account. iOS seems designed for individuals living alone.</li>
<li>Widgets on the home screen. Just by glancing at my Nexus 7&#8242;s screen I can check my email, my calendar, and the weather. iOS&#8217;s home screen is just a list of all your apps.</li>
<li>AdBlock Plus. Android has an AdBlock app, which tries to block in-app adverts.</li>
<li>Internal access &#8211; Terminal, Disk usage, RAM usage, etc. I feel more comfortable with a device that gives me that level of knowledge. Android holds it&#8217;s users in higher regard than iOS.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/software/why-i-prefer-android-to-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tools for Change, Social Change Conference 1995 notes</title>
		<link>http://www.darkcoding.net/behaviour/tools-for-change-social-change-conference-1995-notes/</link>
		<comments>http://www.darkcoding.net/behaviour/tools-for-change-social-change-conference-1995-notes/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 04:31:24 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Behaviour]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1706</guid>
		<description><![CDATA[In these months of American politicians trying to influence you, I thought it interesting to look at ways of using the same tools for positive change. In May 1995, Canadian academic, broadcaster and environmental activist David Suzuki invited marketers, scientists, media educators, and activists to Vancouver for a Social Change Conference. The goal was for [...]]]></description>
			<content:encoded><![CDATA[<p>In these months of American politicians trying to influence you, I thought it interesting to look at ways of using the same tools for positive change.</p>

<p>In May 1995, Canadian academic, broadcaster and environmental activist <a href="http://en.wikipedia.org/wiki/David_Suzuki" target="_blank" class="external">David Suzuki</a> invited marketers, scientists, media educators, and activists to Vancouver for a <a href="http://www.najc.ca/thenandnow/about6d.php" target="_blank" class="external">Social Change Conference</a>. The goal was for social change organisations to learn about effective marketing and behaviour change from professionals and each other.</p>

<p>The proceedings were published in <a href="http://books.google.ca/books/about/Tools_for_Change.html?id=9fDESgAACAAJ" target="_blank" class="external">Tools for Change</a>, which is available at the Vancouver Pubic Library, and AFAIK basically nowhere else. Here&#8217;s what I found interesting:</p>

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

<h2>Mark Sarner of <a href="http://manifestcom.com/" target="_blank" class="external">manifest</a> on Marketing</h2>

<p>Social marketing is about changing the social climate for progressive ideas.</p>

<p>The &#8216;social sector&#8217; (charities, N.G.O&#8217;s), needs to embrace marketing, because they are already doing it, just not well enough. You need to embrace competition. If your cause is not more important than the others you&#8217;re in the wrong organisation.</p>

<p>Develop a product, a social product. It must meet a social need, generate social value. A social product can be a commercial product: condoms, low-fat cookbooks, solar panels, etc. What do your customers want?</p>

<p>Stay focused and on message. Don&#8217;t dilute by attacking all problems at once. Focus on brands, ideas that have qualities and images that attract your target audience. Stand out from the crowd, take risks, be noticed.</p>

<p>Provide sound-bite solutions, as soon as you hook people with the problem.</p>

<h2><a href="http://www.pdx.edu/cupa/profile/larry-wallack" target="_blank" class="external">Larry Wallack</a> on Media Advocacy</h2>

<p>What is the issue? What is the specific policy you want to advance? Who has the power to make that policy a reality? Who can put pressure on them? How does the general public stand on the issue?</p>

<p>Use compelling images &#8211; without good visuals you won&#8217;t get into print and video media. Use human focused statistics. Identify authentic &#8216;human interest&#8217; voices. Journalists will want to speak to them.</p>

<p>Use evocative symbols: slogans, images, objects, martyrs, logos, names, etc.</p>

<h2>Leanne Pippard</h2>

<p>Opinion polls gather a largely uninformed public opinion.</p>

<p>(sorry that&#8217;s all there is in my notes for her)</p>

<h2><a href="http://www.sauder.ubc.ca/Faculty/People/Faculty_Members/Pollay_Richard" target="_blank" class="external">Richard Pollay</a></h2>

<p>Marketing is about producing what people want. Understand your target market. Focus your efforts on a specific market.</p>

<p>Advertising on local radio is very cost effective. A radio ad: No gimmicks, establish common ground, write the way you talk, use real people with real feelings, keep the message simple.</p>

<p>Start with a question, end with a headline.</p>

<h2><a href="http://en.wikipedia.org/wiki/Garfield_Mahood" target="_blank" class="external">Garfield Mahood</a> of the <a href="http://www.nsra-adnf.ca/cms/" target="_blank" class="external">NSRA</a> on the anti-tobacco campaign</h2>

<ul>
<li>Research: Know the issue inside-out. Know the players, the lobbyists, the government agencies, etc. Be a media friendly expert.</li>
<li>Education: Get information to the involved parties. Spend money on advertising.</li>
<li>Polarization: Embrace conflict, it will be almost impossible to achieve your goals with no conflict.</li>
<li>Neutralization: Neutralize the opposition with targeted adverts and messages.</li>
<li>Mobilization: Get supporters to write in.</li>
</ul>

<h2><a href="http://cepsm.ca/jim-mintz/" target="_blank" class="external">Jim Mintz</a> of the Centre of Excellence for Public Sector Marketing.</h2>

<p>The best approach is always top down and bottom up. Get government to legislate away the undesirable behaviour, and get people to stop wanting to pursue it.</p>

<p>Your cause would benefit from a champion: An individual figurehead and leader.</p>

<h2>Herb Chao Gunther of the <a href="http://www.publicmediacenter.org/" target="_blank" class="external">Public Media Centre</a></h2>

<p>The Public Media Centre spends 60% of their budget on advertising, full page ads:</p>

<blockquote>
  <p>It costs money. But if you&#8217;re afraid of money, you&#8217;re afraid of social change.</p>
</blockquote>

<p>Have strong clear values, tell people about right and wrong. Provide moral leadership. Act like a winner.</p>

<p>Focus on the &#8220;muddled middle&#8221;. You don&#8217;t need to sell to your supporters, you probably can&#8217;t convince your opponents, so focus on the uninformed and undecided.</p>

<blockquote>
  <p>Marketing is premised on the fact that you can&#8217;t tell anybody anything they don&#8217;t already know &#8211; you&#8217;d be amazed at what people know.</p>
</blockquote>

<p>Point fingers. Attack the enemy. Once the blame is shifted from consumers, they can join your fight.</p>

<p>You don&#8217;t need consensus, or committees. A free market of ideas and actions is much more effective. Lots of independent campaigns will be more effective than a mono-culture.</p>

<h2><a href="http://info.hper.indiana.edu/sb/page/normal/1210.html" target="_blank" class="external">Susan Middlestadt</a> on Behavioral Science</h2>

<p>Determinants -> Behavior -> Outcome</p>

<p>Determinants of behavior:</p>

<ul>
<li>Perceived consequences: What good things will happen? What bad things?</li>
<li>Perceived social norms: Who do you think will approve / disapprove?</li>
<li>Efficacy and perceived skill: What would make it easier for you to engage in that behavior? More difficult?</li>
</ul>

<p>Design interventions to act on the determinants.</p>

<p>Formal education settings such as classroom on environmental issues, eco-club, etc trigger <a href="http://www.darkcoding.net/behaviour-change-toolkit/#central">central processing</a>.</p>

<p>Non-formal settings can educate about social issues too: A match class or literacy class, where the examples and tests are about the environment. This employs <a href="http://www.darkcoding.net/behaviour-change-toolkit/#peripheral">peripheral processing</a>.</p>

<p>Strategy: Analyze behavior patterns, segment your target audience, develop a plan, do it, monitor, revise.</p>

<p>Technology, Policies and Perceptions should be considered. Recycling example.</p>

<p>Define your target outcome. Research what behaviours, in what context and time frame, will achieve that outcome. Compare people who do the behavior to people who don&#8217;t, see which determinants change.</p>

<h2>David Suzuki</h2>

<p>I wrote his view on television up previously, in <a href="http://www.darkcoding.net/behaviour/david-suzuki-on-television/">David Suzuki on Television</a>.</p>

<p>His broad summary of the conference was this:</p>

<blockquote>
  <p>The challenge is to raise this playing field so that it doesn&#8217;t matter where you lie on the political spectrum &#8211; so that everyone agrees that air, water, soil, and biodiversity are crucial to our survival and to the health of our economy.</p>
</blockquote>

<p>Same as women&#8217;s rights, slavery, child labour, etc.</p>

<p>For (much) more information on behaviour change, continue to the <a href="http://www.darkcoding.net/behaviour-change-toolkit/">Behaviour Change Toolkit</a>.</p>

<p><small>The gap between the conference, the write-up, my notes of the write up, and my blog of my notes of the write up, is bound to end up mis-representing people&#8217;s view. If I have mis-quoted or mis-represented you above, please let me know so I can correct. Thanks!</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/tools-for-change-social-change-conference-1995-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>David Suzuki on television</title>
		<link>http://www.darkcoding.net/behaviour/david-suzuki-on-television/</link>
		<comments>http://www.darkcoding.net/behaviour/david-suzuki-on-television/#comments</comments>
		<pubDate>Tue, 23 Oct 2012 01:11:29 +0000</pubDate>
		<dc:creator>graham</dc:creator>
				<category><![CDATA[Behaviour]]></category>
		<category><![CDATA[television]]></category>

		<guid isPermaLink="false">http://darkcoding.ge1.ca/?p=1701</guid>
		<description><![CDATA[David Suzuki tells of making television science programs. He thought people would turn on TV to watch his program, then turn it off and discuss. Of course people don&#8217;t watch television that way at all. They come home, they turn it on, and it&#8217;s there. And they tune in and out, assaulted by a barrage [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/David_Suzuki" target="_blank" class="external">David Suzuki</a> tells of making television science programs. He thought people would turn on TV to watch his program, then turn it off and discuss.</p>

<blockquote>
  <p>Of course people don&#8217;t watch television that way at all. They come home, they turn it on, and it&#8217;s <em>there</em>. And they tune in and out, assaulted by a barrage of images. By the time they go to bed at night, their brains are mush. They retain bits and pieces with no idea where it came from.</p>
</blockquote>

<p>(From the highlights of <a href="http://books.google.ca/books/about/Tools_for_Change.html?id=9fDESgAACAAJ" target="_blank" class="external">Social Change Conference, 1995</a>).</p>

<p>When confronted with the negative effects of television, people often claim <em>&#8220;I only watch the Discovery / History / Nature channel&#8221;</em>. Your brain still turns to mush. Put the TV in a cupboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darkcoding.net/behaviour/david-suzuki-on-television/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
