<?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>Dodgeball Cannon &#187; Web</title>
	<atom:link href="http://www.johntantalo.com/blog/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johntantalo.com/blog</link>
	<description>It's not so much a time machine as it is my blog.</description>
	<lastBuildDate>Sun, 22 Jan 2012 14:10:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>URI-Escaping JavaScript Bookmarklets in Chrome</title>
		<link>http://www.johntantalo.com/blog/uri-escaping-javascript-bookmarklets-in-chrome/</link>
		<comments>http://www.johntantalo.com/blog/uri-escaping-javascript-bookmarklets-in-chrome/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 21:00:24 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=173</guid>
		<description><![CDATA[John Gruber published a helpful JavaScript Bookmarklet Builder which I used to generate my IPA TTS bookmarklet. A few users reported that Chrome choked on the bookmarklet. I found that the bookmarklet builder does not produce the output that Chrome expects. I was using Chrome 15.0.874.54 beta. For example, take this simple script. (function () [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://daringfireball.net/">John Gruber</a> published a helpful <a href="http://daringfireball.net/2007/03/javascript_bookmarklet_builder">JavaScript Bookmarklet Builder</a> which I used to generate my <a href="http://www.johntantalo.com/blog/ipa-tts-bookmarklet">IPA TTS bookmarklet</a>.</p>
<p>A few users reported that <a href="http://www.google.com/chrome">Chrome</a> choked on the bookmarklet. I found that the bookmarklet builder does not produce the output that Chrome expects. I was using Chrome 15.0.874.54 beta.</p>
<p>For example, take this simple script.</p>
<blockquote><pre><code>(function () {
  // what is 1+1?
  alert(["1+1=",(1+1)].join(''));
})()
</code></pre>
</blockquote>
<p>Gruber&#8217;s script produces this bookmarklet: <a href="javascript:(function%20()%20{alert([%221+1=%22,(1+1)].join(%27%27));})()">Example 1</a></p>
<blockquote><p><code>javascript:(function%20()%20{alert([%221+1=%22,(1+1)].join(%27%27));})()</code></p></blockquote>
<p>If you drag this example to your bookmark bar in Chrome, it will produce this error when invoked.<br />
<blockquote><p><code>Uncaught SyntaxError: Unexpected token %</code></p></blockquote>
<p>What happened? If you edit the bookmark, you will see that Chrome double-escaped the string,</p>
<blockquote><p><code>javascript:(function%2520()%2520%7Balert(%5B%25221+1=%2522,(1+1)%5D.join(%2527%2527));%7D)()</code></p></blockquote>
<p>I believe this happened because the string contained some non-escaped characters such as parentheses.</p>
<p>Gruber points out in a footnote that his script intentionally leaves some characters unescaped for the purpose of readability.</p>
<blockquote>
<p>It’s unclear to me what characters must be escaped in a bookmarklet URL. Some sources suggest that other punctuation characters, such as brackets and semicolons, ought to be escaped, too, but I can see no practical reason to do so. If you want to be really conservative and escape just about everything, change this line:</p>
<p><code>uri_escape_utf8($bookmarklet, qq('" \x00-\x1f\x7f-\xff));</code></p>
<p>to:</p>
<p><code>uri_escape_utf8($bookmarklet);</code></p>
<p>Personally, I prefer to keep the bookmarklet URL itself as readable as possible.
</p></blockquote>
<p>With this change, we get this bookmarklet: <a href="javascript:%28function%20%28%29%20%7Balert%28%5B%221%2B1%3D%22%2C%281%2B1%29%5D.join%28%27%27%29%29%3B%7D%29%28%29">Example 2</a></p>
<blockquote style="overflow-x: scroll;"><p><code>javascript:%28function%20%28%29%20%7Balert%28%5B%221%2B1%3D%22%2C%281%2B1%29%5D.join%28%27%27%29%29%3B%7D%29%28%29</code></p></blockquote>
<p>It may not be as readable as &#8220;Example 1&#8243;, but it works.</p>
<p><strong><a href="https://gist.github.com/1259477/3920d0ad6b8393094acaf9b909c70bdd80a9cfe2">Find my modifications to Gruber&#8217;s JavaScript Bookmarklet Builder on GitHub</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/uri-escaping-javascript-bookmarklets-in-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Shebangs</title>
		<link>http://www.johntantalo.com/blog/javascript-shebangs/</link>
		<comments>http://www.johntantalo.com/blog/javascript-shebangs/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 20:37:04 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=141</guid>
		<description><![CDATA[Ringo, Narwhal, Node, and JavaScriptCore support executing scripts with a shebang. Here are some quick examples to get you started. Ringo #!/usr/bin/env ringo print("ringo"); Narwhal #!/usr/bin/env narwhal print("narwhal"); Node #!/usr/bin/env node require("sys").print("node\n"); JavaScriptCore #!/usr/bin/env jsc print("jsc"); JavaScriptCore nightly added support for shebangs on 6 December 2010. Since Node and JavaScriptCore are binaries, you can use [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ringojs.org/">Ringo</a>, <a href="http://narwhaljs.org/">Narwhal</a>, <a href="http://nodejs.org/">Node</a>, and <a href="http://webkit.org/projects/javascript/">JavaScriptCore</a> support executing scripts with a <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a>.</p>
<p>Here are some quick examples to get you started.</p>
<h2>Ringo</h2>
<p><code>
<pre>    #!/usr/bin/env ringo
    print("ringo");
</pre>
<p></code></p>
<h2>Narwhal</h2>
<p><code>
<pre>    #!/usr/bin/env narwhal
    print("narwhal");
</pre>
<p></code></p>
<h2>Node</h2>
<p><code>
<pre>    #!/usr/bin/env node
    require("sys").print("node\n");
</pre>
<p></code></p>
<h2>JavaScriptCore</h2>
<p><code>
<pre>    #!/usr/bin/env jsc
    print("jsc");
</pre>
<p></code></p>
<p>JavaScriptCore nightly added support for shebangs on <a href="https://bugs.webkit.org/show_bug.cgi?id=49576">6 December 2010</a>.</p>
<p>Since Node and JavaScriptCore are binaries, you can use the full path instead of <code>env</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/javascript-shebangs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Short and sweet OAuth</title>
		<link>http://www.johntantalo.com/blog/short-and-sweet-oauth/</link>
		<comments>http://www.johntantalo.com/blog/short-and-sweet-oauth/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 05:28:37 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=94</guid>
		<description><![CDATA[I recently grew quite frustrated when I had to update Emend&#8217;s Twitter bot to use OAuth. There are, of course, readily available implementations of OAuth in python, even some specifically engineered for App Engine with lovely persistence and caching and KILL ME NOW. I gave up after a couple hours of staring at this nonsense. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently grew quite frustrated when I had to update <a href="http://emendapp.com">Emend&#8217;s</a> Twitter bot to use <a href="http://oauth.net/">OAuth</a>.</p>
<p>There are, of course, <a href="http://oauth.googlecode.com/svn/code/python/oauth/oauth.py">readily available implementations of OAuth</a> in python, even some <a href="http://github.com/mikeknapp/AppEngine-OAuth-Library/raw/master/oauth.py">specifically engineered for App Engine</a> with lovely persistence and caching and KILL ME NOW.</p>
<p>I gave up after a couple hours of staring at this nonsense. I grew so displeased because my app doesn&#8217;t need 95% of what these libraries offer. I only need to <a href="http://oauth.net/core/1.0/#signing_process">sign requests</a> with a fixed <em>oauth_consumer_key</em>, <em>oauth_consumer_secret</em>, <em>oauth_token</em>, and <em>oauth_token_secret</em>. However, this simple task would require me to subclass or instantiate several object with Culver&#8217;s library, and I can&#8217;t even begin to fathom what I&#8217;d need to do with Knapp&#8217;s offering.</p>
<p>(Aside: if you want to authorize and build access tokens for your app, I highly recommend <a href="http://term.ie/oauth/example/client.php">this excellent OAuth test client</a>)</p>
<p>I finally teased apart the core function of signing requests, thanks in large part to the <a href="http://oauth.net/core/1.0/#anchor30">great reference example</a>. If all you need is to access a protected resource, this will get the job done with a single function call, no object-orientation required.</p>
<p><script src="http://gist.github.com/284452.js?file=oauth.py"></script></p>
<p><a href="http://gist.github.com/284452">Source code and unit test of short and sweet OAuth.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/short-and-sweet-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPA TTS bookmarklet</title>
		<link>http://www.johntantalo.com/blog/ipa-tts-bookmarklet/</link>
		<comments>http://www.johntantalo.com/blog/ipa-tts-bookmarklet/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 17:33:49 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[ipa]]></category>
		<category><![CDATA[tts]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=70</guid>
		<description><![CDATA[Last modified 2 October 2011 I present the IPA (International Phonetic Alphabet) TTS (text-to-speech) bookmarklet. (Source) Bookmarklet: IPA TTS (drag to your bookmark bar) How to use: select any text that contains IPA and click on the bookmarklet. Wait a second for the iframe at the bottom of the page to load. Try these examples: [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Last modified <a href="https://gist.github.com/202523/8b3b7339bb37682d3233471f77cb54b44db948b1">2 October 2011</a></strong></p>
<p>I present the IPA (<a href="http://en.wikipedia.org/wiki/International_Phonetic_Alphabet">International Phonetic Alphabet</a>) TTS (<a href="http://en.wikipedia.org/wiki/Text-to-speech">text-to-speech</a>) <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a>. (<a href="http://gist.github.com/202523">Source</a>)</p>
<p>Bookmarklet: <a href="javascript:%28function%20%28%29%20%7Bvar%20selection%20%3D%20window.getSelection%20%3F%20window.getSelection%28%29%20%3Adocument.getSelection%20%3F%20document.getSelection%28%29%20%3Adocument.selection%20%3F%20document.selection.createRange%28%29.text%20%3A%20%27%27%3Bif%20%28selection%29%20%7Bselection%20%3D%20String%28selection%29%3B%7Dif%20%28selection%29%20%7Bvar%20match%20%3D%20selection.match%28%27%5C%2F%28.%2A%29%5C%2F%27%29%3Bvar%20ipa%3Bif%20%28match%20%26%26%20match%5B1%5D%29%20%7Bipa%20%3D%20match%5B1%5D%3B%7Dif%20%28%21ipa%29%20%7Bipa%20%3D%20prompt%28%22Couldn%27t%20find%20any%20IPA.%20Type%20it%20in%20instead%3F%22%29%3B%7Dif%20%28ipa%29%20%7Bipa%20%3D%20ipa.replace%28%2F.%2Fg%2C%20function%20%28c%29%20%7Bif%20%28%2F%25u0%28...%29%2F.test%28escape%28c%29%29%29%20%7Breturn%20escape%28c%29.replace%28%2F%25u0%28...%29%2Fg%2C%20%27%26%23x%241%3B%27%29%3B%7D%20else%20%7Breturn%20c%3B%7D%7D%29%3Bvar%20request%20%3D%20%7Btxt%3A%20%27%3Cphoneme%20alphabet%3D%22ipa%22%20ph%3D%22%27%2Bipa%2B%27%22%3E%20%3C%2Fphoneme%3E%27%2Cvoice%3A%20%27crystal%27%7D%3Bvar%20iframe%20%3D%20document.createElement%28%27iframe%27%29%3Biframe.name%20%3D%20iframe.id%20%3D%20%22iframe%22%2Bnew%20Date%28%29.getTime%28%29%3Bdocument.body.appendChild%28iframe%29%3Bvar%20form%20%3D%20document.createElement%28%27form%27%29%3Bform.target%20%3D%20iframe.name%3Bform.method%20%3D%20%27post%27%3Bform.action%20%3D%20%27http%3A%2F%2F192.20.225.36%2Ftts%2Fcgi-bin%2Fnph-nvdemo%27%3Bform.acceptCharset%20%3D%20%22iso-8859-1%22%3Bform.style.display%20%3D%20%27none%27%3Bfor%20%28var%20name%20in%20request%29%20%7Bvar%20input%20%3D%20document.createElement%28%27input%27%29%3Binput.name%20%3D%20name%3Binput.value%20%3D%20request%5Bname%5D%3Bform.appendChild%28input%29%3B%7Ddocument.body.appendChild%28form%29%3Bform.submit%28%29%3B%7D%7D%20else%20%7Balert%28%22Select%20some%20IPA.%22%29%3B%7D%7D%29%28%29%0A">IPA TTS</a> (drag to your bookmark bar)</p>
<p>How to use: select any text that contains IPA and click on the bookmarklet. Wait a second for the iframe at the bottom of the page to load.</p>
<p>Try these examples: /ˌɪntəˈnæʃnəl/, /ˌɪntɚˈnæʃnəl/</p>
<h3>How does this work?</h3>
<p>The bookmark creates a POST request to the <a href="http://www2.research.att.com/~ttsweb/tts/demo.php">AT&#038;T Natural Voices® Text-to-Speech Demo</a> with the IPA text in <a href="http://en.wikipedia.org/wiki/Speech_Synthesis_Markup_Language">SSML</a>. The AT&#038;T demo has modest support for IPA, but often fails. If you know of another IPA TTS engine, please let me know or <a href="https://gist.github.com/202523">fork the bookmarklet and add it</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/ipa-tts-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Custom Wikipedia CSS &amp; Javascript for iPhone</title>
		<link>http://www.johntantalo.com/blog/custom-wikipedia-css-javascript-for-iphone/</link>
		<comments>http://www.johntantalo.com/blog/custom-wikipedia-css-javascript-for-iphone/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 23:09:45 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Wikipedia]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=23</guid>
		<description><![CDATA[This afternoon I made a custom stylesheet and script to format Wikipedia nicely for me when I am logged on from my iPhone. If you have a Wikipedia account, you can easily use them by adding them to your own monobook.css and monobook.js. Screenshots below.]]></description>
			<content:encoded><![CDATA[<p>This afternoon I made a custom <a href="http://en.wikipedia.org/wiki/User:Beefyt/monobook.css">stylesheet</a> and <a href="http://en.wikipedia.org/wiki/User:Beefyt/monobook.js">script</a> to format Wikipedia nicely for me when I am logged on from my iPhone. If you have a Wikipedia account, you can easily use them by adding them to your own <a href="http://en.wikipedia.org/wiki/Special:MyPage/monobook.css">monobook.css</a> and <a href="http://en.wikipedia.org/wiki/Special:MyPage/monobook.js">monobook.js</a>. Screenshots below.</p>
<p><a href='http://www.johntantalo.com/blog/wp-content/uploads/2008/08/portrait.png'><img src="http://www.johntantalo.com/blog/wp-content/uploads/2008/08/portrait.png" alt="" title="portrait" width="320" height="480" class="aligncenter size-full wp-image-22" /></a></p>
<p><a href='http://www.johntantalo.com/blog/wp-content/uploads/2008/08/landscape.png'><img src="http://www.johntantalo.com/blog/wp-content/uploads/2008/08/landscape.png" alt="" title="landscape" width="480" height="320" class="aligncenter size-full wp-image-21" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/custom-wikipedia-css-javascript-for-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hidden Categories in Wikipedia</title>
		<link>http://www.johntantalo.com/blog/hidden-categories-in-wikipedia/</link>
		<comments>http://www.johntantalo.com/blog/hidden-categories-in-wikipedia/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 07:45:30 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Wikipedia]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=20</guid>
		<description><![CDATA[While searching for a list of unwatched articles in Wikipedia (which isn&#8217;t published as far as I can tell), I found the category of hidden categories. Interestingly, the &#8220;hidden categories&#8221; category itself is not a hidden category[1]. [1] Wikipedia Signpost: Role of hidden categories under discussion]]></description>
			<content:encoded><![CDATA[<p>While searching for a list of unwatched articles in Wikipedia (which isn&#8217;t published as far as I can tell), I found the <a href="http://en.wikipedia.org/wiki/Category:Hidden_categories">category of hidden categories</a>. Interestingly, the &#8220;hidden categories&#8221; category itself is not a hidden category[1].</p>
<p>[1] <a href="http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/2008-03-03/Hidden_Categories">Wikipedia Signpost: Role of hidden categories under discussion</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/hidden-categories-in-wikipedia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s wrong with Yelp?</title>
		<link>http://www.johntantalo.com/blog/why-you-cant-trust-yelp-reviews/</link>
		<comments>http://www.johntantalo.com/blog/why-you-cant-trust-yelp-reviews/#comments</comments>
		<pubDate>Sat, 03 May 2008 18:36:35 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=18</guid>
		<description><![CDATA[Imagine for a moment that you were a point in multidimensional space, and your nearby neighbors in this space are people that share your preferences for restaurants, bars, and clubs. In this model, a bar you like is very near to you (e.g., by a Euclidean metric), while some place you hate is far away. [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine for a moment that you were a point in multidimensional space, and your nearby neighbors in this space are people that share your preferences for restaurants, bars, and clubs. In this model, a bar you like is very near to you (e.g., by a <a href="http://en.wikipedia.org/wiki/Euclidean_distance">Euclidean metric</a>), while some place you hate is far away.</p>
<p>This model rules <a href="http://yelp.com">Yelp</a>. A review on yelp is a measurement of the distance between the reviewer and the reviewed. The review will be favorable if and only if the reviewer is nearby the reviewed in the model.</p>
<p>A restaurant (e.g., <a href="http://www.yelp.com/biz/bite-san-diego">Bite</a>) gets good reviews  because the people that review it know or can guess, before they go there, that they will like it. If they didn&#8217;t, the place wouldn&#8217;t have such stellar reviews.</p>
<p>So why do some places get terrible reviews? I see cases that would cause this. First, if a new nightclub (e.g., <a href="http://www.yelp.com/biz/universal-hillcrest-san-diego">Universal</a>) is still &#8220;figuring itself out,&#8221; it might attract a lot of people expecting one thing and getting another. In other words, they are not near the place in the model, but they visit it anyway because they think they might. Likely, because the place is so new, many people are testing it out, so you can expect the reviews to be unfavorable, <em>even by the people who are supposed to like it</em>, because the presence of outsiders ruins the whole experience.</p>
<p>In another case, a super-exclusive bar might only cater to a very narrow range of clientele. In other words, you have to be unusually close to this bar in the model in order to like it. Perhaps it only supports one or two cliques of regulars, and everyone else is shunned.</p>
<p><a href='http://www.johntantalo.com/blog/wp-content/uploads/2008/05/untitled.png'><img src="http://www.johntantalo.com/blog/wp-content/uploads/2008/05/untitled-300x244.png" alt="" title="yelp" width="300" height="244" class="alignnone size-medium wp-image-19" /></a></p>
<p>In this example, the radii correspond to the ability of a bar or restaurant to support a wide or narrow section of people.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/why-you-cant-trust-yelp-reviews/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dangers of anonymous function closures</title>
		<link>http://www.johntantalo.com/blog/dangers-of-anonymous-function-closures/</link>
		<comments>http://www.johntantalo.com/blog/dangers-of-anonymous-function-closures/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 19:43:57 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=17</guid>
		<description><![CDATA[John Resig&#8217;s jQuery uses a standard technique of anonymous function closures to namespace its internal functionality. (function(){ // jQuery stuff goes here... })(); This is all well and good until you want to inline this code under some of your application code, as I did while working on Eventful&#8217;s MySpace application. Consider this example, written [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">pre {font-size: 1.5em}</style>
<p>John Resig&#8217;s <a target="_blank" href="http://jquery.com/">jQuery</a> uses a standard technique of anonymous function closures to namespace its internal functionality.</p>
<blockquote><pre><code>(function(){
  // jQuery stuff goes here...
})();</code></pre>
</blockquote>
<p>This is all well and good until you want to inline this code under some of your application code, as I did while working on <a target="_blank" href="http://www.myspace.com/topperformers">Eventful&#8217;s MySpace application</a>. Consider this example, written in standard Javascript style.</p>
<blockquote><pre><code>var foo = function(bar) {
  console.log("foo");
  return bar;
}

(function(){
  console.log("bar")
})();</code></pre>
</blockquote>
<p>What do you expect this code to print? If you say &#8220;bar&#8221;, you&#8217;re wrong. It prints &#8220;foo bar&#8221; because in this context the anonymous function closure becomes a call to the function that prints &#8220;foo&#8221; and returns the function that prints &#8220;bar&#8221;, which is then called.</p>
<p>Most of us probably wouldn&#8217;t notice what just happened because we are so used to Javascript interpreters automatically inserting semicolons after function definitions.</p>
<p>The danger is assuming, as John Resig and hundreds others have, that your anonymous function closure is the first token in a new line. In my case, it wasn&#8217;t. The solution? Either start meticulously sprinkling semicolons in your application code, or just add a single semicolon before your parenthetical block, guaranteeing it&#8217;s the first token in the line.</p>
<blockquote><pre><code>;(function(){
  // jQuery stuff goes here...
})();
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/dangers-of-anonymous-function-closures/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reversed Blogs</title>
		<link>http://www.johntantalo.com/blog/reversed-blogs/</link>
		<comments>http://www.johntantalo.com/blog/reversed-blogs/#comments</comments>
		<pubDate>Wed, 09 Aug 2006 08:30:53 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=7</guid>
		<description><![CDATA[Take a regular blog, and flip it around. What do you get? A reversed blog, of course, where vistors write questions or comments and the author anwers. Sounds stupid, but I think people could get a lot of fun and use out of this. I see this manifesting as a single site with multiple instances [...]]]></description>
			<content:encoded><![CDATA[<p>Take a regular blog, and flip it around. What do you get? A reversed blog, of course, where vistors write questions or comments and the author anwers. Sounds stupid, but I think people could get a lot of fun and use out of this. I see this manifesting as a single site with multiple instances (e.g. <a href="http://blogger.com">blogger</a> or <a href="http://livejournal.com">livejournal</a>), funded by ads, and configurable to control who can ask questions, who can answer, and so on.</p>
<p>Here are a few examples. A couple&#8217;s answers their friends&#8217; questions. A researcher&#8217;s or expert&#8217;s revblog answers questions from others in her field. A CEO&#8217;s revblog answers his company&#8217;s employees. Changing the parameters around may allow anybody to ask and answer (a forum) or only the author to ask (a traditional blog), but keeping in the spirit of &#8220;questions&#8221; and &#8220;answers.&#8221;</p>
<p>For instance, imagine this were a reversed blog where I come up with silly ideas and you tell me if they suck or not. Would that be a good idea?</p>
<p><strong>Update:</strong> As pointed out in the comments, this idea has now been implemented by <a href="http://stackoverflow.com/">Stack Overflow</a> and its brethren: <a href="http://superuser.com/">Super User</a>, <a href="http://serverfault.com/">Server Fault</a>, and <a href="http://mathoverflow.net/">Math Overflow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/reversed-blogs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WikiSyntax</title>
		<link>http://www.johntantalo.com/blog/wikisyntax/</link>
		<comments>http://www.johntantalo.com/blog/wikisyntax/#comments</comments>
		<pubDate>Sun, 06 Aug 2006 08:56:00 +0000</pubDate>
		<dc:creator>John Tantalo</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.johntantalo.com/blog/?p=4</guid>
		<description><![CDATA[I&#8217;m working on a Greasemonkey script to add syntax highlighting to Wikipedia in Firefox. The trick is to replace the edit page&#8217;s textarea with an editable iframe as the page loads, then you can do crazy fun stuff with the document which I will refrain from mentioning because it&#8217;s much too nerdy. At first I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a <a href="http://greasemonkey.mozdev.org/">Greasemonkey</a> script to add syntax highlighting to <a href="http://www.wikipedia.org/">Wikipedia</a> in <a href="http://www.mozilla.com/firefox/">Firefox</a>. The trick is to replace the edit page&#8217;s textarea with an editable iframe as the page loads, then you can do crazy fun stuff with the document which I will refrain from mentioning because it&#8217;s much too nerdy.</p>
<p>At first I thought an extension was the way to go, but its turns out extensions are aimed at tweaking Firefox&#8217;s interface, not fussing with the page. Greasemonkey is perfect for the job, since it basically just executes a script on every page that matches a given pattern. Plus, users don&#8217;t have to go through the hassle of downloading crap and restarting the application.</p>
<p><a class="imagelink" title="WikiSyntax" href="http://www.johntantalo.com/blog/wp-content/uploads/2006/12/picture-1.png"><img align="left" id="image12" alt="WikiSyntax" title="WikiSyntax" src="http://www.johntantalo.com/blog/wp-content/uploads/2006/12/picture-1.thumbnail.png" /></a>This screenshot shows link underlining, headers, and boldface (i.e., embiggening). I haven&#8217;t figured out how to handle styling as the page is edited, though, but once that&#8217;s out of the way the rest should just be a matter of regex hacking.</p>
<p>Here is a quick <a href="http://johntantalo.com/wikisyntax/">WikiSyntax demonstration</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johntantalo.com/blog/wikisyntax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

