<?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>module?.exports = Blog &#187; javascript</title>
	<atom:link href="http://benatkin.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://benatkin.com</link>
	<description>Ben Atkin&#039;s blog</description>
	<lastBuildDate>Thu, 10 May 2012 04:36:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>br-jquery: a jquery package for the browserify javascript packager for node.js</title>
		<link>http://benatkin.com/2012/01/22/br-jquery-node/</link>
		<comments>http://benatkin.com/2012/01/22/br-jquery-node/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 22:49:27 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[announcement]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[node]]></category>

		<guid isPermaLink="false">http://benatkin.com/?p=1093</guid>
		<description><![CDATA[I published a node.js package to npm called br-jquery, which contains jQuery and provides an alternate path to downloading jQuery and putting it in a repository when starting a jQuery project. It is a lot like jquery-browserify, but it contains &#8230; <a href="http://benatkin.com/2012/01/22/br-jquery-node/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I published a node.js package to npm called <a href="https://github.com/benatkin/br-jquery">br-jquery</a>, which contains jQuery and provides an alternate path to downloading jQuery and putting it in a repository when starting a jQuery project. It is a lot like <a href="http://github.com/jmars/jquery-browserify">jquery-browserify</a>, but it contains a newer version of jQuery (1.7.1) and has the minified version as well. Additionally it has a build script which fetches jQuery and a full <a href="https://github.com/benatkin/br-jquery/tree/master/example">example</a>.</p>
<p><a href="https://github.com/substack/node-browserify">Browserify</a> creates bundles from node.js-style CommonJS modules. It stubs out some core functionality so node.js modules with minimal dependencies can be used in the browser. Here is some JavaScript taken from the example, that creates a bundle:</p>
<pre class="brush: jscript; title: ; notranslate">
var js = require('browserify')({
  require: {jquery: 'br-jquery'},
  entry: 'hello.js'
}).bundle()
</pre>
<p>The <i>require</i> property is used to , and the <i>entry</i> property is used to include a module that will be run when the bundle is loaded. The <i>entry</i> module starts by requiring jQuery:</p>
<pre class="brush: jscript; title: ; notranslate">
var $ = require('jquery');
$(function() {
  // manipulate the DOM here...
});
</pre>
<p>I really like the browserify way of doing things. Instead of adapting browser code to run on the server, it adapts server code to run on the browser!</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/benatkin/br-jquery/">br-jquery</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/benatkin/">benatkin</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-03-24</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">10</span></div><div class="resource-infobox-clear"></div></div>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/substack/node-browserify/">node-browserify</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/substack/">substack</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-05-17</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">861</span></div><div class="resource-infobox-clear"></div></div>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/jquery/jquery/">jquery</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/jquery/">jquery</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-05-17</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">14063</span></div><div class="resource-infobox-clear"></div></div>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2012/01/22/br-jquery-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links: Parsing in Ruby and JavaScript</title>
		<link>http://benatkin.com/2011/12/01/parsing-in-ruby-and-javascript/</link>
		<comments>http://benatkin.com/2011/12/01/parsing-in-ruby-and-javascript/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 06:53:38 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://benatkin.com/?p=1067</guid>
		<description><![CDATA[I&#8217;ve been reading quite a bit about parsing and templating in ruby as I attempt to port a templating engine from JavaScript to Ruby. Here are some scattered links: Jison Jison is a parser generator for JavaScript that has separate &#8230; <a href="http://benatkin.com/2011/12/01/parsing-in-ruby-and-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading quite a bit about parsing and templating in ruby as I attempt to port a templating engine from JavaScript to Ruby. Here are some scattered links:</p>
<h3>Jison</h3>
<p>Jison is a parser generator for JavaScript that has separate lex and bnf definitions. It&#8217;s used by <a href="https://github.com/wycats/handlebars.js/">Handlebars.js</a>.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/zaach/jison/">jison</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/zaach/">zaach</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-05-16</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">560</span></div><div class="resource-infobox-clear"></div></div>
<h3>Treetop</h3>
<p>Treetop is a parser generator for Ruby. It&#8217;s installed with Ruby On Rails, through the <code>mail</code> gem which is installed by ActionMailer.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/nathansobo/treetop/">treetop</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/nathansobo/">nathansobo</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-03-29</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">447</span></div><div class="resource-infobox-clear"></div></div>
<h3>Citrus</h3>
<p>Citrus is another promising parsing gem for Ruby. It seems to be very easy to get started with, and I like many of the design decisions.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/mjijackson/citrus/">citrus</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/mjijackson/">mjijackson</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-02-24</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">177</span></div><div class="resource-infobox-clear"></div></div>
<h3>Temple</h3>
<p>Temple is a templating-specific library that helps with a lot of the AST transformation. It doesn&#8217;t seem to have a CFG syntax so it seems that using treetop or citrus would make sense for complex grammars. Otherwise, strscan could be used.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/judofyr/temple/">temple</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/judofyr/">judofyr</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-02-26</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">154</span></div><div class="resource-infobox-clear"></div></div>
<h3>temple-mustache</h3>
<p>This is an implementation of a mustache renderer in . It uses strscan to generate the initial parse tree, and Temple to generate the ruby code. It supports mustache sections.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/minad/temple-mustache/">temple-mustache</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/minad/">minad</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2011-05-04</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">1</span></div><div class="resource-infobox-clear"></div></div>
<h3>Slim</h3>
<p>Slim is a Haml-like templating library for Ruby that&#8217;s used in production by many. It uses Temple, with a line-based parser, which works well because it uses significant indentation for nesting.</p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/stonean/slim/">slim</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/stonean/">stonean</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-04-14</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">1119</span></div><div class="resource-infobox-clear"></div></div>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2011/12/01/parsing-in-ruby-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.7.0 is out!</title>
		<link>http://benatkin.com/2011/11/04/jquery-1-7-0-is-out/</link>
		<comments>http://benatkin.com/2011/11/04/jquery-1-7-0-is-out/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 10:20:20 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://benatkin.com/?p=1015</guid>
		<description><![CDATA[&#8230;and I like the new .on() and .off() API for setting up events. I wrote some code that uses it, just for practice. Nothing too fancy.]]></description>
			<content:encoded><![CDATA[<p>&#8230;and I like <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">the new <em>.on()</em> and <em>.off()</em> API for setting up events.</a></p>
<p>I wrote some code that uses it, just for practice.</p>
<pre class="brush: jscript; title: ; notranslate">
$.fn.tree = function(data) {
  var $el = $(this),
      html = [];

  function renderNode(node) {
    if (typeof node === "object") {
      html.push("&lt;ul&gt;");
      for (var key in node) {
        if (node.hasOwnProperty(key)) {
          html.push("&lt;li&gt;&lt;strong&gt;" + key + ": &lt;/strong&gt;");
          html.push(typeof node[key] == "object" ? renderNode(node[key]) : node[key]);
          html.push("&lt;/li&gt;");
        }
      }
      html.push("&lt;/ul&gt;");
    }
  }

  renderNode(data);
  $el.html(html.join(""));

  $el.on('click', 'strong', function() {
    $(this).closest('li').find('ul').toggle(200);
  });
};

$("&lt;div&gt;").appendTo("body").tree({
  name: {
    first: "Benjamin",
    last: "Atkin"
  },
  location: {
    city: "Boulder",
    state: "CO"
  },
  accounts: {
    social: {
      twitter: "http://twitter.com/benatkin",
      facebook: "http://facebook.com/atkin",
      gplus: "http://gplus.to/benatkin",
      identica: "http://identi.ca/benatkin",
      rstatus: "http://rstat.us/bat"
    },
    creative: {
      github: "http://github.com/benatkin",
      blog: "http://benatkin.com/"
    }
  }
});
</pre>
<p><a href="http://jsbin.com/opicit">Nothing too fancy.</a></p>
<div class="resource-infobox"><div class="resource-infobox-field"><span class="resource-infobox-label">Repository</span><a class="resource-infobox-value" href="https://github.com/jquery/jquery/">jquery</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Owner</span><a class="resource-infobox-value" href="https://github.com/jquery/">jquery</a></div><div class="resource-infobox-field"><span class="resource-infobox-label">Last Commit</span><span class="resource-infobox-value">2012-05-17</span></div><div class="resource-infobox-field"><span class="resource-infobox-label">Watchers</span><span class="resource-infobox-value">14063</span></div><div class="resource-infobox-clear"></div></div>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2011/11/04/jquery-1-7-0-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SyntaxHighlighter Evolved: how it works</title>
		<link>http://benatkin.com/2011/09/21/syntaxhighlighter-evolved/</link>
		<comments>http://benatkin.com/2011/09/21/syntaxhighlighter-evolved/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 00:26:56 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Syntax Highlighting]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://benatkin.com/?p=904</guid>
		<description><![CDATA[I installed a WordPress plugin called SyntaxHighlighter Evolved, which highlights source code with client-side JavaScript. Here are a few notes about how it works: Code can be inserted using a Shortcode. Thanks to how Shortcodes work, HTML entities don&#8217;t need &#8230; <a href="http://benatkin.com/2011/09/21/syntaxhighlighter-evolved/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I installed a WordPress plugin called <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter Evolved</a>, which highlights source code with client-side JavaScript. Here are a few notes about how it works:</p>
<ul>
<li>Code can be inserted using a <a href="http://codex.wordpress.org/Shortcode_API">Shortcode</a>. Thanks to how Shortcodes work, HTML entities don&#8217;t need to be escaped in the HTML view.</li>
<li>It uses a lot of Shortcode tags, one for each language, like <em>php</em>, so there is minimal overhead to inserting code snippets. This is a good decision in my opinion, because it gets used so often on code blogs.
</li>
<li>The underlying library, <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a>, has a core that contains generic features for highlighting code, and contains brushes for highlighting different languages. These are <a href="https://github.com/alexgorbatchev/SyntaxHighlighter/blob/master/scripts/shBrushPython.js">mostly data</a>.</li>
<li>The JavaScript code for SyntaxHighlighter is included at the end of the page, and only the needed brushes are included. Apparently when shortcodes are used, a language or brush name is added to a variable, and at the end of the page, it adds the appropriate script tag(s).</li>
</ul>
<p>Finally, here are a couple of examples. This one is the included php brush:</p>
<pre class="brush: php; title: ; notranslate">
function factorial($x) {
  if ($x &gt; 1) {
    return $x * factorial($x-1);
  } else {
    return $x;
  }
}
</pre>
<p>And here is the <a href="http://wordpress.org/extend/plugins/syntaxhighlighter-coffeescript-brush/">CoffeeScript brush, which is provided by another plugin</a> that depends upon the SyntaxHighlighter Evolved plugin:</p>
<pre class="brush: coffeescript; title: ; notranslate">
passed = (score for score in scores when score &gt; 60)
</pre>
<p>I really like this plugin. It&#8217;s a very complete solution. That said, I&#8217;d really like to be using ACE editor or CodeMirror to insert/edit snippets in blog posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2011/09/21/syntaxhighlighter-evolved/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery UI widgets</title>
		<link>http://benatkin.com/2009/09/08/jquery-ui-widgets/</link>
		<comments>http://benatkin.com/2009/09/08/jquery-ui-widgets/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 04:17:52 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://benatkin.com/weblog/?p=459</guid>
		<description><![CDATA[JavaScript is a prototyping programming language, and as such, has many different ways to define classes or create objects. If you try to search for a tutorial on object-oriented programming in JavaScript, you&#8217;ll find that each tutorial has its own &#8230; <a href="http://benatkin.com/2009/09/08/jquery-ui-widgets/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JavaScript is a prototyping programming language, and as such, has many different ways to define classes or create objects. If you try to search for a tutorial on object-oriented programming in JavaScript, you&#8217;ll find that each tutorial has its own way of doing things. It can be very confusing.</p>
<p>Fortunately, jQuery UI has a widget framework, that makes setting up object-oriented widgets easy. After using it, I wanted to use it for everything, until I find something at least as easy to use as it. I didn&#8217;t, however, want to include a large dependency like jQuery UI if I was only using it for its widget framework.</p>
<p>I was glad to find, after a little experimentation with the Build Your Download page, that I can get jQuery UI&#8217;s widget framework in a download of only 9.06 kb minified. You can get this by clicking Deselect All and checking UI Core. After that, the theme drop-down box should be set to No Theme.</p>
<p>I made a geocoding widget for Django in a project for a client using this. It simplified my code a great deal.</p>
<p>One thing it does that&#8217;s good for projects that might have a lot of custom widgets on one page (which was not the case for this one) is it takes care of using jQuery&#8217;s data() method, which stores objects in a way that is less likely to cause memory leak issues in Internet Explorer than storing objects using closures.</p>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2009/09/08/jquery-ui-widgets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery example: gather</title>
		<link>http://benatkin.com/2009/06/23/jquery-example-gather/</link>
		<comments>http://benatkin.com/2009/06/23/jquery-example-gather/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 06:24:43 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://benatkin.com/weblog/?p=422</guid>
		<description><![CDATA[Here&#8217;s an example I whipped together to show some of what I learned from reading about the jQuery Event object. It shows that events can pass data as they bubble up. gather.html &#8211; demo (my site) gather.html &#8211; demo source &#8230; <a href="http://benatkin.com/2009/06/23/jquery-example-gather/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an example I whipped together to show some of what I learned from reading about the <a href="http://docs.jquery.com/Events/jQuery.Event">jQuery Event object</a>. It shows that events can pass data as they bubble up.</p>
<ol>
<li><a href="http://benatkin.com/jquery-stuff/gather.html"><strong>gather.html</strong> &#8211; demo (my site)</a></li>
<li><a href="http://github.com/benatkin/jquery-stuff/blob/master/gather.html"><strong>gather.html</strong> &#8211; demo source (github)</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2009/06/23/jquery-example-gather/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery plugin: convenience</title>
		<link>http://benatkin.com/2009/06/23/jquery-plugin-convenience/</link>
		<comments>http://benatkin.com/2009/06/23/jquery-plugin-convenience/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 21:42:00 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://benatkin.com/weblog/?p=419</guid>
		<description><![CDATA[jQuery has convenience functions for events like click and keydown, and lets you create and use your own events with bind() and trigger(), but doesn&#8217;t provide a way to create your own convenience functions for custom events. I took several &#8230; <a href="http://benatkin.com/2009/06/23/jquery-plugin-convenience/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>jQuery has convenience functions for events like click and keydown, and lets you create and use your own events with bind() and trigger(), but doesn&#8217;t provide a way to create your own convenience functions for custom events. I took several lines of code from the jQuery source and created a plugin that makes creating convenience functions as easy as calling $.convenience(&#8216;nameOfFunction&#8217;). Then I can bind or trigger an event simply by calling nameOfFunction() on the selector. This should be apparent by looking at the <a href="http://github.com/benatkin/jquery-stuff/blob/fc86b3c1e23c716469841759677f9617bc712ae7/convenience.html">demo source</a> (the third link).</p>
<ol>
<li><a href="http://github.com/benatkin/jquery-stuff/blob/fc86b3c1e23c716469841759677f9617bc712ae7/jquery.convenience.js"><strong>jquery.convenience.js </strong>- plugin source (github)</a></li>
<li><a href="http://benatkin.com/jquery-stuff/convenience.html"><strong>convenience.html</strong> &#8211; demo (my site)</a></li>
<li><a href="http://github.com/benatkin/jquery-stuff/blob/fc86b3c1e23c716469841759677f9617bc712ae7/convenience.html"><strong>convenience.html</strong> &#8211; demo source (github)</a></li>
</ol>
<p>The example shows one feature of custom events that I overlooked: <a href="http://docs.jquery.com/Events/trigger#eventdata">propagation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2009/06/23/jquery-plugin-convenience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fewer twitter interruptions with TwitterFox</title>
		<link>http://benatkin.com/2008/09/14/fewer-twitter-interruptions-with-twitterfox/</link>
		<comments>http://benatkin.com/2008/09/14/fewer-twitter-interruptions-with-twitterfox/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 08:43:51 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.benatkin.com/weblog/?p=156</guid>
		<description><![CDATA[Update: I was wrong about the popup preference not working. I had forgotten to turn off popup balloons on one of my computers, and missed a return statement while reading the source code. So my changes are unnecessary. I am &#8230; <a href="http://benatkin.com/2008/09/14/fewer-twitter-interruptions-with-twitterfox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> <em>I was wrong about the popup preference not working. I had forgotten to turn off popup balloons on one of my computers, and missed a return statement while reading the source code. So my changes are unnecessary.</em></p>
<p>I am a big fan of <a href="http://twitter.com/">twitter</a>. I use it all the time. I follow a lot of people. Some I know personally, some I&#8217;ve only met online, and some I have never met. I like to interact with people on twitter in real time.</p>
<p>Of course, the benefits of twitter come at the cost of time. The little bits of time here and there spent reading and posting tweets add up. It can also cause interruptions, making it hard to focus.</p>
<h2>twitter.com and twhirl</h2>
<p>I used twitter.com at first, then <a href="http://www.twhirl.org/">twhirl</a>, and twitter.com again before I discovered TwitterFox.</p>
<p>The biggest problem with using twitter.com is that I have to load twitter.com to check for new tweets, whether or not there are any new tweets. It takes a while to load a web page. Usually that is an interruption in itself. Usually I either miss the action on twitter or I obsessively check twitter.com to see if there are any new tweets. On days when I&#8217;m feeling less motivated or more curious about what&#8217;s happening on twitter it is usually the latter.</p>
<p>For a month or two I used <a href="http://www.twhirl.org/">twhirl</a> to access twitter. There are two different ways of using it, each of which has its own problems. One way is the default, where it pops up new messages in the lower-right corner of the screen. This is the way most desktop twitter clients work. The problem with this is obvious: it&#8217;s an interruption, plain and simple. If I&#8217;m in the zone, I will likely get distracted. The other way of using twhirl is to turn off pop-up messages, and to either give the window some space on the screen or to switch to it using Alt-Tab to check tweets. The problem with this is it quickly devolves into a glancing or Alt-Tab frenzy, as at any time when I&#8217;m even slightly curious about what&#8217;s happening on twitter, I can check in an instant. Often times when I would check I would find no new tweets.</p>
<h2>the twitter urge</h2>
<p>Every so often I get the urge to check twitter. It&#8217;s perfectly natural for anyone who has discovered the joy of using twitter. What matters is what I do with those urges. If every urge turns into reading a list of twitter messages, it can turn into a real productivity killer.</p>
<p>For a while I&#8217;ve known the way that I would like to be able to use twitter. I would like a number of new messages on the screen. Then, if I got the twitter urge and there weren&#8217;t any new messages, it would only cause a split-second of interruption. If there were any new messages, I would know, and if I didn&#8217;t check even though there were new messages, I could give myself a pat on the back for staying productive, and know that once I got more work done I would have something to read.</p>
<p>After a week of being frustrated with twitter, I decided to do something about it. So I looked at the list of twitter clients again and tried a couple out. I wanted one that was open source and easy to customize.</p>
<h2>TwitterFox</h2>
<p>I spend enough time in Firefox, both at work and on my laptop, that having something in the Firefox status bar is pretty much as good as having something in the taskbar, if not better. Firefox extensions are also easy to customize (unless the code is a mess), so I gave it a try. When I saw the number of new tweets in the lower-right corner of my Firefox window, I was elated. This is exactly what I wanted!</p>
<p><img class="aligncenter size-full wp-image-160" title="twitterfox" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/twitterfox.png" alt="" width="317" height="408"></p>
<p>It worked really well for me, once I figured out how to turn off popup balloons, where it would show the latest tweet(s) in the bottom-right corner, much like twhirl. At first, I thought the preference wasn&#8217;t working, so I made changes to the source code. I found tinkering with the source code to be relatively easy. Since I&#8217;m a web developer, I&#8217;m very comfortable working in JavaScript.</p>
<p>The tiny difference between TwitterFox and twhirl that makes it work for me is that the number of messages appears on a part of the screen that I see regularly. The information I need is there, and presented in a way that is not distracting. This is also the way I keep tabs on my e-mail (GMail) and my RSS Feeds (Google Reader), though I like the way TwitterFox shows the number better. GMail and Google Reader have the number of new items in their titles, which appear in the Firefox tab bar. Sometime I&#8217;d like to find or make extensions that will show the number of new items in those two web apps in the Firefox status bar.</p>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2008/09/14/fewer-twitter-interruptions-with-twitterfox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trying Out CouchDB In FireBug</title>
		<link>http://benatkin.com/2008/09/13/trying-out-couchdb-in-firebug/</link>
		<comments>http://benatkin.com/2008/09/13/trying-out-couchdb-in-firebug/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 09:05:22 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.benatkin.com/weblog/?p=116</guid>
		<description><![CDATA[Since I love FireBug, and CouchDB has a JSON API, I attempted to combine the two. My goal was to find a way to use jQuery&#8216;s AJAX functions to create, read, and update CouchDB documents. Getting Started The first thing &#8230; <a href="http://benatkin.com/2008/09/13/trying-out-couchdb-in-firebug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I love <a href="http://getfirebug.com/">FireBug</a>, and <a href="http://incubator.apache.org/couchdb/">CouchDB</a> has a JSON API, I attempted to combine the two. My goal was to find a way to use <a href="http://jquery.com/">jQuery</a>&#8216;s AJAX functions to create, read, and update CouchDB documents.</p>
<h2>Getting Started</h2>
<p>The first thing I tried was creating a merb project with a single page referencing jQuery, and accessing CouchDB from there. The browser&#8217;s security model got in my way, however. A page on one port on localhost can&#8217;t access another port with AJAX. I searched for ways to give a page special permission, but my search turned up empty and I figured that I&#8217;d rather not go against the browser anyway, if I could help it.</p>
<p>The next thing I tried was getting a page that references jQuery to be served by CouchDB&#8217;s web server. That way the page and jQuery&#8217;s JSON API would be on the same port and Firefox would be happy. I opened up CouchDB&#8217;s Futon Utility Client at http://localhost:5984/_utils/ and found that it already had the latest version of jQuery included! Problem solved.</p>
<p>I opened the FireBug console (which was already enabled on localhost from when I was trying to get it working with my Merb project) and started trying out jQuery&#8217;s AJAX functions on CouchDB.</p>
<p style="text-align: center;"><a href="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch1.png"><img class="size-medium wp-image-122 aligncenter" title="couch1" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch1.png" alt="" width="657" height="440"></a></p>
<p style="text-align: left;">The GET request returned successfully! However, FireBug doesn&#8217;t retain the response, so I have to click <strong>Load Response</strong> to get it.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-126" title="couch2" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch2.png" alt="" width="367" height="123"></p>
<p style="text-align: left;">OK, there&#8217;s CouchDB&#8217;s welcome message! Expanding the GET request and clicking <strong>Load Response</strong> is tedious, though, so a better technique is needed. The first thing that comes to mind is doing a synchronous request. I find that get() doesn&#8217;t support this option, so I need to use ajax().</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-127" title="couch3" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch3.png" alt="" width="417" height="82"></p>
<p style="text-align: left;">Aside from FireBug&#8217;s quoting <a href="http://failblog.org/">FAIL</a>, it works nicely. What I&#8217;d really like, though, is for FireBug to pretty-print the JSON. So I throw an eval() statement around it, and add the left side of an assignment statement because otherwise I would get an error (another way to get it working is to throw square brackets around the expression).</p>
<p style="text-align: center;"><img class="size-full wp-image-128 aligncenter" title="couch4" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch4.png" alt="" width="497" height="134"></p>
<p style="text-align: left;">The output is quite a bit nicer, in my opinion.</p>
<h2 style="text-align: left;">Creating a Database</h2>
<p style="text-align: left;">To create a database I use the <a href="http://wiki.apache.org/couchdb/HttpDatabaseApi">HttpDatabaseApi</a> page on the <a href="http://incubator.apache.org/couchdb/">CouchDB wiki</a>. Creating a database requires use of a <strong>PUT</strong> request, which can be made with jQuery&#8217;s ajax() function if the browser supports it (and Firefox does).</p>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-129" title="couch5" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch5.png" alt="" width="500" height="59"></p>
<p style="text-align: left;">CouchDB returns a simple OK message to let me know it worked.</p>
<h2 style="text-align: left;">Creating a Document</h2>
<p style="text-align: left;">Now that I have a database, I can create a document using the HttpDocumentApi. I opt to take the cavalier approach of having the server generate an ID rather than supplying an ID of my own. To do this, I send a POST with the database&#8217;s URL for the address and the document&#8217;s contents for the POST data. To send the POST data, I call ajax() with the document&#8217;s contents (as a JSON expression) for the data option and the string &#8216;json&#8217; for the dataType option.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-135" title="couch7" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch7.png" alt="" width="635" height="210"></p>
<p style="text-align: left;">It didn&#8217;t work. I expand the POST and look at the data sent to find out why.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-136" title="couch8" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch8.png" alt="" width="635" height="210"></p>
<p style="text-align: left;">The ajax() function didn&#8217;t serialize the data! It&#8217;s not built into jQuery. It makes sense, given that one of jQuery&#8217;s features is its small footprint. I remember that when I viewed the source of the main page of CouchDB&#8217;s Futon Utility Client I saw a JSON include. It&#8217;s in <a href="http://localhost:5984/_utils/script/json2.js">http://localhost:5984/_utils/script/json2.js</a>. It&#8217;s not a jQuery plug-in, but its interface is fairly simple. To serialize data, you call JSON.stringify() with an object as the first parameter. I add this to my statement and try again.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-137" title="couch9" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch9.png" alt="" width="634" height="209"></p>
<p style="text-align: left;">It worked! Or, at least, it didn&#8217;t error. It returned a globally unique ID (GUID) generated by the server. Now I use the ID to GET the document&#8217;s contents.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-138" title="couch10" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch10.png" alt="" width="634" height="209"></p>
<p style="text-align: left;">Only a summary of the object is shown. If I click the object it expands to a full view.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-139" title="couch11" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch11.png" alt="" width="633" height="208"></p>
<p style="text-align: left;">The data is there. The revision number is also present. One of CouchDB&#8217;s coolest features is built-in versioning.</p>
<p style="text-align: left;">After I realized that I was given only a summary of the object, I tried creating a document again and seeing if I missed any info that was supplied in the response to the POST request. It turns out that I did. The revision (_rev) was given. I&#8217;d like to have Firebug print out the whole response (and not a short summary), but I don&#8217;t see any way of doing so.</p>
<h2 style="text-align: left;">Updating a Document</h2>
<p style="text-align: left;">Documents can be updated by sending a PUT request with the document&#8217;s URL as the address and the new contents as the data. The new contents must include the revision number upon which the update is based. This is to prevent conflicts. If a revision number other than that of the latest revision is supplied, it means that another client updated it first.</p>
<p style="text-align: left;">I update the document by getting the latest copy, storing it in a variable, removing the ID (since it&#8217;s already in the URL), changing the radius, and sending a PUT request with the new database contents.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-140" title="couch12" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch12.png" alt="" width="634" height="209"></p>
<p style="text-align: left;">The document is updated. If I expand the object I can see the new revision number.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-141" title="couch13" src="http://www.benatkin.com/weblog/wp-content/uploads/2008/09/couch13.png" alt="" width="633" height="208"></p>
<p style="text-align: left;">Pretty cool, huh?</p>
<h2 style="text-align: left;">Conclusion &amp; Next Steps</h2>
<p>Before I tried using CouchDB with Firebug, I tried using the Futon Utility Client. I felt that I learned more and better retained what I learned when I used Firebug. Firebug as it is right now has a couple of issues that will keep me from using it as an environment in which to try doing different things with CouchDB. The first issue is that the pretty-print doesn&#8217;t show the full object in the console view, and there&#8217;s no option in the UI to make it do so. The second issue is that I find the editor to be insufficient. When the editor is in vertical mode, there&#8217;s no way to go through the history of commands entered. When the editor is in horizontal mode, it can&#8217;t expand beyond one line. When I switch between tabs, the text in the editor is often lost.</p>
<p>Firebug is, however, being actively worked on, and will hopefully get some features that will make it easier and more fun to use to play with JavaScript API&#8217;s and web services.</p>
<p>I would like to get the custom JavaScript environment mentioned at the top of this post set up and working with CouchDB. One way to get it working might be to set up a proxy of sorts to CouchDB. I could have any requests starting with /couchdb be forwarded to the CouchDB port with the /couchdb part stripped off.</p>
<p>This was fun. I think the next thing I&#8217;ll do with CouchDB is try writing a simple wiki using CouchDB and Merb.</p>
<p style="text-align: left;">
<p style="text-align: center;">
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2008/09/13/trying-out-couchdb-in-firebug/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>On finding interesting Ubiquity commands&#8230;</title>
		<link>http://benatkin.com/2008/08/28/on-finding-interesting-ubiquity-commands/</link>
		<comments>http://benatkin.com/2008/08/28/on-finding-interesting-ubiquity-commands/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 23:26:18 +0000</pubDate>
		<dc:creator>Ben Atkin</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ubiquity]]></category>

		<guid isPermaLink="false">http://www.benatkin.com/weblog/?p=95</guid>
		<description><![CDATA[I&#8217;ve been trying to find clever Ubiquity commands in the Herd. I want to see things that use the preview functionality in interesting ways, like the built-in map command does. What I&#8217;ve wound up doing so far, though, is sifting &#8230; <a href="http://benatkin.com/2008/08/28/on-finding-interesting-ubiquity-commands/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to find clever <a href="http://wiki.mozilla.org/Labs/Ubiquity">Ubiquity</a> commands in the <a href="https://labs.toolness.com/ubiquity-herd/">Herd</a>. I want to see things that use the preview functionality in interesting ways, like the built-in <strong>map</strong> command does. What I&#8217;ve wound up doing so far, though, is sifting through dozens of commands that do nothing more than what could be done with a custom entry in the Firefox Search Bar, or commands that are nothing but links to another page.</p>
<p>While I think it&#8217;s useful to be able to search and go to websites from a command line, it&#8217;s not what I have in mind when I search for new commands.</p>
<p>I think that search engines and bookmarks should be separated from the rest of the commands, and that posting search engines or bookmarks as commands to the command part of the Herd should be discouraged. This will help in several ways:</p>
<ul>
<li>Users who don&#8217;t know JavaScript will have an easy time adding bookmarks and search engines to Ubiquity and assigning them strings</li>
<li>I&#8217;ll be able to add search engines and bookmarks from websites without having to look at the code or decide whether I can trust the people who write the code</li>
<li>If I provide a bookmark or search engine on my website I won&#8217;t have to worry about convincing my users to trust me enough to install it, since it won&#8217;t be able to send any information from their browser to my website except for a search query</li>
<li>I won&#8217;t have to sift through bookmarks and search engines to find commands that provide advanced functionality</li>
<li>It will encourage website owners to create more powerful Ubiquity commands</li>
</ul>
<p>Ubiquity is at an early stage, so I won&#8217;t be surprised if someone&#8217;s already working on separating simple commands from more complex ones. I hope so. I really want to see Ubiquity catch on, and for that to happen I think it needs to be easier for users to customize their commands.</p>
]]></content:encoded>
			<wfw:commentRss>http://benatkin.com/2008/08/28/on-finding-interesting-ubiquity-commands/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

