<?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>Brain on Fire</title>
	<atom:link href="http://www.brainonfire.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brainonfire.net/blog</link>
	<description>Tim McCormack, distilled</description>
	<lastBuildDate>Sun, 15 Aug 2010 13:16:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Force SSL for Wikipedia (for advanced users)</title>
		<link>http://www.brainonfire.net/blog/force-ssl-for-wikipedia/</link>
		<comments>http://www.brainonfire.net/blog/force-ssl-for-wikipedia/#comments</comments>
		<pubDate>Sun, 23 May 2010 02:54:14 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[-no category-]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[tech recipe]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=757</guid>
		<description><![CDATA[I like using HTTPS whenever possible. Usually this is as simple as adding a single letter to a URL, but some sites have separate domains for SSL. The Wikimedia sites are a great example of this; they share the domain secure.wikimedia.org and use the first elements of the path to specify the site. Now, I [...]]]></description>
			<content:encoded><![CDATA[<p>I like using HTTPS whenever possible. Usually this is as simple as adding a single letter to a URL, but some sites have separate domains for SSL. The Wikimedia sites are a great example of this; they share the domain secure.wikimedia.org and use the first elements of the path to specify the site.</p>

<p>Now, I could have set up a Greasemonkey script to redirect me once I hit an unsecure Wikipedia page, but then it's too late. (I'm usually going directly to the article via web search results.) I could also use Greasemonkey to rewrite URLs in web pages, but that's a mess. Instead, I wanted to intercept any requests to unsecure Wikipedia and redirect them on the fly, before they even left my machine. Here's how I set up my browser to always use SSL for Wikimedia sites:</p>

<ol>
	<li>Have Apache with virtual hosts and Mozilla Firefox with FoxyProxy</li>
	<li>In my default virtual host:
		<pre>&lt;Directory /var/www/&gt;
	RewriteEngine On
	RewriteBase /
	RewriteCond ${HTTP_HOST} !.*mycomputername.*
	RewriteRule . rewriter.php [L]
&lt;/Directory&gt;</pre></li>
	<li>And this file at /var/www/rewriter.php:
		<pre>&lt;?php

$host = $_SERVER['HTTP_HOST'];
$path = $_SERVER['REQUEST_URI'];

// ensure path is not of form http://...
if(strpos($path, '/') !== 0) {
	$start = "http://$host/";
	if(strpos($path, $start) === 0) {
		$path = substr($path, strlen($start) - 1); // include slash
	} else {
		die();
	}
}

if(preg_match('/([a-z0-9]+)\.wikipedia\.org/', $host, $m_domain)) {
	header("Location: https://secure.wikimedia.org/wikipedia/{$m_domain[1]}{$path}");
	die();
}

?&gt;</pre></li>
	<li>Then set up a proxy in FoxyProxy, early in the chain, called "rewriter". Set it to a SOCKS 5 proxy at localhost:80, using the whitelist regex <code>http://[a-z]+\.wikipedia\.org/.*</code></li>
</ol>

<p>Obviously, the setup as written here only gets Wikipedia, but it could easily be expanded to Wiktionary, Wikibooks, Wikimedia Commons, and other sister sites.</p>

<p>I'll delete any tech-support questions in the comments area, so don't ask them. This guide is for advanced users only. Discussions of potential improvements are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/force-ssl-for-wikipedia/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Managing code: We suck at cross-cutting</title>
		<link>http://www.brainonfire.net/blog/managing-code-we-suck-at-cross-cutting/</link>
		<comments>http://www.brainonfire.net/blog/managing-code-we-suck-at-cross-cutting/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 05:06:53 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[Challenges in software engineering]]></category>
		<category><![CDATA[code management]]></category>
		<category><![CDATA[idealism]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[theory]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=747</guid>
		<description><![CDATA[One of the constant dilemmas I encounter in software development is where to put files. In theory, it doesn't matter; I can set the lookup paths and file references however I want, and the software will compile and run. In practice, I feel it is one of the biggest factors in how comfortable I am [...]]]></description>
			<content:encoded><![CDATA[<p>One of the constant dilemmas I encounter in software development is <em>where to put files</em>. In theory, it doesn't matter; I can set the lookup paths and file references however I want, and the software will compile and run. In practice, I feel it is one of the biggest factors in how comfortable I am developing a project. As a programmer, I need to be able to reload a big ol' wad of context whenever I switch projects, and the directory structure serves in part as external memory. Refactoring, collaboration, permissions, and deployment are all made easier by proper directory structures and naming. Code rot, the scourge of long-running projects, is multiplied by poor initial code management decisions. In short, file management makes <strong>a lot of little differences</strong> that can make or break a project in the long term.</p>

<p>Usually, the standard hierarchical filesystem model is perfect. I have a project Foo, it contains folders for source, compile info, and binaries, and each of those folders is probably hierarchical as well. The source and binary folders usually have matching subdirectory structures, but that particular duplication of structure is OK, because the binaries folder is generated, not edited; I never have to think about changing both directory structures at the same time.</p>

<p>This standard model fails when I have to work with multiple related projects. If I put the Foo and Bar projects side by side, I notice that both have src and bin directories. Perhaps I should have a src folder and bin folder instead, each subdivided into Foo and Bar directories! Each has advantages and disadvantages that are immediately obvious. This is known as the problem of <strong>cross-cutting concerns</strong>, where there are strong yet orthogonal organizational principles that compete for priority.</p>

<p>I like to imagine that we would be better off with a new filesystem model, perhaps one based on matrices, tagging, smart searches, filters, or <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Directed_acyclic_graph">DAGs</a>. I don't know what the right answer is, but I'd like to hear your thoughts on the matter.</p>]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/managing-code-we-suck-at-cross-cutting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LoadForCompile: Help for in-browser compilers</title>
		<link>http://www.brainonfire.net/blog/load-for-compile/</link>
		<comments>http://www.brainonfire.net/blog/load-for-compile/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 21:30:51 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[announce]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=671</guid>
		<description><![CDATA[As javascript engines increase in speed and efficiency, it is becoming feasible to write compilers and interpreters in javascript to allow webpages to run alternative programming languages not normally supported by browsers. See processing.js, for instance: A graphics library that runs a Java-like language in the browser. An initial hurdle facing developers of these toolkits [...]]]></description>
			<content:encoded><![CDATA[<p>As javascript engines increase in speed and efficiency, it is becoming feasible to write compilers and interpreters in javascript to allow webpages to run alternative programming languages not normally supported by browsers. See <a href="http://processingjs.org/">processing.js</a>, for instance: A graphics library that runs a Java-like language in the browser.</p>

<p>An initial hurdle facing developers of these toolkits is the problem of loading source code. Javascript is loaded and executed natively in the browser environment, and it would be nice to load alternative language sources in a similar manner. So, today I wrote a library to do that.</p>

<p>The library, called <a href="http://lab.brainonfire.net/lib/load-for-compile.js">LoadForCompile</a>, is invoked with a MIME type and a callback.  It searches the DOM for script elements with the given MIME type, loads their sources, and passes them to the callback. There is a <a href="http://lab.brainonfire.net/lib/demo/load-for-compile.html">very simple demo page</a> with a "compiler" that displays whatever source code it is provided. Following is the documentation for the library.</p>

<h3 id="heading-description">Description</h3>

<p>LoadForCompile will retrieve alternate-language source code and pass it (in order) to <code>onLoad</code>. Any sources that cannot be retrieved will be ignored by default.</p>

<p>If the <code>onFinish</code> argument is provided, it will be called when all sources have been loaded and passed.</p>

<p>If the <code>onError</code> argument is provided, it will be called with <code>(src, k)</code>, where <code>src</code> is the offending URL and <code>k</code> is a continuation of the loading process, so the relying client may continue or entirely halt the loading process by calling <code>k</code> or not calling it, respectively.</p>

<h3 id="heading-usage">Usage</h3>

<ol>
	<li>Place script elements in your HTML document with desired MIME type.</li>
	<li>Each script element may have a <code>src</code> attribute, an inline body between the opening and closing tags, or both. The body is guaranteed to be called immediately after the associated remote source, or not at all.</li>
	<li>Finally, call LoadForCompile with the MIME type and callbacks.</li>
</ol>

<h3 id="heading-specification">Specification</h3>

<p>LoadForCompile searches the DOM for any script nodes bearing the target MIME type. For each one, it records the src attribute and the contents of the text node, if any. It is an error to have non-text elements as children of the script node, and in such a situation the behavior of this library is unspecified.</p>

<p>The library uses asynchronous requests to load any remote resources specified by <code>src</code> attributes. This loading occurs in an unspecified order. If any remote source fails to load, the library will mark that source (and any associated inline body) as invalid. If <code>onError</code> is provided, it will be called with a continuation function that will resume progress. (If the continuation is not called, no additional callbacks will be made.)</p>

<p>Note that if <code>onError</code> is provided and does not call the continuation, <code>onFinish</code> will not be called.</p>

<h3 id="heading-metadata">Metadata</h3>

<p>The library is in version 0.2 and is licensed under the LGPL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/load-for-compile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tone down your system beep</title>
		<link>http://www.brainonfire.net/blog/tone-down-your-system-beep/</link>
		<comments>http://www.brainonfire.net/blog/tone-down-your-system-beep/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 22:10:46 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[Solutions]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=664</guid>
		<description><![CDATA[The "system beep" (or "system bell") can be quite annoying. Instead of disabling it altogether, you may be able to change it to something a little less irritating. Some operating systems will allow you to change it to a visual alert or a sound file of your choice. Today, I'll show you how to change [...]]]></description>
			<content:encoded><![CDATA[<p>The "system beep" (or "system bell") can be quite annoying. Instead of disabling it altogether, you may be able to change it to something a little less irritating. Some operating systems will allow you to change it to a visual alert or a sound file of your choice. Today, I'll show you how to change the duration, pitch, and volume to something less grating if you're using X.Org (applies to just about all Unix or GNU/Linux systems.) [<a href="http://ubuntuforums.org/showpost.php?p=4075006&#038;postcount=3">via</a>]</p>

<p>I use <code>xset</code>, a command that can set various preferences in the current X display. One of the parameter sets is <code>b</code>, the properties of the system bell. It can be used to set the relative volume, pitch, and duration. Here's an example:</p>

<pre class="commandline">xset b 50 700 5</pre>

<p>That example sets the system bell to 50% volume, a pitch of 700 hertz, and a duration of 5 milliseconds.</p>

<p>Experiment by entering that command, then pressing [Backspace] on the next line of your terminal (to generate a system bell.) Your hardware may not support certain combinations, in which the bell is silent.</p>

<p>To have this setting take effect every time you log in, add it to your session startup commands. In Ubuntu, that's System :: Preferences :: Sessions.</p>]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/tone-down-your-system-beep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT, standard library, and IncompatibleRemoteServiceException</title>
		<link>http://www.brainonfire.net/blog/gwt-standard-lib-incompatibleremoteserviceexception/</link>
		<comments>http://www.brainonfire.net/blog/gwt-standard-lib-incompatibleremoteserviceexception/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 19:00:31 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[Solutions]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[programming language design]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=658</guid>
		<description><![CDATA[The GWT is a set of programs that allows developers to write Java code and compile it down into Javascript to be run on browsers. This requires you to use the subset of Java that the toolkit can emulate, but the compile-time and runtime error messages it displays are often not very useful. I was [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://code.google.com/webtoolkit/" title="Google Web Toolkit homepage">GWT</a> is a set of programs that allows developers to write Java code and compile it down into Javascript to be run on browsers. This requires you to use the subset of Java that the toolkit can emulate, but the compile-time and runtime error messages it displays are often not very useful.</p>

<p>I was developing a GWT application with Eclipse and ran into a client-server communication issue that manifested at runtime. The client would request an object from the server, the object would properly serialize and deserialize (verified by JS debugger), and then GWT's glue code would throw <code>IncompatibleRemoteServiceException</code> (saying "This application is out of date, please click the refresh button on your browser.")</p>



<p>Ultimately, I believe this exception was occurring because either</p>

<ol type="A">
	<li>the class in question extended <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/EnumMap.html"><code>java.util.EnumMap</code></a>, a standard Java library class that GWT reimplements in JS, or</li>
	<li>accessing <code>Whatever.class</code> is disallowed in GWT, but is required for generic code that deals with enumeration types.</li>
</ol>

<p> When I rewrote the class to itself reimplement <code>EnumMap</code> (but specialized to a specific <code>Enum</code>), the exception disappeared. Read on for gory Java details:</p>

<p><code>EnumMap</code> maps values of an <code>Enum</code> to values of some other type. In my case, I was mapping to <code>Boolean</code> values, creating a selection of the <code>Enum</code>. Ordinarily I would just use <code>EnumMap&lt;MyEnum, Boolean&gt;</code>, but unfortunately, <code>EnumMap</code> is not <code>Serializable</code>, since it has no nullary constructors. And why is this? Well, its constructors need to retrieve the list of enumeration values, and  not only do Java generics erase the type information that would otherwise allow access to this info, but one also cannot call <code>T.values()</code> where <code>T</code> is a parameter type extending Enum. Basically, it's a whole pile of language-design fail.</p>

<p>I tried to get around all these issues by subclassing <code>EnumMap</code> and calling <code>super(MyEnum.class)</code> in the constructor, allowing it to be nullary (and therefore supporting serialization.) Ultimately, however, this code was rejected by GWT, and I found it easier to just write a specific reimplementation of the library code.</p>

<p>(Eclipse 3.4 x64 on Ubuntu Intrepid Ibex x64, GWT 1.6.4 plugin, ia32
Sun Java 5 libs.)</p>]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/gwt-standard-lib-incompatibleremoteserviceexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bahamas trip: Day 11</title>
		<link>http://www.brainonfire.net/blog/bahamas-trip-day-11/</link>
		<comments>http://www.brainonfire.net/blog/bahamas-trip-day-11/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 03:05:47 +0000</pubDate>
		<dc:creator>Tim McCormack</dc:creator>
				<category><![CDATA[-no category-]]></category>
		<category><![CDATA[Bahamas]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[San Salvador]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://www.brainonfire.net/?p=653</guid>
		<description><![CDATA[It is my last day in the Bahamas, for now. After breakfast I have just enough time to walk out to the North Point, where I hear tell there might be some San Salvador rock iguanas, a critically endangered subspecies. It seems that some of them may have swum across the harbor from the cay [...]]]></description>
			<content:encoded><![CDATA[<p>It is my last day in the Bahamas, for now. After breakfast I have just enough time to walk out to the North Point, where I hear tell there might be some San Salvador rock iguanas, a critically endangered subspecies. It seems that some of them may have swum across the harbor from the cay where the main local population lives. (I express an interest in taking closeup photos, and am warned that they may attempt to eat my camera...)</p>



<p>Alas, iguanas are not in the cards today. The Point is beautiful as always, though, with both smooth and jagged rock formations lining the sides. On the walk back to GRC I see a mangrove I hadn't noticed before, what might be a Bahama Mockingbird, and a yellow-flowered Wild Unction Vine.</p>

<a href="http://gallery.brainonfire.net/view/5ebf0b34f9c50c6ffb864680c1161663" class="thumblink" title="See photo page"><img src="http://cdn.gallery.brainonfire.net/5ebf0b34f9c50c6ffb864680c1161663.thumb.jpg" alt="Thumbnail image"><span class="caption">Crab hiding under overhang</span></a>

<p>I packed the night before, so the only thing left to do before getting on the truck is to go down to the seashore and say goodbye to the island. I throw back the shells I had collected, but keep the smooth sea glass. A mid-sized crab scuttles under an overhang of the boat launch ramp I am standing on, and I nearly dip my camera into the surf to take a closeup photo. It comes out beautifully.</p>

<p>----</p>

<p>The return trip is a breeze, except for the Nassau airport, where we have to go through Bahamian airport security, followed immediately by grumpy, power-tripping US Customs agents, and then through US airport security. Hey, handle that laptop gently, or at least don't slam it on the table! The San Sal airport was delightfully insecure, which made me feel relaxed. This harrying makes me anxious.</p>

<p>Finally, we are home. My mom picks us all up from the airport, and we watch the Tina James' Magic evening primroses open, exotic flowers in our own yard.</p>]]></content:encoded>
			<wfw:commentRss>http://www.brainonfire.net/blog/bahamas-trip-day-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
