<?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>Deadpan Sincerity</title>
	<atom:link href="http://blog.deadpansincerity.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.deadpansincerity.com</link>
	<description>a weblog by david miller</description>
	<lastBuildDate>Fri, 09 Dec 2011 12:03:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Announcing Dizzee</title>
		<link>http://blog.deadpansincerity.com/2011/09/announcing-dizzee/</link>
		<comments>http://blog.deadpansincerity.com/2011/09/announcing-dizzee/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 12:24:50 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[dizzee]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[subprocesses]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=510</guid>
		<description><![CDATA[Dizzee is an Emacs library for managing subprocesses. This is it&#8217;s initial release! From the docs: Dizzee is a pleasant way to manage your project&#8217;s subprocesses in Emacs. You have a project. In order to get an instance running and start working, you have to manually launch say&#8230; 4 processes in 4 different shells. This [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/davidmiller/dizzee">Dizzee</a> is an Emacs library for managing subprocesses. <br />
This is it&#8217;s initial release!</p>
<p>From the docs:</p>
<blockquote><p>Dizzee is a pleasant way to manage your project&#8217;s subprocesses in Emacs.<br />
You have a project.<br />
In order to get an instance running and start working, you have to manually launch say&#8230; 4 processes in 4 different shells.<br />
This is Not Fun.<br />
Thankfully it is also a definable, repeatable process &#8211; which means that we can Use Programming.<br />
At worst, this is More Fun than doing it yourself every time.
</p>
</blockquote>
<p>
This all came about when I started my current job &#8211; of the three product stacks I work on, none can be run from source without launching multiple processes in separate shells. Terminator helps (and is generally awesome) but being able to start work on a bug all with one command, and build in code reloading without having to build it into the source &#038; go through the process of getting the relevant buy-in for that, was a massive win.</p>
<p>Bugs/feature requests &#038; docs via <a href="https://github.com/davidmiller/dizzee">github</a>. </p>
<p>Enjoy. </p>
<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/09/announcing-dizzee/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick Access to .dotfiles in Emacs</title>
		<link>http://blog.deadpansincerity.com/2011/08/quick-access-to-dotfiles-in-emacs/</link>
		<comments>http://blog.deadpansincerity.com/2011/08/quick-access-to-dotfiles-in-emacs/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 21:42:30 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[dotfiles]]></category>
		<category><![CDATA[elisp]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lisp]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=502</guid>
		<description><![CDATA[For those moments when you want fast access to &#8220;~/.something&#8221; &#8211; what nicer than M-x .thatsomething &#40;defmacro dotfile &#40;filename&#41; &#34;Define the function `filename' to edit the dotfile in question&#34; &#40;let &#40;&#40;filestr &#40;symbol-name filename&#41;&#41;&#41; `&#40;progn &#40;defun ,&#40;intern filestr&#41; &#40;&#41; ,&#40;format &#34;Open %s for editing&#34; filestr&#41; &#40;interactive&#41; &#40;find-file ,&#40;concat &#34;~/&#34; filestr&#41;&#41;&#41;&#41;&#41;&#41; With which we can define a [...]]]></description>
			<content:encoded><![CDATA[<p>For those moments when you want fast access to &#8220;~/.something&#8221; &#8211; what nicer than M-x .thatsomething</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defmacro</span> dotfile <span style="color: #66cc66;">&#40;</span>filename<span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;Define the function `filename' to edit the dotfile in question&quot;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>filestr <span style="color: #66cc66;">&#40;</span>symbol-<span style="color: #b1b100;">name</span> filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    `<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">progn</span>
       <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> <span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">intern</span> filestr<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span>format <span style="color: #ff0000;">&quot;Open %s for editing&quot;</span> filestr<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>find-file <span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span>concat <span style="color: #ff0000;">&quot;~/&quot;</span> filestr<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>With which we can define a M-x .emacs function with:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>dotfile <span style="color: #66cc66;">.</span>emacs<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/08/quick-access-to-dotfiles-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Colonize &#8211; eol fun for emacs</title>
		<link>http://blog.deadpansincerity.com/2011/06/colonize-eol-fun-for-emacs/</link>
		<comments>http://blog.deadpansincerity.com/2011/06/colonize-eol-fun-for-emacs/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 20:20:48 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=491</guid>
		<description><![CDATA[Doing a lot of work with interpreters that need semi-colons to tell them when a line ends recently &#8211; and making flymake be quiet about it involves a whole sequence of C-e &#8230; ; &#8230; what was I thinking about again? So thanks to this, C-M-; now colonizes the line and leaves me happily where [...]]]></description>
			<content:encoded><![CDATA[<p>Doing a lot of work with interpreters that need semi-colons to tell them when a line ends recently &#8211; and making <a href="http://www.emacswiki.org/emacs/FlyMake">flymake</a> be quiet about it involves a whole sequence of C-e &#8230; ; &#8230; what was I thinking about again?</p>
<p>So thanks to this, C-M-; now colonizes the line and leaves me happily where I was</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> colonize <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;For languages that insist on putting a colon at the end of a line,
do that. But stay where you're thinking is at.&quot;</span>
  <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>save-excursion
    <span style="color: #66cc66;">&#40;</span>move-end-of-line <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>insert <span style="color: #ff0000;">&quot;;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#40;</span>kbd <span style="color: #ff0000;">&quot;C-M-;&quot;</span><span style="color: #66cc66;">&#41;</span> 'colonize<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/06/colonize-eol-fun-for-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercurial Hook to ensure issue references in Trac/Redmine</title>
		<link>http://blog.deadpansincerity.com/2011/06/mercurial-hook-to-ensure-issue-references-in-tracredmine/</link>
		<comments>http://blog.deadpansincerity.com/2011/06/mercurial-hook-to-ensure-issue-references-in-tracredmine/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 10:41:07 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[something's burning]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[wishful thinking]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=400</guid>
		<description><![CDATA[As much as I love the version control integration of the bug trackers I use (Redmine and Trac) I find myself forgetting to include the issue reference more often than I&#8217;d like to admit. Add to this the merry dance you have to go through to ammend commit messages in Mercurial and things get even [...]]]></description>
			<content:encoded><![CDATA[<p>As much as I love the version control integration of the bug trackers I use (<a href="http://www.redmine.org/">Redmine</a> and <a href="http://trac.edgewall.org/">Trac</a>) I find myself forgetting to include the issue reference more often than I&#8217;d like to admit.</p>
<p>Add to this the <a href="http://stackoverflow.com/questions/623052/how-to-edit-incorrect-commit-message-in-mercurial">merry dance</a> you have to go through to ammend commit messages in <a href="http://mercurial.selenic.com/">Mercurial</a> and things get even worse. (Oh how I&#8217;d love for hg to implement something similar to <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html">git&#8217;s</a> $ git commit &#8211;amend )</p>
<p>Hence, a Pre-transaction-commit hook for hg that will ask me if I&#8217;m sure I want to commit without an issue number. If want to commit anyway, it&#8217;s just two extra keystrokes, and saves a whole lot of rollback/apply nonsense.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #dc143c;">cmd</span> = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'hg'</span>, <span style="color: #483d8b;">'log'</span>, <span style="color: #483d8b;">'-vr'</span>, <span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'HG_NODE'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>,
                       stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
msg = <span style="color: #dc143c;">cmd</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'description:'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
issue_regexes = <span style="color: black;">&#91;</span>
    <span style="color: #808080; font-style: italic;"># Trac</span>
    r<span style="color: #483d8b;">'#<span style="color: #000099; font-weight: bold;">\d</span>+'</span>,
    <span style="color: #808080; font-style: italic;"># Redmine</span>
    r<span style="color: #483d8b;">'fixes #<span style="color: #000099; font-weight: bold;">\d</span>+'</span>,
    r<span style="color: #483d8b;">'refs #<span style="color: #000099; font-weight: bold;">\d</span>+'</span>,
    <span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">filter</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>x, msg<span style="color: black;">&#41;</span>, issue_regexes<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;No issue ref or fix... message is:&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> msg
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Continue? [y/n] &quot;</span><span style="color: black;">&#41;</span>
    resp = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> resp == <span style="color: #483d8b;">'n'</span>:
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">9</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Then add the following to your project&#8217;s .hg/hgrc:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>hooks<span style="color: #009900;">&#93;</span>
pretxncommit <span style="color: #339933;">=</span> path<span style="color: #339933;">/</span>to<span style="color: #339933;">/</span>your<span style="color: #339933;">/</span>pretxncommit.<span style="color: #660066;">py</span></pre></div></div>

<p>Saving you endless embarrassment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">davidmiller<span style="color: #000000; font-weight: bold;">@</span>pascal:~<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>buggy_repo$ hg commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;A context-less void&quot;</span>
No issue ref or fix... message is:
&nbsp;
A context-less void
&nbsp;
&nbsp;
&nbsp;
Continue? <span style="color: #7a0874; font-weight: bold;">&#91;</span>y<span style="color: #000000; font-weight: bold;">/</span>n<span style="color: #7a0874; font-weight: bold;">&#93;</span> n
transaction abort<span style="color: #000000; font-weight: bold;">!</span>
rollback completed
abort: pretxncommit hook exited with status <span style="color: #000000;">9</span></pre></div></div>

<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/06/mercurial-hook-to-ensure-issue-references-in-tracredmine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up Emacs as a Javascript editing environment for Fun or Profit</title>
		<link>http://blog.deadpansincerity.com/2011/05/setting-up-emacs-as-a-javascript-editing-environment-for-fun-and-profit/</link>
		<comments>http://blog.deadpansincerity.com/2011/05/setting-up-emacs-as-a-javascript-editing-environment-for-fun-and-profit/#comments</comments>
		<pubDate>Sun, 29 May 2011 17:21:16 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[favourite things]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[flymake]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[jslint]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[yasnippet]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=454</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of Javascript lately, which has naturally led to a whole lot of trips down the .emacs rabbit-hole So, here are the steps you need to turn OOTB Emacs into the perfect environment for working on Javascript: Auto-completion First up, you&#8217;re going to want decent auto-completion, so install the straightforwardly named [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of Javascript lately, which has naturally led to a whole lot of trips down the .emacs rabbit-hole</p>
<p>So, here are the steps you need to turn OOTB Emacs into the perfect environment for working on Javascript:</p>
<h2>Auto-completion</h2>
<div id="attachment_479" class="wp-caption aligncenter" style="width: 386px"><a href="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/ac.png"><img src="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/ac.png" alt="" title="Emacs Auto completing" width="376" height="224" class="size-full wp-image-479" /></a><p class="wp-caption-text">Fizzing!</p></div><br />
<br \></p>
<p>First up, you&#8217;re going to want decent auto-completion, so install the straightforwardly named <a href="http://cx4a.org/software/auto-complete/">auto-complete-mode</a>. Due to some mode-name aliasing that goes on in the Emacs23 javascript mode, You&#8217;ll need to make sure it can find the relevant Javascript dictionary so</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>auto-complete<span style="color: #000000; font-weight: bold;">/</span>dict
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> javascript-mode js-mode</pre></div></div>

<p>and then add to your .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/path-to/auto-complete&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">; Load the default configuration</span>
<span style="color: #66cc66;">&#40;</span>require 'auto-complete-config<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">; Make sure we can find the dictionaries</span>
<span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'ac-dictionary-directories <span style="color: #ff0000;">&quot;~/emacs/auto-complete/dict&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">; Use dictionaries by default</span>
<span style="color: #66cc66;">&#40;</span>setq-default ac-sources <span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'ac-sources 'ac-source-dictionary<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>global-auto-complete-mode t<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">; Start auto-completion after 2 characters of a word</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> ac-auto-start <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">; case sensitivity is important when finding matches</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> ac-ignore-<span style="color: #b1b100;">case</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>You now have auto-completion for all variable names in all open Javascript buffers, as well as for standard syntax words (setTimeout, parseInt, onFocus etc).</p>
<h2>Snippeting</h2>
<p>Not content with that, we&#8217;ll also want some kind of intelligent snippet package right &#8211; how many times do you really want to type all those semicolons and curly braces? Once is good for me.</p>
<p>The excellent <a href="http://code.google.com/p/yasnippet/">Yasnippet</a> provides this (check out the <a href="http://www.youtube.com/watch%3Fv%3D76Ygeg9miao">youtube demo</a> if you&#8217;ve not come across it before)</p>
<p>Once you&#8217;ve got that downloaded and installed, you&#8217;ll want some Javascript snippets to load in, the ones I use, for standard Javascript and jQuery can be downloaded from <a href="https://github.com/davidmiller/yasnips/raw/master/jsnips.tgz">here</a>, and then the directory provided by that tarfile needs to go in yasnippet/snippets/text-mode</p>
<p>So for our .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/path/to/yasnippet&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Load the library</span>
<span style="color: #66cc66;">&#40;</span>require 'yasnippet<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>yas/initialize<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Load the snippet files themselves</span>
<span style="color: #66cc66;">&#40;</span>yas/load-directory <span style="color: #ff0000;">&quot;~/path/to/yasnippet/snippets/text-mode&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Let's have snippets in the auto-complete dropdown</span>
<span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'ac-sources 'ac-source-yasnippet<span style="color: #66cc66;">&#41;</span></pre></div></div>

<h2>Syntax Checking</h2>
<p><div id="attachment_484" class="wp-caption alignright" style="width: 136px"><a href="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/syntax.png"><img src="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/syntax.png" alt="" title="whoops..." width="126" height="79" class="size-full wp-image-484" /></a><p class="wp-caption-text">Whoops...</p></div>
<p>One of the problems with Javascript programming is that the feedback loop for syntax errors is *slow* &#8211; if you&#8217;re working with the web you have to wait for a whole pageload. So we&#8217;ll want on-the-fly error checking.</p>
<p><a href="http://keturn.net/">Kevin Turner</a> originally wrote <a href="https://github.com/keturn/lintnode#readme">Lintnode</a>, which runs a lighthweight node.js server that passes your file to <a href="http://www.crockford.com/">Douglas Crockford&#8217;s</a> <a href="http://www.jslint.com/">JSLint</a> to integrate with <a href="http://www.emacswiki.org/emacs/FlyMake">Flymake</a> &#8211; the Emacs solution for on-the-fly syntax checking. The fork I&#8217;m currently maintaining at <a href="https://github.com/davidmiller/lintnode">Github</a> contains some enhancements such as automatic initialization and JSLint options passed from Emacs that the original has yet to merge in. Given that JSLint frequently complains about things that you might like it to er, not complain about, the ability to change the options with the lintnode-jslint-excludes variable makes this far more useable.</p>
<p>So:</p>
<p>Install <a href="http://nodejs.org/">node.js</a> and <a href="http://npmjs.org/">npm</a> (The package manager for node)</p>
<p>Get lintnode and the dependencies</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>davidmiller<span style="color: #000000; font-weight: bold;">/</span>lintnode.git
<span style="color: #7a0874; font-weight: bold;">cd</span> lintnode
npm <span style="color: #c20cb9; font-weight: bold;">install</span> express connect-form haml underscore</pre></div></div>

<p>Then we need this in our .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/path/to/lintnode&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>require 'flymake-jslint<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Make sure we can find the lintnode executable</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> lintnode-location <span style="color: #ff0000;">&quot;~/path/to/lintnode&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; JSLint can be... opinionated</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> lintnode-jslint-excludes <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> 'nomen 'undef 'plusplus 'onevar 'white<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Start the server when we first open a js file and start checking</span>
<span style="color: #66cc66;">&#40;</span>add-hook 'js-mode-hook
          <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#40;</span>lintnode-hook<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Syntax errors will now be given a red background without having to leave the comfort of Emacs.</p>
<p>Even better, if we install the <a href="http://www.emacswiki.org/emacs/FlymakeCursor">Flymake Cursor</a> package, we get the error message in the minibuffer when the cursor is on a line with an error.</p>
<div id="attachment_485" class="wp-caption aligncenter" style="width: 351px"><a href="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/modeline.png"><img src="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/modeline.png" alt="" title="modeline" width="341" height="153" class="size-full wp-image-485" /></a><p class="wp-caption-text">Easy Mistake!</p></div>
<p>Get the source from http://www.emacswiki.org/emacs/flymake-cursor.el and then add to your .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/emacs/minor-modes&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Nice Flymake minibuffer messages</span>
<span style="color: #66cc66;">&#40;</span>require 'flymake-cursor<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><b>Edit:</b></p>
<p>As Jesse and Magnar point out in the comments, it&#8217;s probably a better idea to not exclude &#8216;undef from the jslint errors, but rather to declare global variables at the top of your .js file</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #006600; font-style: italic;">/*global $ */</span></pre></div></div>

<p>This way you can let jslint know about other libraries you are using, but still get the checks for undefined variables in your own code.</p>
<h2>Code folding</h2>
<div id="attachment_486" class="wp-caption aligncenter" style="width: 484px"><a href="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/hideshow.png"><img src="http://blog.deadpansincerity.com/wp-content/uploads/2011/05/hideshow.png" alt="" title="hideshow" width="474" height="144" class="size-full wp-image-486" /></a><p class="wp-caption-text">Underscore outline</p></div>
<p>Especially if you&#8217;re dealing with large projects, the ability to hide portions of code can be great for maintaining focus. Emacs comes with this built in, but you have to enable it, so returning to our .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-hook 'js-mode-hook
          <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #808080; font-style: italic;">;; Scan the file for nested code blocks</span>
            <span style="color: #66cc66;">&#40;</span>imenu-add-menubar-index<span style="color: #66cc66;">&#41;</span>
            <span style="color: #808080; font-style: italic;">;; Activate the folding mode</span>
            <span style="color: #66cc66;">&#40;</span>hs-minor-mode t<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This means that when your cursor is in the function&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Foo <span style="color: #339933;">=</span> <span style="color: #CC0000;">42</span><span style="color: #339933;">;</span>
addFoo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Let's add the meaning of life to</span>
    <span style="color: #006600; font-style: italic;">// our `num` - it'll be fun!</span>
    <span style="color: #003366; font-weight: bold;">var</span> meaningful<span style="color: #339933;">;</span>
    meaningful <span style="color: #339933;">=</span> num <span style="color: #339933;">+</span> Foo<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&#8230; and you M-x hs-hide-block, the function turns into:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">Var</span> Foo <span style="color: #339933;">=</span> <span style="color: #CC0000;">42</span><span style="color: #339933;">;</span>
addFoo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To my taste the default keybinding of C-c @ C-h to hide blocks is somewhat perverse, so I&#8217;d recommend this in your .emacs:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">;; Show-hide</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#40;</span>kbd <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> 'hs-show-block<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#40;</span>kbd <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> 'hs-show-all<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#40;</span>kbd <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> 'hs-hide-block<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#40;</span>kbd <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> 'hs-hide-all<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>YMMV.</p>
<h2>Javascript Console</h2>
<p>Having a REPL for the language you&#8217;re working with close to hand is basically required for me to enjoy working with it. Now that we&#8217;ve installed node.js, though, we can have us a Javascript console inside Emacs with <a href="http://js-comint-el.sourceforge.net/">js-comint</a>&#8230;</p>
<p>Once you&#8217;ve grabbed the file, your .emacs should have:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'load-path <span style="color: #ff0000;">&quot;~/path/to/js-comint&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>require 'js-comint<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;; Use node as our repl</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> inferior-js-program-command <span style="color: #ff0000;">&quot;node&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> inferior-js-mode-hook
      <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #808080; font-style: italic;">;; We like nice colors</span>
        <span style="color: #66cc66;">&#40;</span>ansi-color-for-comint-mode-on<span style="color: #66cc66;">&#41;</span>
        <span style="color: #808080; font-style: italic;">;; Deal with some prompt nonsense</span>
        <span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'comint-preoutput-filter-functions
                     <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">lambda</span> <span style="color: #66cc66;">&#40;</span>output<span style="color: #66cc66;">&#41;</span>
                       <span style="color: #66cc66;">&#40;</span>replace-regexp-in-string <span style="color: #ff0000;">&quot;.*1G<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\.</span>.*5G&quot;</span> <span style="color: #ff0000;">&quot;...&quot;</span>
                     <span style="color: #66cc66;">&#40;</span>replace-regexp-in-string <span style="color: #ff0000;">&quot;.*1G.*3G&quot;</span> <span style="color: #ff0000;">&quot;&amp;gt;&quot;</span> output<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>You can then run a Javascript REPL with M-x run-js and also send portions of files by selecting them and then running M-x send-region. Neat.</p>
<h2>By way of conclusion</h2>
<p>There are a few other tweaks that make my Javascripting just that little bit nicer, but they&#8217;re more personal Emacs setup than anything specific to Javascript. So, there you have it, the perfect Javascript editing environment.</p>
<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/05/setting-up-emacs-as-a-javascript-editing-environment-for-fun-and-profit/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Announcing Pony Mode &#8211; a Django editing mode for Emacs</title>
		<link>http://blog.deadpansincerity.com/2011/05/announcing-pony-mode-a-django-editing-mode-for-emacs/</link>
		<comments>http://blog.deadpansincerity.com/2011/05/announcing-pony-mode-a-django-editing-mode-for-emacs/#comments</comments>
		<pubDate>Sat, 28 May 2011 11:33:10 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[favourite things]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=448</guid>
		<description><![CDATA[I&#8217;m pleased to announce the first beta &#8216;release&#8217; of Pony Mode, a minor mode for working on Django projects in Emacs. This mode provides integration with the django management commands within emacs, as well as test integration, a minor-mode with syntax highlighting for editing templates, will determine whether you are using Fabric or Buildout, as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to announce the first beta &#8216;release&#8217; of <a href="https://github.com/davidmiller/pony-mode">Pony Mode</a>, a minor mode for working on <a href="www.djangoproject.com">Django</a> projects in <a href="http://www.gnu.org/software/emacs/">Emacs</a>.</p>
<p>This mode provides integration with the django management commands within emacs, as well as test integration, a minor-mode with syntax highlighting for editing templates, will determine whether you are using <a href="http://fabfile.org">Fabric</a> or <a href="http://www.buildout.org/">Buildout</a>, as well as much more!</p>
<p>This mode is under active development, so please file any bugs at the <a href="https://github.com/davidmiller/pony-mode/issues">Github page</a>, and feel free to provide any feedback/feature requests etc.</p>
<p>Current features include:</p>
<ul>
<li>Run dev server in an emacs buffer [C-c C-p r]</li>
<li>* Checks to see if runserver_plus is available</li>
<li>* If not uses in-built runserver</li>
<li>Jump to current project in browser (start server if required) [C-c C-p b]</li>
<li>Run test case at point in buffer [C-c C-p t]</li>
<li>Run tests for current app in buffer [C-c C-p t]</li>
<li>Run Syncdb on current project</li>
<li>Management commands for current project in interactive buffer</li>
<li>South integration &#8211; run south convert, schemamigration, migrate</li>
<li>Run django shell in buffer [C-c C-p s]</li>
<li>* Checks for shell_plus</li>
<li>* If not defaults to shell</li>
<li>Fabric integration [C-c C-p f]</li>
<li>Startapp and dumpdata on current project within emacs</li>
<li>Database integration with Emacs sql-mode interactive buffer [C-c C-c d</li>
<li>Django Template minor mode with syntax highlighting for django</li>
<p> template tags</p>
<li>Snippet collection for django</li>
<li>generate tags table for project</li>
<li>run manage commands in interactive buffer</li>
<li>Buildout integration</li>
<li>Generate TAGS table for project to enable quick navigation</li>
<li>Jump to template at point or from editing view [C-c C-p g t]</li>
</ul>
<p>Grab it while it&#8217;s hot!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/05/announcing-pony-mode-a-django-editing-mode-for-emacs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mass buffer revert in emacs</title>
		<link>http://blog.deadpansincerity.com/2011/05/mass-buffer-revert-in-emacs/</link>
		<comments>http://blog.deadpansincerity.com/2011/05/mass-buffer-revert-in-emacs/#comments</comments>
		<pubDate>Sat, 21 May 2011 09:52:43 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[wishful thinking]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[M-x]]></category>
		<category><![CDATA[vcs]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=441</guid>
		<description><![CDATA[One of the problems with doing branchy development in Emacs is that when you have lots of files open and then switch branches, the bufer contents stay on the previous branch. Thankfully Emacs will warn you that the file&#8217;s contents have changed before you edit/save the file, but calling M-x revert-buffer on lots of open [...]]]></description>
			<content:encoded><![CDATA[<p>One of the problems with doing branchy development in Emacs is that when you have lots of files open and then switch branches, the bufer contents stay on the previous branch. Thankfully Emacs will warn you that the file&#8217;s contents have changed before you edit/save the file, but calling M-x revert-buffer on lots of open files gets old very fast.</p>
<p>This being Emacs though, the natural solution to any irritation is to program your way out of it. M-x regexp-revert let&#8217;s you enter a regexp, and then reverts any buffer with a file location matching that regexp to the file&#8217;s current state on disk.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> regexp-revert <span style="color: #66cc66;">&#40;</span>regexp<span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;Revert all buffers whose path matches regexp&quot;</span>
  <span style="color: #66cc66;">&#40;</span>interactive <span style="color: #ff0000;">&quot;sPath Regexp: &quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">dolist</span> <span style="color: #66cc66;">&#40;</span>buffer <span style="color: #66cc66;">&#40;</span>buffer-<span style="color: #b1b100;">list</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>string-match-p regexp <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> <span style="color: #66cc66;">&#40;</span>buffer-file-<span style="color: #b1b100;">name</span> buffer<span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">progn</span>
          <span style="color: #66cc66;">&#40;</span>set-buffer buffer<span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#40;</span>revert-buffer <span style="color: #b1b100;">nil</span> t<span style="color: #66cc66;">&#41;</span>
          <span style="color: #66cc66;">&#40;</span>message <span style="color: #ff0000;">&quot;Reverting %s&quot;</span> <span style="color: #66cc66;">&#40;</span>buffer-file-<span style="color: #b1b100;">name</span> buffer<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Love regards etc</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/05/mass-buffer-revert-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>coverage command for separate test runner in django</title>
		<link>http://blog.deadpansincerity.com/2011/02/coverage-command-for-seperate-test-runner-in-django/</link>
		<comments>http://blog.deadpansincerity.com/2011/02/coverage-command-for-seperate-test-runner-in-django/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 08:11:05 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[coverage]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unittesting]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=402</guid>
		<description><![CDATA[I&#8217;m a long-time fan of django-test-coverage. It takes Ned Batchelor&#8216;s coverage.py and wraps it in a django test runner for you, which is great. Particularly with large test suites though, the speed increase is too large to go unnoticed (In my projects normally in the region of 150% YMMV). And your tests can never be [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a long-time fan of <a href="http://pypi.python.org/pypi/django-test-coverage/0.1">django-test-coverage</a>. It takes <a href="http://nedbatchelder.com/">Ned Batchelor</a>&#8216;s <a href="http://nedbatchelder.com/code/coverage/">coverage.py</a> and wraps it in a django test runner for you, which is great.</p>
<p>Particularly with large test suites though, the speed increase is too large to go unnoticed (In my projects normally in the region of 150% YMMV).</p>
<p>And your tests can <em>never</em> be too fast right?</p>
<p>One solution to this is to only use the coverage test runner in a seperate management command. That way you always have access to the stats, but your &#8216;regular&#8217; test run doesn&#8217;t take the performance hit. </p>
<p>Not only that, but you can also run the coverage stats on your continuous integration server once every few hours for a consistently recent picture of how your coverage is looking.</p>
<p>The code itself is nothing dead simple, just <a href="http://docs.djangoproject.com/en/dev/howto/custom-management-commands/">subclasses the django BaseCommand</a> class and then fetches the right test runner:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #483d8b;">&quot;&quot;&quot;
Run our tests with coverage turned on
&quot;&quot;&quot;</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">core</span>.<span style="color: black;">management</span>.<span style="color: black;">base</span> <span style="color: #ff7700;font-weight:bold;">import</span> BaseCommand
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Command<span style="color: black;">&#40;</span>BaseCommand<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    We totally want to get coverage details, but that's so slow!
    &quot;&quot;&quot;</span>
    option_list = BaseCommand.<span style="color: black;">option_list</span>
    <span style="color: #008000;">help</span> = <span style="color: #483d8b;">&quot;Run our tests with coverage turned on&quot;</span>
    args = <span style="color: #483d8b;">&quot;[appname ...]&quot;</span>
&nbsp;
    requires_model_validation = <span style="color: #008000;">False</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> handle<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">*</span>tests, <span style="color: #66cc66;">**</span>options<span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;&quot;&quot;
        Actually do the test run
&nbsp;
        Arguments:
        - `*tests`: test labels
        - `**options`: passed opts
        &quot;&quot;&quot;</span>
        verbosity = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>options.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'verbosity'</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        interactive = options.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'interactive'</span>, <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
        mod = <span style="color: #008000;">__import__</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;django-test-coverage.runner&quot;</span><span style="color: black;">&#41;</span>
        failures = mod.<span style="color: black;">runner</span>.<span style="color: black;">run_tests</span><span style="color: black;">&#40;</span>tests, verbosity=verbosity,
                                        interactive=interactive<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> failures:
            <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #008000;">bool</span><span style="color: black;">&#40;</span>failures<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This then needs to live somewhere in an a management dir of one of your installed apps&#8230;</p>
<blockquote><p>yourproject/yourapp/management/commands/coverage.py</p></blockquote>
<p>&#8230;and you&#8217;ll need to </p>
<blockquote><p>$ <a href="http://pypi.python.org/pypi/setuptools">easy_install</a> django-test-coverage</p></blockquote>
<p>So that the test runner is there in your environment.</p>
<p>Grab the <a href="https://github.com/davidmiller/Deadpansincerity-Code-Samples/raw/master/django/commands/coverage.py">raw file</a> here.</p>
<p>Alternatively you <em>could</em> <a href="http://ericholscher.com/blog/2009/nov/13/django-testing-code-coverage/">patch django itself</a>. Until they merge those changes though, I&#8217;ll be sticking with the seperate command.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/02/coverage-command-for-seperate-test-runner-in-django/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Get the latest Chrome nightly on your Linux desktop every day</title>
		<link>http://blog.deadpansincerity.com/2011/02/get-the-latest-chrome-nightly-on-your-linux-desktop-every-day/</link>
		<comments>http://blog.deadpansincerity.com/2011/02/get-the-latest-chrome-nightly-on-your-linux-desktop-every-day/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 21:04:01 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[the internet]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nightly]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/?p=404</guid>
		<description><![CDATA[Quick bash script to pull the latest chrome nightly to your very own desktop! 1 2 3 4 5 6 7 8 9 #!/bin/bash LATEST=&#34;http://build.chromium.org/f/chromium/snapshots/Linux/&#34;`curl http://build.chromium.org/f/chromium/snapshots/Linux/LATEST`&#34;/chrome-linux.zip&#34; wget $LATEST unzip chrome-linux.zip rm chrome-linux.zip if &#91; -x ~/builds/chrome-linux/ &#93;; then rm -rf ~/builds/chrome-linux/ fi mv chrome-linux ~/builds/ You&#8217;ll need to make the directory it&#8217;s going to download [...]]]></description>
			<content:encoded><![CDATA[<p>Quick bash script to pull the latest chrome nightly to your very own desktop!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">LATEST</span>=<span style="color: #ff0000;">&quot;http://build.chromium.org/f/chromium/snapshots/Linux/&quot;</span><span style="color: #000000; font-weight: bold;">`</span>curl http:<span style="color: #000000; font-weight: bold;">//</span>build.chromium.org<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">/</span>chromium<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>Linux<span style="color: #000000; font-weight: bold;">/</span>LATEST<span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot;/chrome-linux.zip&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #007800;">$LATEST</span>
<span style="color: #c20cb9; font-weight: bold;">unzip</span> chrome-linux.zip
<span style="color: #c20cb9; font-weight: bold;">rm</span> chrome-linux.zip
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> ~<span style="color: #000000; font-weight: bold;">/</span>builds<span style="color: #000000; font-weight: bold;">/</span>chrome-linux<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> ~<span style="color: #000000; font-weight: bold;">/</span>builds<span style="color: #000000; font-weight: bold;">/</span>chrome-linux<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> chrome-linux ~<span style="color: #000000; font-weight: bold;">/</span>builds<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>

<p>You&#8217;ll need to make the directory it&#8217;s going to download to.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>builds</pre></div></div>

<p>Then add as a cron job to run every night &#038;&#038; daily updates will come down the pipes!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2011/02/get-the-latest-chrome-nightly-on-your-linux-desktop-every-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security and freedoms</title>
		<link>http://blog.deadpansincerity.com/2010/10/security-and-freedoms/</link>
		<comments>http://blog.deadpansincerity.com/2010/10/security-and-freedoms/#comments</comments>
		<pubDate>Sun, 31 Oct 2010 12:05:12 +0000</pubDate>
		<dc:creator>david miller</dc:creator>
				<category><![CDATA[favourite things]]></category>
		<category><![CDATA[wishful thinking]]></category>
		<category><![CDATA[freedom]]></category>
		<category><![CDATA[Popper]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.deadpansincerity.com/2010/10/security-and-freedoms/</guid>
		<description><![CDATA[We must plan for freedom, and not only for security, if for no other reason than that only freedom can make security secure. Karl Popper &#8211; The Open Society and its Enemies]]></description>
			<content:encoded><![CDATA[<blockquote><p>We must plan for freedom, and not only for security, if for no other reason than that only freedom can make security secure.</p></blockquote>
<p>Karl Popper &#8211; The Open Society and its Enemies</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.deadpansincerity.com/2010/10/security-and-freedoms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

