<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" 
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

  <channel>
    <title>Deft Code</title>
    <link>http://www.deftcode.com/</link>
    <description>Characterized by facility and skill</description>
    <dc:language>en-us</dc:language>
    <dc:creator>bill@marginalia.org</dc:creator>
    <dc:rights>Copyright 2006</dc:rights>
    <dc:date>2005-04-27T16:08:26-08:00</dc:date>
    <admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=3.2" />
    <admin:errorReportsTo rdf:resource="mailto:bill@marginalia.org"/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

    <item>
      <title>Increment during emacs keyboard macro</title>
      <link>http://www.deftcode.com/archives/increment_during_emacs_keyboard_macro.html</link>
      <description><![CDATA[This is a useful trick if you have a bunch of text that you need to munge and insert an incremented digit during. An example - you want to change: one two three ... twenty into: one =&gt; 1, two...]]></description>
      <guid isPermaLink="false">1448@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>This is a useful trick if you have a bunch of text that you need to munge and insert an incremented digit during. An example - you want to change:</p>



<pre>
one
two
three
...
twenty
</pre>



<p>into:</p>



<pre>
one =&gt; 1,
two =&gt; 2,
three =&gt; 3,
...
twenty =&gt; 20,
</pre>



<p>You can accomplish this with an emacs keyboard macro; you just need to add a lisp eval to the mix. First, you need to add the initial digit you need to the list:</p>



<pre>
one =&gt; 1,
two
three
...
</pre>



<p>The basic logic is: select the digit of the current line, save it to a register, move to our next line, insert the text we want, insert the incremented value in the register, finish the line. I&#8217;m going to assume if you&#8217;re read this far you know the basic routine for creating an emacs keyboard macro, so here&#8217;s the commented dump of the keystrokes needed:</p>



<pre>
C-(		;; start macro defun
C-r		;; isearch-backward
SPC		;; self-insert-command
C-f		;; forward-char-command
C-SPC       ;; set-mark-command
C-s		;; isearch-forward
,			;; self-insert-command
RET		;; newline
C-b		;; backward-char-command
C-x C-x	;; exchange-point-and-mark
C-x x	;; copy-to-register
a			;; self-insert-command
C-n		;; next-line
C-e		;; end-of-line
SPC		;; self-insert-command
=&gt;		;; self-insert-command * 2
SPC		;; self-insert-command
M-:		;; eval-expression
(insert	;; self-insert-command * 7
SPC		;; self-insert-command
(number- to- string	;; self-insert-command * 17
SPC		;; self-insert-command
(+			;; self-insert-command * 2
SPC		;; self-insert-command
1			;; self-insert-command
SPC		;; self-insert-command
C-x r g	;; insert-register
a			;; self-insert-command
C-e		;; end-of-line
)))		;; self-insert-command * 3
RET		;; newline
,			;; self-insert-command
C-e		;; end-of-line
C-)		;; end macro defun
</pre>



<p>The interesting part is the M-: line, which starts a lisp eval mini-buffer, into which I insert: <code>(insert (number-to-string (+ 1 CURVAL)))</code>, with <span class="caps">CURVAL </span>being inserted from the register. You can then run the macro as many times as needed (with C-x e) to comple all lines.</p>

<p>All those who are now thinking that it would probably have been quicker to either a) just do it all by hand or b) write a perl/python/ruby one-liner and run it over the text; are obviously not true emacs aficiandos.</p>]]></content:encoded>
      <dc:subject>Emacs</dc:subject>
      <dc:date>2005-04-27T16:08:26-08:00</dc:date>
    </item>
    <item>
      <title>LibraryLookup for VPL</title>
      <link>http://www.deftcode.com/archives/librarylookup_for_vpl.html</link>
      <description>I was pretty impressed by Jon Udell&amp;#8217;s LibraryLookup Greasemonkey script, so I adapted it for Vancouver Public Library. What this does is automatically do a lookup in the VPL catalogue whenever you&amp;#8217;re viewing a title on Amazon; if VPL has...</description>
      <guid isPermaLink="false">1443@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>I was pretty impressed by Jon Udell&#8217;s <a title="Jon Udell: Sufficiently simple technology" href="http://weblog.infoworld.com/udell/2005/04/04.html#a1207">LibraryLookup Greasemonkey script</a>, so I <a href="http://deftcode.com/code/LibraryLookup.user.js">adapted it for Vancouver Public Library</a>. What this does is automatically do a lookup in the <span class="caps">VPL </span>catalogue whenever you&#8217;re viewing a title on Amazon; if <span class="caps">VPL </span>has the item a link will be added to it. This requires the <a href="http://greasemonkey.mozdev.org/">latest version</a> of greasemonkey (version 0.2.6 as of this post).</p>]]></content:encoded>
      <dc:subject>mozilla</dc:subject>
      <dc:date>2005-04-06T22:11:56-08:00</dc:date>
    </item>
    <item>
      <title>Paul Graham is a Weenis</title>
      <link>http://www.deftcode.com/archives/paul_graham_is_a_weenis.html</link>
      <description>Maciej Ceglowski has an opinion about Paul Graham. I am still giggling. Much like with David Foster Wallace, be sure to read the footnotes....</description>
      <guid isPermaLink="false">1442@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p><a href="http://www.idlewords.com/2005/04/dabblers_and_blowhards.htm">Maciej Ceglowski has an opinion about Paul Graham</a>. I am still giggling. Much like with David Foster Wallace, be sure to read the footnotes.</p>]]></content:encoded>
      <dc:subject>Humour</dc:subject>
      <dc:date>2005-04-05T10:08:40-08:00</dc:date>
    </item>
    <item>
      <title>Ruby Bloglines OSD Notifier</title>
      <link>http://www.deftcode.com/archives/ruby_bloglines_osd_notifier.html</link>
      <description>Another little bit of somewhat useful code: bloglinesosd.rb. It&amp;#8217;s pretty basic - it checks bloglines for unread entries and displays a count using the xosd library. Enjoy, and as always have the appropriate amount of fun....</description>
      <guid isPermaLink="false">1441@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>Another little bit of somewhat useful code: <a href="http://deftcode.com/code/bloglinesosd.rb">bloglinesosd.rb</a>. It&#8217;s pretty basic - it checks bloglines for unread entries and displays a count using the <a href="http://www.ignavus.net/software.html">xosd</a>  library. Enjoy, and as always have the appropriate amount of fun.</p>]]></content:encoded>
      <dc:subject>Ruby</dc:subject>
      <dc:date>2005-03-30T21:02:12-08:00</dc:date>
    </item>
    <item>
      <title>Delicious autocomple</title>
      <link>http://www.deftcode.com/archives/delicious_autocomple.html</link>
      <description>Del.Icio.Us Auto-Complete - another awesome greasemonkey user script; provides autocomplete for your tags when using the del.icio.us bookmark service....</description>
      <guid isPermaLink="false">1431@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p><a title="Del.Icio.Us Auto-Complete - John Resig" href="http://ejohn.org/projects/autodelicious/">Del.Icio.Us Auto-Complete</a> - another awesome <a href="http://greasemonkey.mozdev.org/">greasemonkey</a>  user script; provides autocomplete for your tags when using the <a href="http://del.icio.us/">del.icio.us bookmark service</a>.</p>]]></content:encoded>
      <dc:subject>mozilla</dc:subject>
      <dc:date>2005-03-26T12:38:02-08:00</dc:date>
    </item>
    <item>
      <title>Ruby Flickr Upload Script</title>
      <link>http://www.deftcode.com/archives/ruby_flickr_upload_script.html</link>
      <description>I&amp;#8217;ve been playing around with Ruby for a while, and finally came up with something useful: rflick.rb, an uploader script written in Ruby. (You can definitely pick your language when it comes to command line uploaders.) The actual development of...</description>
      <guid isPermaLink="false">1429@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>I&#8217;ve been playing around with <a href="http://www.ruby-lang.org">Ruby</a> for a while, and finally came up with something useful: <a href="http://deftcode.com/code/flickr_upload/">rflick.rb</a>, an uploader script written in Ruby. (You can definitely <a href="http://flickr.com/services/api/">pick your language</a> when it comes to command line uploaders.) </p>

<p>The actual development of the script was fairly easy: ruby&#8217;s built in support for option parsing, <span class="caps">YAML, </span>and <span class="caps">XML </span>made things simple. The only irritating part was the <span class="caps">HTTP POST </span>of the image file, which I found is not supported by the ruby&#8217;s (otherwise excellent) standard http lib. (In case you think this an unreasonable expectation, <a href="http://www.icewalkers.com/Perl/5.8.0/lib/HTTP/Request/Common.html">perl does this</a>.) A rousing bout of googling lead me to <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113774">this</a>, which I used to extract a reasonably generic multipart/form-data helper class.</p>

<p>This is the first public release, so please let me know if you use it and if you discover any problems. If you&#8217;re a developer looking for the rest of the flickr <span class="caps">API </span>in Ruby, you want <a href="http://premshree.seacrow.com/code/ruby/flickr-ruby">this</a>. (Which I initially found <a href="http://holycola.net/archives/000719.html">here</a>, which lead to the creation of the upload script. And now you know&#8230; the rest of the story.)</p>]]></content:encoded>
      <dc:subject></dc:subject>
      <dc:date>2005-03-24T21:59:32-08:00</dc:date>
    </item>
    <item>
      <title>Ignorance is bliss</title>
      <link>http://www.deftcode.com/archives/ignorance_is_bliss.html</link>
      <description>I thought this greasemonkey userscript, which automatically ignores stories about Michael Jackson in the reuter&amp;#8217;s feed in bloglines, was pretty clever, but it&amp;#8217;s not nearly agressive enough about hiding things I don&amp;#8217;t want to know about. A wee bit of...</description>
      <guid isPermaLink="false">1422@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>I thought <a href="http://sharedobject.org/greasemonkey/michaeljackson.reuters.user.js">this greasemonkey userscript</a>, which automatically ignores stories about Michael Jackson in the reuter&#8217;s feed in bloglines, was pretty clever, but it&#8217;s not nearly agressive enough about hiding things I don&#8217;t want to know about. A wee bit of hackery later, I present: <a href="http://deftcode.com/code/ignoreStories.user.js">Mental Health Through Ignorance</a>, a <a href="http://greasemonkey.mozdev.org/">greasemonkey</a> script that will hide any stories matching specified strings. A link is provided if you want to risk your zen state and read the hidden story.</p>

<p>By default, anything with the strings &#8216;michael jackson&#8217; or &#8216;scott peterson&#8217; are ignored. If you want to change this script to alter the strings that will trigger the hiding behaviour, here&#8217;s what you do:</p>

<ol>
 <li>Download the script into a text file on your computer; you can call it anything you want as long as it ends with .user.js
 <li>look for the line <code>var toMatch = [&quot;michael jackson&quot;, &quot;scott peterson&quot;];</code>
 <li>let&#8217;s say you wanted to add Robert Blake and OJ Simpson to the list and remove Scott Peterson, you would change this line to read: <code>var toMatch = [&quot;michael jackson&quot;, &quot;robert blake&quot;, &quot;oj simpsons&quot;];</code>. The rule is to put the bits you want matched between quotes, with the bits separated by commas. (Aside to people who know what they&#8217;re doing and are wondering about using regexps: go crazy. Whatever you put in the array is compiled to regexp objects and used as the matcher.)
 <li>save the file and open it in your browser. Click Tools/Install User Script. You&#8217;re done.
</ol>

<p>Happy blissful ignorance!</p>

<p><strong>Update</strong>: A wee bit of tweaking: the text informing you of a hidden story now gives you the matched text. Fixed problem where multiple matches meant you couldn&#8217;t view the story (although really, you probably shouldn&#8217;t).</p>

<p>PS: I am a complete neophyte when it comes to JavaScript and <span class="caps">DOM</span>; using this code as an example of how to do things is probably unwise with a capital <span class="caps">UN.</span></p>]]></content:encoded>
      <dc:subject>mozilla</dc:subject>
      <dc:date>2005-03-17T17:22:51-08:00</dc:date>
    </item>
    <item>
      <title>Easy XPath Fiddling</title>
      <link>http://www.deftcode.com/archives/easy_xpath_fiddling.html</link>
      <description>It&amp;#8217;s always a pleasure to find a tool that is easy to try out, and XPath Explorer certainly fits the bill: download a jar, run it with java -jar, and you&amp;#8217;re testing XPath expressions. No dependency hell, no tracking down...</description>
      <guid isPermaLink="false">1418@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>It&#8217;s always a pleasure to find a tool that is easy to try out, and <a href="http://www.purpletech.com/xpe/index.jsp">XPath Explorer</a> certainly fits the bill: download a jar, run it with java -jar, and you&#8217;re testing XPath expressions. No dependency hell, no tracking down libs from a thousand sourceforge and jakarta sites. Nice.</p>]]></content:encoded>
      <dc:subject>XML</dc:subject>
      <dc:date>2005-03-09T16:56:46-08:00</dc:date>
    </item>
    <item>
      <title>Attention Canadian Geeks</title>
      <link>http://www.deftcode.com/archives/attention_canadian_geeks.html</link>
      <description>Amazon.ca has a bunch of computer books 50% off. Especially tempting is the 3 volume set of Art of Computer Programming for only $99....</description>
      <guid isPermaLink="false">1387@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p><a title="RedFlagDeals.com: The Deals Page" href="http://www.redflagdeals.com/deals/main.php/weblog/tbp_jan_25_amazon/">Amazon.ca has a bunch of computer books 50% off</a>. Especially tempting is the 3 volume set of Art of Computer Programming for only $99.</p>]]></content:encoded>
      <dc:subject></dc:subject>
      <dc:date>2005-01-25T19:12:50-08:00</dc:date>
    </item>
    <item>
      <title>Tool Cruft</title>
      <link>http://www.deftcode.com/archives/tool_cruft.html</link>
      <description>Tool Cruft: The question is this: What new tool are you missing out on because of your blind faith in old reliable? A better way of saying this is, what opportunity are you missing? I will be typing C-x C-s...</description>
      <guid isPermaLink="false">1371@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p><a href="http://www.randsinrepose.com/archives/2004/12/21/tool_cruft.html">Tool Cruft</a>:</p>

<blockquote>The question is this: What new tool are you missing out on because of your blind faith in old reliable? A better way of saying this is, what opportunity are you missing?</blockquote>

<p>I will be typing C-x C-s to save documents until I die, personally.</p>]]></content:encoded>
      <dc:subject>Programming Practices</dc:subject>
      <dc:date>2004-12-21T14:13:41-08:00</dc:date>
    </item>
    <item>
      <title>Top 10 Java Books</title>
      <link>http://www.deftcode.com/archives/top_10_java_books.html</link>
      <description>del.icio.us is down, so: Top 10 Must Read Books for the Java Programmer. Title should perhaps be &amp;#8220;The Top 10 Must Read Books for the Open Source Server-Side Java Programmer&amp;#8221;, but it works for me....</description>
      <guid isPermaLink="false">1358@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>del.icio.us is down, so: <a href="http://www.manageability.org/blog/stuff/top-10-must-read-books-for-the-java-developer">Top 10 Must Read Books for the Java Programmer</a>. Title should perhaps be &#8220;The Top 10 Must Read Books for the Open Source Server-Side Java Programmer&#8221;, but it works for me.</p>]]></content:encoded>
      <dc:subject>Java</dc:subject>
      <dc:date>2004-11-30T08:21:15-08:00</dc:date>
    </item>
    <item>
      <title>Persistent JVM</title>
      <link>http://www.deftcode.com/archives/persistent_jvm.html</link>
      <description>Great idea: run your java code in a persistent jvm....</description>
      <guid isPermaLink="false">1354@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>Great idea: <a title="Martian Software - NailGun: Insanely Fast Java" href="http://www.martiansoftware.com/nailgun/">run your java code in a persistent jvm</a>.</p>]]></content:encoded>
      <dc:subject>Java</dc:subject>
      <dc:date>2004-11-22T09:05:06-08:00</dc:date>
    </item>
    <item>
      <title>End of Moore&apos;s Law at Intel?</title>
      <link>http://www.deftcode.com/archives/end_of_moores_law_at_intel.html</link>
      <description>I don&amp;#8217;t pay enough attention to the chip market to really know whether this is a big deal or not, but if I read it right, Moore&amp;#8217;s Law won&amp;#8217;t apply to consumer chips anymore: Intel Corp. on Thursday canceled plans...</description>
      <guid isPermaLink="false">1331@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>I don&#8217;t pay enough attention to the chip market to really know whether <a href="http://www.reuters.com/newsArticle.jhtml?type=technologyNews&amp;storyID=6506690&amp;pageNumber=0">this</a> is a big deal or not, but if I read it right, Moore&#8217;s Law won&#8217;t apply to consumer chips anymore:</p>

<blockquote>
Intel Corp. on Thursday canceled plans to introduce its highest-speed desktop computer chip, ending for now a 25-year run that has seen the speeds of Intel&#8217;s microprocessors increase by more than 750 times.

<p>&#8230;</p>

Both Intel and its arch-rival, Advanced Micro Devices Inc.  , have shifted their focus from increasing clock speed &#8212; a measure of how fast a chip can crunch numbers &#8212; to a less quantitative goal of performance encompassing multi-tasking, security, and multimedia.<br />
</blockquote>]]></content:encoded>
      <dc:subject>Hardware</dc:subject>
      <dc:date>2004-10-14T16:57:28-08:00</dc:date>
    </item>
    <item>
      <title>desktop google</title>
      <link>http://www.deftcode.com/archives/desktop_google.html</link>
      <description>You have, of course, already heard of Google Desktop. Two initial thoughts: No support for mozilla/firefox browsing history? I could be completely off base on this, but isn&amp;#8217;t the likely early-adopter segment also likely to be using non-IE browsers? No...</description>
      <guid isPermaLink="false">1330@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>You have, of course, already heard of <a href="http://desktop.google.com/">Google Desktop</a>. Two initial thoughts:</p>

<ul>
 <li>No support for mozilla/firefox browsing history? I could be completely off base on this, but isn&#8217;t the likely early-adopter segment also likely to be using non-IE browsers? 
  <li>No option to search google mail? Seems a bit of a no-brainer to me.
</ul>]]></content:encoded>
      <dc:subject></dc:subject>
      <dc:date>2004-10-14T14:25:07-08:00</dc:date>
    </item>
    <item>
      <title>Crop Circles: The Language</title>
      <link>http://www.deftcode.com/archives/crop_circles_the_language.html</link>
      <description>I can finally stop calculating my crop circles by hand: crop, a language for crop circles. (via)...</description>
      <guid isPermaLink="false">1319@http://www.deftcode.com/</guid>
      <content:encoded><![CDATA[<p>I can <em>finally</em> stop calculating my crop circles by hand: <a href="http://www.glassner.com/andrew/cg/research/crop/crop.htm">crop</a>, a language for crop circles. (<a href="http://www.mono211.com/links/archive/2004_10.html">via</a>)</p>]]></content:encoded>
      <dc:subject>Humour</dc:subject>
      <dc:date>2004-10-01T17:20:23-08:00</dc:date>
    </item>


  </channel>
</rss>