<?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>Vague Hope</title>
	<atom:link href="http://vaguehope.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vaguehope.com</link>
	<description>Musings of a displaced marine biologist</description>
	<lastBuildDate>Wed, 11 Apr 2012 22:29:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PowerMock Puzzler</title>
		<link>http://vaguehope.com/2012/02/powermock-puzzler/</link>
		<comments>http://vaguehope.com/2012/02/powermock-puzzler/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 08:35:12 +0000</pubDate>
		<dc:creator>はく</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vaguehope.com/?p=338</guid>
		<description><![CDATA[PowerMock is a very handy extension to the Mockito mocking framework. It extends Mockito by allowing the mocking of static methods and final classes. Obviously to do this some interesting mangling is going on inside the JVM. Occasionally it is possible to run into some very confusing error messages. Yesterday my colleague [Candle] and I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://code.google.com/p/powermock/">PowerMock</a> is a very handy extension to the <a href="https://code.google.com/p/mockito/">Mockito</a> mocking framework.  It extends Mockito by allowing the mocking of static methods and final classes.  Obviously to do this some interesting mangling is going on inside the JVM.  Occasionally it is possible to run into some very confusing error messages.</p>
<p>Yesterday my colleague [<a href="http://blog.candle.me.uk/">Candle</a>] and I spent a very vexing half hour over this puzzle before we figured out the answer.  So I though I would share it to see how long it takes others to figure it out. ^^</p>
<p>Consider the following class.  Do not worry that it basically does nothing.  This is just the minimum to show the puzzle.</p>
<blockquote><pre>import java.net.URL;
import com.google.common.cache.CacheLoader;

public class Loader extends CacheLoader&lt;URL, String&gt; {
	@Override
	public String load (URL u) throws Exception {
		u.openConnection();
		return null;
	}
}</pre>
</blockquote>
<p>And then consider this test class.</p>
<blockquote><pre>import java.net.URL;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest({ URL.class })
public class LoaderTest {
	@Test
	public void test () throws Exception {
		URL url = PowerMockito.mock(URL.class);
		Loader loader = new Loader();
		loader.load(url);
	}
}</pre>
</blockquote>
<p>When run this test will fail with the following exception.  I have edited it slightly to match the cuttings above.  It throws in Loader.load() at the call to u.openConnection().</p>
<blockquote><p>java.lang.AbstractMethodError: java/net/URLStreamHandler.openConnection(Ljava/net/URL;)Ljava/net/URLConnection;<br />
	at java.net.URL.openConnection(URL.java:957)<br />
	at Loader.load(Loader.java:7)</p></blockquote>
<p>Now try and figure out what is going on here.  Go go go!  And for bonus points, suggest a solution that will fix it enough to make the test pass.</p>
]]></content:encoded>
			<wfw:commentRss>http://vaguehope.com/2012/02/powermock-puzzler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MQTT Kindlet</title>
		<link>http://vaguehope.com/2012/01/mqtt-kindlet/</link>
		<comments>http://vaguehope.com/2012/01/mqtt-kindlet/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 13:27:44 +0000</pubDate>
		<dc:creator>はく</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vaguehope.com/?p=307</guid>
		<description><![CDATA[For London Green Hackathon I hacked together a proof-of-concept Kindlet (Kindle Applet) for monitoring environmental data in real-time that runs on a Kindle 3. Its actually a generic MQTT client that runs on a Kindle, but MQTT is a very popular protocol for transmitting environmental data so I think I can argue the &#8216;green&#8217; values [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://vaguehope.com/2012/01/mqtt-kindlet/img_20120129_125008/" rel="attachment wp-att-317"><img src="http://vaguehope.com/uploads/2012/01/IMG_20120129_125008-768x1024.jpg" alt="" title="MQTT on Kindle 3" width="450" height="600" class="aligncenter size-large wp-image-317" /></a></p>
<p>For <a href="http://london.greenhackathon.com">London Green Hackathon</a> I hacked together a proof-of-concept Kindlet (Kindle Applet) for monitoring environmental data in real-time that runs on a Kindle 3.  Its actually a generic MQTT client that runs on a Kindle, but MQTT is a very popular protocol for transmitting environmental data so I think I can argue the &#8216;green&#8217; values of this project.  After all, <a href="http://nanode.eu">Nanode</a> is just an Arduino with an Ethernet port, that gets green badges.</p>
<p>All the code was written after 1AM, thought the night and into the next day.  Its somewhat rough around the edges.  But given we were not sure if it would work at all, I am very happy with the result.</p>
<p>The Kindle is NOT intended as a general use computing device.  There is a SDK, but its closed and so far as I know very little has been done with it.  Its basically for creating interactive books, not applications.  Seems current bets are that is will remain this way.  Hardware limitations aside, the software is really quite fragile.  I am guessing there is a single JVM process for everything, and there is no sand-boxing.  Any unhandled exceptions trigger a JVM restart.</p>
<p>Installing apps on a Kindle requires several hacks to be applied to the device first.  In order: jail-brake, usb-network, developer certificate and changes to the JVM security manager configuration.  The last one is not required for all apps, but it was needed for this hack.</p>
<p><a href="http://blog.tkxuyen.com/2010/10/kindle-jailbreaking-and-kdk.html">Jail-brake and USB network</a>: That page has all the required details and links to the jail-brake downloads.<br />
<a href="http://www.mobileread.com/forums/archive/index.php/t-158015.html">If the USB net freezes on you, try this</a>.</p>
<p>All Kindlets must be signed.  Most people share the same certificate (keeps things simple) and this needs to be copied into `/var/local/java/keystore/developer.keystore&#8217; on Kindle.</p>
<p><a href="http://www.mobileread.mobi/forums/showthread.php?t=151984&#038;page=2">Java security manager</a>: MQTT requires permission to open a socket.  By default the Kindle only allows Kindlets to do HTTP and HTTPS.  By editing `/opt/amazon/ebook/security/external.policy&#8217; and adding `permission java.net.SocketPermission &#8220;*:80-&#8221;, &#8220;accept, connect, listen, resolve&#8221;;&#8217; we can get around this blocker.</p>
<p><a href="http://www.cowlark.com/kindle/getting-started.html">Writing Kindlets</a>: this page is a very good getting started guild.  The Hello World example Kindlet is a useful starting point.  I think <a href="http://adq.livejournal.com/107360.html">this page also helped</a>.</p>
<p><a href="https://kdk-javadocs.s3.amazonaws.com/index.html">AWT / Kindle GUI</a>: JavaDoc for the Kindle GUI tools.  Its basically AWT with a custom set of widgets specially for the Kindle. Not the most clear guide but a good start.  Generally I was able to deduce the remaining 10% of data by trial-and-try-angai-until-it-works-dam-it.</p>
<p>But the final result?  A funky Kindlet that can connect to any MQTT broker and tail the content of a topic space.  Oh, and a greatly increased knowledge of how a Kindle hangs together.  It really is an awesome device.</p>
]]></content:encoded>
			<wfw:commentRss>http://vaguehope.com/2012/01/mqtt-kindlet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Perform: Programming</title>
		<link>http://vaguehope.com/2012/01/perform-programming/</link>
		<comments>http://vaguehope.com/2012/01/perform-programming/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 22:00:00 +0000</pubDate>
		<dc:creator>はく</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vaguehope.com/?p=281</guid>
		<description><![CDATA[Music, films, acting, painting&#8230; art of any kind.  People always have an opinion.  It is a completely open-access system.  No special skills are required to understand and enjoy art&#8230; what would be the point in music that was only interesting to skilled musicians? A display of great skill earns great praise and respect, possibly fame.  [...]]]></description>
			<content:encoded><![CDATA[<p>Music, films, acting, painting&#8230; art of any kind.  People always have an opinion.  It is a completely open-access system.  No special skills are required to understand and enjoy art&#8230; what would be the point in music that was only interesting to skilled musicians?</p>
<p>A display of great skill earns great praise and respect, possibly fame.  No one wants to know how a given tune was dreamed up, the tedious months of refining the composition, the 100 failed songs that preceded this one.  The art in a work of art is all in the interpretation, the mind of the observer.</p>
<p>Programming, coding, the process of making software.  Call it what you will.  I will go out on limb here and suggest that, for MEDCs at lest, software is more ubiquitous that art.  Indeed all films, music, games are themselves dependent on software.  As important as paint is to an artist.</p>
<p>But when an artist creates a great painting, where is the credit to the chemist who create the paint?  Paint is commodity.  The beauty in any technique is its easy of repetition.  A paint only has to be created once to benefit many artists.  But the paint is too easy to obtain.  In perfecting a manufacturing process the chemist has, ironically, removed their name from the world.  No fame or praise is afforded to them.</p>
<p>A job done too well is never acknowledged as having ever existed.</p>
<p>What drives an artist?  What do they seek?  Material gain, certainly, but I suspect that is not all.  To want to show off is to be alive.  To have your existence acknowledged and counted.  To prove that you are not just like everyone else.  That there is something that only you can do.  To a musician performing live in front of a large audience there must be such a sense of acknowledgement.</p>
<p>My fate now is writing software.  It has become a reflex &#8211; something not requiring exerted effort.  Thought and planning, yes.  But like the musician playing from memory, the code just flows.</p>
<p>I never planned to be a software engineer.  In a way, I tried quite hard not to be.  The default choice, the easy and obvious choice, is usually the wrong one.  Always taking the easy path leads to a dead end.  No, worse than that.  It leads to a straight path of more of the same.</p>
<p>There is no performance in programming.  With a life time of experience and honed skill and craft there is still no grand display, no art.  No fame, no praise.  The great enablers of technology so often unknown, lost in history.</p>
<p>In a world of billions, strive to set yourself apart and assert your existence.  Be noticed, be remembered.  In software, is this possible?  Will more remain than unfixed bugs and sarcastic commit comments?</p>
<p>How many are remembered for their code?  Ideas yes, but the art of coding?  If code is incomprehensible to non-coders, then can such even be possible?</p>
<p>A common theme in the <a href="https://en.wikipedia.org/wiki/Earthsea">Earthsea books</a> is that it takes power to know power.  You can not comprehend someone&#8217;s skill without first possessing a near level of skill yourself.  People have always mistrusted magic.</p>
<p>This is a blog entry that I have been thinking about writing for years.  It has then been hastily written and sat on for several weeks.  Apologies for the D&#038;D reference in the title.</p>
]]></content:encoded>
			<wfw:commentRss>http://vaguehope.com/2012/01/perform-programming/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SVN to (existing) git repository in 3 steps</title>
		<link>http://vaguehope.com/2011/09/svn-to-existing-git-repository-in-3-steps/</link>
		<comments>http://vaguehope.com/2011/09/svn-to-existing-git-repository-in-3-steps/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 20:23:16 +0000</pubDate>
		<dc:creator>はく</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vaguehope.com/?p=263</guid>
		<description><![CDATA[Today I migrated Morrigan (my media player and manger project) from a private SVN server to an existing github.com repository. Usually I would not bother writing up such mundane things, but this was so easy I wanted to make the point. Assuming an existing target git repository called `projectfoo-git&#8217;, it goes like this: $ cd [...]]]></description>
			<content:encoded><![CDATA[<p>Today I migrated Morrigan (my media player and manger project) from a private SVN server to an <a href="https://github.com/haku/Morrigan">existing github.com repository</a>.  Usually I would not bother writing up such mundane things, but this was so easy I wanted to make the point.</p>
<p>Assuming an existing target git repository called `projectfoo-git&#8217;, it goes like this:</p>
<p><code><br />
$ cd &lt;projectfoo-git directory&gt;/..<br />
$ git svn --authors-file=svn-authors.txt clone -s https://example.com/svn/projectfoo projectfoo-svn-git<br />
$ cd projectfoo-git<br />
$ git pull ../projectfoo-svn-git<br />
$ git push<br />
</code></p>
<p>The remote repository will now contain the full SVN commit history merged into the existing history.  Are there any other source control systems that can come anywhere near making it this easy?  I doubt it.</p>
<p>References: http://john.albin.net/git/convert-subversion-to-git</p>
]]></content:encoded>
			<wfw:commentRss>http://vaguehope.com/2011/09/svn-to-existing-git-repository-in-3-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing on Android</title>
		<link>http://vaguehope.com/2011/09/developing-on-android/</link>
		<comments>http://vaguehope.com/2011/09/developing-on-android/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 15:56:59 +0000</pubDate>
		<dc:creator>はく</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://vaguehope.com/?p=254</guid>
		<description><![CDATA[A few days ago I got an Asus Transformer &#8211; an Android table with a full physical keyboard. Since then I have been trying to figure out the best way to write code on this device. While porting Eclipse to Android would be cool, it would also be near impossibly complex. It would also be [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I got an Asus Transformer &#8211; an Android table with a full physical keyboard.  Since then I have been trying to figure out the best way to write code on this device.  While porting Eclipse to Android would be cool, it would also be near impossibly complex.  It would also be excessive.  What I am aiming for here is a fairly simple toolchain and workflow.</p>
<p>To start with, I would like to be able to:<br />
- Check code out of Git<br />
- Make some changes (preferably with syntax highlighting)<br />
- Commit and push changes back to remote Git repository</p>
<p>And there are a number of ways this could be done&#8230;</p>
<p>1) Write pure-Java Android app.  There are good Java libraries for most tasks, including a pure-Java Git client.  This would still be quite a tough job though as there would be a lot of UI work to do.</p>
<p>2) Native binaries.  It is in theory possible to cross-compile all the needed tools, including a shell, git client, vi, etc.  The main downside here is how they interact with non-rooted devices.  Native binaries must be packaged up inside a .apk like any other app and can only be run by their owning application.  For example ConnectBot could not use a local-term to run a git binary from another .apk.  A custom ConnectBot build containing the extra binaries would need to be built.  Also I have yet to find an example of compiling git for Android. :(</p>
<p>3) Use a VM. Android devices like this have more than enough power to run small VMs.  And recently a VM was written in JavaScript that could run shell, vi and emacs well.  A small Linux VM that hosts an SSH server on a local port and using ConnectBot as its UI would provide a fairly familiar development environment.  I have been pondering if I could use the JavaScript VM as a base and wrap it in a Android-Java application and fill in the extra features needed, but I fear this is somewhat beyond my skills at the moment.</p>
<p>4) Native binaries with bridging app.  Take the native binaries from 2) and write a small SSH server app like in 4) that proves ConnectBot access to them on a local connection.  Fairly minimal work once the native binaries are ready.  I hope.</p>
<p>I keep wondering of anyone else has thought about this yet or better yet got a working solution, but I guess hardware like this are still fairly rare no not many have the inspiration to do the work.  I am sure it will come at some point, I am just impatient. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://vaguehope.com/2011/09/developing-on-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

