<?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>Bitwise Evolution &#187; tech</title>
	<atom:link href="http://blog.ciscavate.org/category/tech/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ciscavate.org</link>
	<description>Musings of a Seattle-area hacker with a bent on improving digital lifestyles.</description>
	<lastBuildDate>Sun, 25 Jul 2010 23:21:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Recovered Puzzles</title>
		<link>http://blog.ciscavate.org/2010/07/recovered-puzzles.html</link>
		<comments>http://blog.ciscavate.org/2010/07/recovered-puzzles.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 23:21:56 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=130</guid>
		<description><![CDATA[I used to collect puzzles&#8211;back when I had a wiki to post them to&#8211;but that content was lost to me a few years ago when the system hosting my personal content had a slew of hard drive issues.  I was lamenting that loss last week when a coworker suggested that I could possibly find [...]]]></description>
			<content:encoded><![CDATA[<p>I used to collect puzzles&#8211;back when I had a wiki to post them to&#8211;but that content was lost to me a few years ago when the system hosting my personal content had a slew of hard drive issues.  I was lamenting that loss last week when a coworker suggested that I could possibly find the content on the way-back machine at <a href="http://www.archive.org">archive.org</a>, and indeed, I did!</p>

<p>Without further ado, here&#8217;s a short list of brainteasers (none are of my creation, and I do not have citations&#8211;if you know who to credit for any of these, please let me know and I will add proper attribution info.)</p>

<p><strong>Calendar Cubes</strong></p>

<p>A man has two cubes on his desk. Each face of each cube has a single-digit number wirtten on it. With these two cubes, the man is able to enumerate all the days in any month, and each morning he arranges the cubes so that the number of the current day is on top, <em>always</em> using both cubes. How are the numbers distributed on the cubes?</p>

<p><strong>Pennies 1</strong></p>

<p>You are blindfolded in a room with 100 pennies. 30 of the pennies are heads-up, the remainder are tails-up. You can interact with the pennies in any way, but your fingers are not dexterous enough to feel the contours of the coins (so you can&#8217;t feel one to see which side is heads, or tails). Since you are blindfolded, you can&#8217;t see them either. Your task is to manipulate the coins such that there are two sets and each set has an equal number of coins that are heads-up. (The sets must be disjoint, non-empty, and all pennies must be in one of the two sets.)</p>

<p><strong>Pennies 2</strong></p>

<p>Given N pennies, one of which is counterfiet (and therefore is of different weight from the remainder) and a balance, how can you find the counterfeit coin in less three weighings on the balance.</p>

<p><strong>Eggs</strong></p>

<p>You are in a 100-floor building on a planet with oddly low gravity and/or surprisingly durable eggs.  You happen to have two of these eggs (unfertilized, I assure you). Your task is to find the highest floor from which you can drop an egg and have it remain intact.</p>

<p><strong>Numbers</strong></p>

<p>Given 99 unique integers between 1 and 100, provide an optimal algorithm to find the remaining integer in that range that is not in the set.</p>

<p>Hint: Bcgvzny gnxrf yvarne gvzr naq pbafgnag fcnpr.</p>

<p><strong>Prisoners</strong></p>

<p>50 people are inprisioned, and during their imprisonment the captor will invite people randomly in to visit with her. All visits are one-on-one, and each prisoner has a unique tunnel from their cell to the captor&#8217;s office (so you can&#8217;t look out your cell and see who is going in). In the captor&#8217;s room is a bowl that the prisoners can optionally turn over, or turn right-side up during their visit(s). The initial state of the bowl is known to everyone.</p>

<p>The imprisonment may last for an infinite period of time, during which each prisoner will be invited into the captor&#8217;s office many, many times (essentially infinite, but it needs not be infinite, it could just be a reasonably small number in the optimal case). The imprisonment ends when one prisoner says: &#8220;Everyone has been in to see the captor at least once.&#8221; If a prisoner says this and they are wrong, all prisoners are killed immediately. Because the captor may decide not to visit anyone for a while, it is as if the prisoners have no concept of time, so they can&#8217;t bound the number of people seen based on the passage of time.</p>

<p>To give the prisoners a chance, they are allowed to convene briefly before their imprisonment, during which time they can plan a strategy. How do they do it?</p>

<p><strong>Sequences</strong>
What is the next line in this sequence?</p>

<p><pre>
1
1 1
2 1
1 1 1 2
3 1 1 2
2 1 1 2 1 3
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2010/07/recovered-puzzles.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test-Driven XML Schema dev with xmlstarlet</title>
		<link>http://blog.ciscavate.org/2009/10/test-driven-xml-schema-dev-with-xmlstarlet.html</link>
		<comments>http://blog.ciscavate.org/2009/10/test-driven-xml-schema-dev-with-xmlstarlet.html#comments</comments>
		<pubDate>Sat, 17 Oct 2009 00:46:36 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=125</guid>
		<description><![CDATA[Just to document how I do this:

Problem: I need a schema for FooTask

Solution:


Create a &#8216;tests&#8217; directory.
populate said directory with simple example xml files.
Name those files valid-foo.xml or invalid-bar.xml (I use numbers for foo and bar).
Create your xsd file in the same directory as &#8216;tests&#8217;. Lets call it foo.xsd
Copy the following Makefile into the same location.


XSD=foo.xsd
# [...]]]></description>
			<content:encoded><![CDATA[<p>Just to document how I do this:</p>

<p><em>Problem:</em> I need a schema for FooTask</p>

<p><em>Solution:</em></p>

<ul>
<li>Create a &#8216;tests&#8217; directory.</li>
<li>populate said directory with simple example xml files.</li>
<li>Name those files <code>valid-foo.xml</code> or <code>invalid-bar.xml</code> (I use numbers for foo and bar).</li>
<li>Create your xsd file in the same directory as &#8216;tests&#8217;. Lets call it <code>foo.xsd</code></li>
<li>Copy the following Makefile into the same location.</li>
</ul>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;"><span class="re2">XSD=</span>foo.xsd<br />
<span class="re3"># run xmlstarlet with -e to see verbose error.</span><br />
<br />
<span class="kw3">test</span>:<br />
&nbsp; &nbsp; @<span class="kw1">for</span> file <span class="kw1">in</span> `ls <span class="nu0">-1</span> tests/valid*.xml`; <span class="kw1">do</span> <span class="kw1">if</span> xmlstarlet val -q --xsd <span class="re0">$<span class="br0">&#123;</span>XSD<span class="br0">&#125;</span></span> $<span class="re0">$<span class="br0">&#123;</span>file<span class="br0">&#125;</span></span>; <span class="kw1">then</span> <span class="kw3">echo</span> <span class="st0">&quot;pass&quot;</span>; <span class="kw1">else</span> <span class="kw3">echo</span> <span class="st0">&quot;fail: $${file}&quot;</span>; <span class="kw1">fi</span>; <span class="kw1">done</span><br />
&nbsp; &nbsp; @<span class="kw1">for</span> file <span class="kw1">in</span> `ls <span class="nu0">-1</span> tests/invalid*.xml`; <span class="kw1">do</span> <span class="kw1">if</span> ! xmlstarlet val -q --xsd <span class="re0">$<span class="br0">&#123;</span>XSD<span class="br0">&#125;</span></span> $<span class="re0">$<span class="br0">&#123;</span>file<span class="br0">&#125;</span></span>; <span class="kw1">then</span> <span class="kw3">echo</span> <span class="st0">&quot;pass&quot;</span>; <span class="kw1">else</span> <span class="kw3">echo</span> <span class="st0">&quot;fail: $${file}&quot;</span>; <span class="kw1">fi</span>; <span class="kw1">done</span></div></div>

<p>Now, run make, and if anything fails you can manually run <code>xmlstarlet val -e --xsd foo.xsh [failing file.xml]</code> to see the details.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/10/test-driven-xml-schema-dev-with-xmlstarlet.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implications: Coding for Homomorphicly Encrypted Input</title>
		<link>http://blog.ciscavate.org/2009/07/implications-coding-for-homomorphicly-encrypted-input.html</link>
		<comments>http://blog.ciscavate.org/2009/07/implications-coding-for-homomorphicly-encrypted-input.html#comments</comments>
		<pubDate>Thu, 16 Jul 2009 18:56:52 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=115</guid>
		<description><![CDATA[Craig Gentry (Stanford / IBM) recently published a paper that proves the existence of fully homomorphic crypto systems.  This has caused quite a stir, since such a system would allow an untrusted party to perform computations on encrypted data, returning an encrypted result, without ever knowing anything about the input or output.  I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Craig Gentry (Stanford / IBM) recently published a <a href="http://portal.acm.org/citation.cfm?id=1536414.1536440">paper</a> that proves the existence of fully homomorphic crypto systems.  This has caused quite a stir, since such a system would allow an untrusted party to perform computations on encrypted data, returning an encrypted result, without ever knowing anything about the input or output.  I&#8217;m not going to explain what homomorphic encryption is (at least, not in great detail).  Bruce Schneier&#8217;s blog has a <a href="http://www.schneier.com/blog/archives/2009/07/homomorphic_enc.html">great post</a> about it, and the comments there are extremely helpful in understanding how it works, and what this means for cloud computing.</p>

<p>I make no claims to being a cryptographer, but I did have a number of questions about the practical viability of this approach.  Now, there are many questions in that vein that are directed at the performance characteristics of Gentry&#8217;s approach (which are abysmal, but not asymptotically so).  I was curious about The use of side effects to discern information about the encrypted content.</p>

<p>For example, anyone who has used a debugger knows that you can monitor the flow of a program that has been instrumented with debugging symbols, and you can learn a great deal about the input even without examining the content of variables.  If a given conditional branch directs execution one way, then you know the predicate evaluated to a specific value.  I set out to determine why this sort of attack is not a problem, and I ended up learning a lot about the way programs that run on encrypted data must operate.</p>

<h3>Homomorphisms</h3>

<p>Let&#8217;s take a moment to quickly discuss homomorphisms, and homomorphic encryption.</p>

<blockquote>a homomorphism is a structure-preserving map between two algebraic structures &#8211;<a href="http://en.wikipedia.org/wiki/Homomorphism">Wikipedia</a></blockquote>

<p>In this case (encryption) the homomorphism is a mapping from the clear text and the cypher-text.  Fully homomorphic encryption, as Gentry discovered, preserves addition and multiplication&#8211;meaning that you can add and multiply cyphertext, and the result can be decrypted to reveal clear text that has been added and multiplied in the same way.  Addition and Multiplication provide the operations necessary to implement boolean logic, and therefore, are sufficient to program very complex transformations (I&#8217;m not certain that it is safe to say &#8220;arbitrarily complex&#8221;).</p>

<p>It&#8217;s important to realize that <em>every</em> addition or multiplication operation results in a value that is encrypted.  The running program can not know the intermediate results, and indeed it does not.</p>

<h3>So, how do conditionals work?</h3>

<p>Edward Kmett <a href="http://www.schneier.com/blog/archives/2009/07/homomorphic_enc.html#c383405">posted</a> the conversion from if/then/else to addition/multiplication on Schneier&#8217;s blog:</p>

<div class="codecolorer-container java"><div class="codecolorer" style="font-family: monospace;"><span class="kw1">if</span> <span class="br0">&#40;</span>condition<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw2">return</span> then_clause;<br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw2">return</span> else_clause;<br />
<span class="br0">&#125;</span></div></div>

<p>becomes:</p>

<div class="codecolorer-container java" style="height:35px;"><div class="codecolorer" style="font-family: monospace;"><span class="kw2">return</span> condition * then_clause + <span class="br0">&#40;</span><span class="nu0">1</span>-condition<span class="br0">&#41;</span> * else_clause;</div></div>

<p>Here&#8217;s a &#8220;real&#8221; example (it compiles, at least) using both approaches.  This is just meant to be used for explanation &#8212; compilers could easily do the translation from the code in is0_clear() to is0_enc().  I&#8217;ve written them out separately here so we can look at the generated bytecode.</p>

<div class="codecolorer-container java"><div class="codecolorer" style="font-family: monospace;"><span class="kw2">public</span> <span class="kw2">class</span> Test <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw2">public</span> <span class="kw4">int</span> is0_clear<span class="br0">&#40;</span><span class="kw4">int</span> input<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="nu0">0</span>==input<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">return</span> <span class="nu0">2</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">return</span> <span class="nu0">3</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp;<span class="kw2">public</span> <span class="kw4">int</span> is0_enc<span class="br0">&#40;</span><span class="kw4">int</span> input<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1">// I'm cheating a bit to keep this simple -- calculate</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1">// the conditional to be either 0 or 1:</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw4">int</span> cond = <span class="nu0">0</span>==input ? <span class="nu0">1</span> : <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; <span class="kw2">return</span> cond * <span class="nu0">2</span> + <span class="br0">&#40;</span><span class="nu0">1</span>-cond<span class="br0">&#41;</span> * <span class="nu0">3</span>;<br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>

<p>And here&#8217;s the bytecode (generated by sun-java-6, and output with javap -verbose).</p>

<div class="codecolorer-container asm" style="height:280px;"><div class="codecolorer" style="font-family: monospace;"><span class="kw4">public</span> <span class="kw1">int</span> is0_clear<span class="br0">&#40;</span><span class="kw1">int</span><span class="br0">&#41;</span><span class="co1">;</span><br />
&nbsp; <span class="kw4">Code</span>:<br />
&nbsp; &nbsp;<span class="kw4">Stack</span>=<span class="nu0">2</span>, Locals=<span class="nu0">2</span>, Args_size=<span class="nu0">2</span><br />
&nbsp; &nbsp;<span class="nu0">0</span>:&nbsp; &nbsp;iconst_0<br />
&nbsp; &nbsp;<span class="nu0">1</span>:&nbsp; &nbsp;iload_1<br />
&nbsp; &nbsp;<span class="nu0">2</span>:&nbsp; &nbsp;if_icmpne&nbsp; <span class="nu0">7</span>&nbsp; // Conditional Jump!!<br />
&nbsp; &nbsp;<span class="nu0">5</span>:&nbsp; &nbsp;iconst_2<br />
&nbsp; &nbsp;<span class="nu0">6</span>:&nbsp; &nbsp;ireturn&nbsp; &nbsp; &nbsp; &nbsp; // return a constant <span class="nu0">2</span><br />
&nbsp; &nbsp;<span class="nu0">7</span>:&nbsp; &nbsp;iconst_3<br />
&nbsp; &nbsp;<span class="nu0">8</span>:&nbsp; &nbsp;ireturn&nbsp; &nbsp; &nbsp; &nbsp; // return a constant <span class="nu0">3</span><br />
<br />
<span class="kw4">public</span> <span class="kw1">int</span> is0_enc<span class="br0">&#40;</span><span class="kw1">int</span><span class="br0">&#41;</span><span class="co1">;</span><br />
&nbsp; <span class="kw4">Code</span>:<br />
&nbsp; &nbsp;<span class="kw4">Stack</span>=<span class="nu0">3</span>, Locals=<span class="nu0">3</span>, Args_size=<span class="nu0">2</span><br />
&nbsp; &nbsp;<span class="nu0">0</span>:&nbsp; &nbsp;iconst_0&nbsp; &nbsp; &nbsp; // lines <span class="nu0">0</span><span class="nu0">-9</span> here are <span class="kw4">for</span> the <span class="st0">&quot;cheating&quot;</span> part<br />
&nbsp; &nbsp;<span class="nu0">1</span>:&nbsp; &nbsp;iload_1&nbsp; &nbsp; &nbsp; &nbsp; // just ignore them -- the arithmetic to accomplish<br />
&nbsp; &nbsp;<span class="nu0">2</span>:&nbsp; &nbsp;if_icmpne&nbsp; <span class="nu0">9</span>&nbsp; &nbsp;// the same thing is complex, <span class="kw1">and</span> <span class="kw1">not</span> important.<br />
&nbsp; &nbsp;<span class="nu0">5</span>:&nbsp; &nbsp;iconst_1<br />
&nbsp; &nbsp;<span class="nu0">6</span>:&nbsp; &nbsp;<span class="kw4">goto</span>&nbsp; &nbsp;<span class="nu0">10</span><br />
&nbsp; &nbsp;<span class="nu0">9</span>:&nbsp; &nbsp;iconst_0<br />
&nbsp; &nbsp;<span class="nu0">10</span>:&nbsp; istore_2&nbsp; &nbsp;// note that there are no conditional jumps below here: <br />
&nbsp; &nbsp;<span class="nu0">11</span>:&nbsp; iload_2&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span class="nu0">12</span>:&nbsp; iconst_2<br />
&nbsp; &nbsp;<span class="nu0">13</span>:&nbsp; <span class="kw1">imul</span><br />
&nbsp; &nbsp;<span class="nu0">14</span>:&nbsp; iconst_1<br />
&nbsp; &nbsp;<span class="nu0">15</span>:&nbsp; iload_2<br />
&nbsp; &nbsp;<span class="nu0">16</span>:&nbsp; isub<br />
&nbsp; &nbsp;<span class="nu0">17</span>:&nbsp; iconst_3<br />
&nbsp; &nbsp;<span class="nu0">18</span>:&nbsp; <span class="kw1">imul</span><br />
&nbsp; &nbsp;<span class="nu0">19</span>:&nbsp; iadd<br />
&nbsp; &nbsp;<span class="nu0">20</span>:&nbsp; ireturn&nbsp; &nbsp;// return the result of the calculated expression.</div></div>

<p>Since every operation results in an unknown value, <em>no conditional branches</em> can be taken!  Every branch has to be evaluated, and the correct result of the &#8216;correct&#8217; branch is selected by multiplying by a binary value, that is itself, encrypted!  This means that things like run-time short-circuit evaluation are not possible, monitoring progam flow is meaningless,  (possibly?) every input will result in the same run-time, and all side-effects will happen regardless of the input.</p>

<h3>Implications?</h3>

<p>Going further down this rabbit hole, caching is impossible, and global state (if even posible) is likely to be extremely dangerous.  I shudder to think of how Python&#8217;s concept of scoping would interact with a compiler that generates code for homomorphicly encrypted input.</p>

<p>Aside from the pure overhead of dealing with encrypted data, and the &#8220;refreshing&#8221; required with Gentry&#8217;s algorithm, I think that there are going to be some serious performance and development concerns once homomorphic encryption becomes a reality.  The programming practices that are common in languages like Java and Python now are not likely to hold up.  I expect that the APIs that enable operation on encrypted data will be based on <a href="http://en.wikipedia.org/wiki/Total_function">total functions</a>, and I have only begun to think about the implications for testing, code coverage, and quality assurance.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/07/implications-coding-for-homomorphicly-encrypted-input.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cleaning up my browser.</title>
		<link>http://blog.ciscavate.org/2009/06/cleaning-up-my-browser.html</link>
		<comments>http://blog.ciscavate.org/2009/06/cleaning-up-my-browser.html#comments</comments>
		<pubDate>Fri, 19 Jun 2009 21:47:30 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[eye candy]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=112</guid>
		<description><![CDATA[

I&#8217;m done with firefox &#8212; Opera 10 now plays flash well, has adblock via. urifilters, a cleaner UI (no menubar, a menu button!) vertical tabs are supported natively, etc&#8230; I don&#8217;t really like the widget toolkit used in the file open/save dialog, but that&#8217;s much better than the horrid performance/stability/bizarre bugs of Firefox.

The minimal UI [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ciscavate.org/wp-content/2009/06/opera-clean.png"><img src="http://blog.ciscavate.org/wp-content/2009/06/opera-clean.png" alt="opera-clean" title="opera-clean" width="200" class="alignright size-medium wp-image-111" /></a></p>

<p>I&#8217;m done with firefox &#8212; Opera 10 now plays flash well, has adblock via. urifilters, a cleaner UI (no menubar, a menu <em>button</em>!) vertical tabs are supported natively, etc&#8230; I don&#8217;t really like the widget toolkit used in the file open/save dialog, but that&#8217;s <em>much</em> better than the horrid performance/stability/bizarre bugs of Firefox.</p>

<p>The minimal UI possible with Opera is also a major win in my book.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/06/cleaning-up-my-browser.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven deployment issues</title>
		<link>http://blog.ciscavate.org/2009/06/maven-deployment-issues.html</link>
		<comments>http://blog.ciscavate.org/2009/06/maven-deployment-issues.html#comments</comments>
		<pubDate>Sat, 06 Jun 2009 02:25:33 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=109</guid>
		<description><![CDATA[I&#8217;ve been building / porting various projects to maven lately, and pushing them to our in-house maven server.  For a while, I was doing this from my laptop at home.  However, at work, I&#8217;m pushing to localhost (it&#8217;s a temporary thing while we determine if maven will actually work long-term.)

The following error had [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been building / porting various projects to maven lately, and pushing them to our in-house maven server.  For a while, I was doing this from my laptop at home.  However, at work, I&#8217;m pushing to localhost (it&#8217;s a temporary thing while we determine if maven will actually work long-term.)</p>

<p>The following error had me stumped for a few days:</p>

<div class="codecolorer-container bash" style="height:35px;"><div class="codecolorer" style="font-family: monospace;"><span class="br0">&#91;</span>INFO<span class="br0">&#93;</span> Error retrieving previous build number <span class="kw1">for</span> artifact <span class="st0">'de.balokb:libreadline-java-i386-Linux-c23cxx6:jar'</span>: repository metadata <span class="kw1">for</span>: <span class="st0">'snapshot de.balokb:libreadline-java-i386-Linux-c23cxx6:1.0-SNAPSHOT'</span> could not be retrieved from repository: inhouse_snapshot due to an error: Exit code: <span class="nu0">1</span> - Host key verification failed.</div></div>

<p>All the googling I did turned up people stumped with ssh public key problems, or users who had specified ssh: instead of extssh: &#8230; etc.  It was fairly quick to elleminate those issues, or so I thought.  (<code>ssh localhost</code> right? No problem.)</p>

<p>I happened to look in more detail at my pom.xml:</p>

<div class="codecolorer-container xml"><div class="codecolorer" style="font-family: monospace;"><span class="sc3"><span class="re1">&lt;repository<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;id<span class="re2">&gt;</span></span></span>inhouse<span class="sc3"><span class="re1">&lt;/id<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Inhouse Internal Release Repository<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;url<span class="re2">&gt;</span></span></span>scpexe://10.0.0.26/var/www/maven/inhouse<span class="sc3"><span class="re1">&lt;/url<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/repository<span class="re2">&gt;</span></span></span></div></div>

<p>hm&#8230; <code>10.0.0.26</code> I wonder&#8230;</p>

<div class="codecolorer-container text">$ ssh 10.0.0.26
The authenticity of host '10.0.0.26 (10.0.0.26)' can't be established.
RSA key fingerprint is a7:bf:36:4c:b9:c7:c2:f9:03:9a:3a:a7:4f:10:e5:ba.
Are you sure you want to continue connecting (yes/no)?</div>

<p>Ah ha!  I clearly can&#8217;t use a pom.xml that lists &#8220;localhost&#8221; in the server section &#8212; I&#8217;d only be able to push from one place.  However, since I&#8217;d never ssh&#8217;d to <code>10.0.0.26</code> from localhost, the fingerprint was unknown, and that was causing maven to error out with the problem I saw initially.</p>

<p>&#8220;Fingerprint ID failed&#8221; would have been a nicer error message, but I don&#8217;tk now that that is possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/06/maven-deployment-issues.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bitten by dependency management</title>
		<link>http://blog.ciscavate.org/2009/05/bitten-by-dependency-management.html</link>
		<comments>http://blog.ciscavate.org/2009/05/bitten-by-dependency-management.html#comments</comments>
		<pubDate>Fri, 22 May 2009 23:31:45 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=103</guid>
		<description><![CDATA[I&#8217;ve started using Maven to manage my java projects, and overall I&#8217;m very happy with it.  It seems to be more mature than ivy, with better documentation, and the vast majority of tasks that I need &#8220;just work&#8221; (just don&#8217;t ask me about jni&#8211;that&#8217;s another post).

Today, (and yesterday, and a good portion of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ciscavate.org/wp-content/2009/05/dependencies.png"><img src="http://blog.ciscavate.org/wp-content/2009/05/dependencies-small.png" alt="dependencies-small" title="dependencies-small" width="145" height="200" class="alignright size-full wp-image-106" /></a>I&#8217;ve started using Maven to manage my java projects, and overall I&#8217;m very happy with it.  It seems to be more mature than ivy, with better documentation, and the vast majority of tasks that I need &#8220;just work&#8221; (just don&#8217;t ask me about jni&#8211;that&#8217;s another post).</p>

<p>Today, (and yesterday, and a good portion of the night in-between) I ran into a nasty bug in a library that I didn&#8217;t know my code depended on.  It isn&#8217;t particularly important <em>what</em> I was working on, but just for context: I needed to strip a lot of text content out of nodes in the complete wikipedia revision history dump, so I was using Sax to parse the xml stream, filter out the stuff I wanted filtered out, and save the stuff that, well, I wanted saved.  Being that the input was all of wikipedia, there were a fair number of unicode characters in there.  As it turns out, the 2.6.2 xercesImpl has some sort of bug that allows xml with certain characters to be read without throwing exceptions, but when you try to write the chars that were actually read, you end up trying to write characters that aren&#8217;t valid in xml.  Even if I&#8217;d known that in advance, my response would have been something like &#8220;ok, so what? I&#8217;m not using xercesImpl, and certainly not a version <em>that</em> old&#8221;.</p>

<p>Well.</p>

<p>You see, in addition to using Maven, I&#8217;ve also been using the <a href="http://code.google.com/p/google-collections/">Google Collections</a> and <a href="http://code.google.com/p/jsr-305/">JSR305</a> libraries, so I just drop those <code>&lt;dependency&gt;</code> entries into the pom for all my new projects&#8211;I just assume that I&#8217;ll need them, and I usually do.</p>

<p>Unfortunately, JSR305 1.3.8 depends on jaxen 1.1.1, which depends on xercesImpl 2.6.2 (jaxen also needs this dependency via xom 1.0, for what that&#8217;s worth).</p>

<p>Because that dependency was already present in my build path (via <code>mvn eclipse:eclipse</code>) and in the generated jar (via <code>&lt;addClasspath&gt;</code> and <code>&lt;classpathPrefix&gt;</code> in the <code>maven-jar-plugin</code>  configuration section), I never realized that my sax code actually had a <em>direct</em> dependency on xerces as well.  This all came to a head when, 3.53gb into my 2.8tb run, these rather unhelpful exceptions started popping up:</p>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;">java.io.IOException: The character <span class="st0">'?'</span> is an invalid XML character<br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xml.serialize.BaseMarkupSerializer.characters<span class="br0">&#40;</span>Unknown<br />
Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at com.stottlerhenke.tools.wikiparse.ContentStripper.characters<span class="br0">&#40;</span>ContentStripper.java:<span class="nu0">195</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.parsers.AbstractSAXParser.characters<span class="br0">&#40;</span>Unknown<br />
Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl<span class="re1">$FragmentContentDispatcher</span>.dispatch<span class="br0">&#40;</span>Unknown<br />
Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument<span class="br0">&#40;</span>Unknown<br />
Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.parsers.XML11Configuration.parse<span class="br0">&#40;</span>Unknown Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.parsers.XML11Configuration.parse<span class="br0">&#40;</span>Unknown Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.parsers.XMLParser.parse<span class="br0">&#40;</span>Unknown Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at org.apache.xerces.parsers.AbstractSAXParser.parse<span class="br0">&#40;</span>Unknown Source<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at com.stottlerhenke.tools.wikiparse.ContentStripper.parse<span class="br0">&#40;</span>ContentStripper.java:<span class="nu0">96</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;at com.stottlerhenke.tools.wikiparse.ContentStripper.main<span class="br0">&#40;</span>ContentStripper.java:<span class="nu0">379</span><span class="br0">&#41;</span></div></div>

<p><code>&lt;rant&gt;</code> &#8220;?&#8221; is not unicode &#8212; it fits just fine in asci tables everywhere &#8212; so please don&#8217;t tell me that it&#8217;s an invalid unicode character :) (0xd800 <em>is</em> an invalid unicode character, and that would have been <em>much</em> more helpful) <code>&lt;/rant&gt;</code></p>

<p>Many hours later I was able to find a sample of the actual input that was causing these problems, and I was able to reproduce the issue with an input slightly smaller than 2.8tb.  Once that was done, I set out to make a minimal test case.  Rather than bother with a new maven project, I just hacked it out in emacs (not using google collections, etc. because, clearly, I wanted it minimal).  To my surprise, everything worked, and worked fantastically! But how? I didn&#8217;t even supply an xml api on the classpath, yet it ran just fine!</p>

<p>In truth, I <em>did</em> supply an xml api &#8212; xercesImpl.jar, and many other libraries &#8212; via my environment&#8217;s <code>$CLASSPATH</code>.  (Figuring that out was another adventure, but I digress.)  Once it became clear that I was indeed using a broken library it was simply a matter of explicitly specifying the dependency on a new version of xercesImpl, and rebuilding.</p>

<p>The moral?</p>

<p>Know your dependencies!  This should come along with knowing your language&#8217;s built-in APIs well.  It wasn&#8217;t clear to me that the SAX packages I was using were not part of the core java API, so it didn&#8217;t strike me as odd that I didn&#8217;t need to specify a classpath entry or a pom dependency before I could use sax.</p>

<p>If you suspect something strange, you can see the dependency tree in the generated html documentation you get when running <code>mvn site</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/05/bitten-by-dependency-management.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the key repeat in Ubuntu 9.04</title>
		<link>http://blog.ciscavate.org/2009/05/fixing-the-key-repeat-in-ubuntu-904.html</link>
		<comments>http://blog.ciscavate.org/2009/05/fixing-the-key-repeat-in-ubuntu-904.html#comments</comments>
		<pubDate>Thu, 14 May 2009 17:18:54 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=100</guid>
		<description><![CDATA[I just upgraded my workstation to Jaunty (Ubuntu 9.04) and the key repeat delay and speed dropped to a frustrating level.

gnome-control-center can be used to fix this, but it requires that the gnome-settings-daemon be running, which forces it&#8217;s opinions on many other aspects of my environment (I run Enlightenment dr17).

Poking around a bit, and help [...]]]></description>
			<content:encoded><![CDATA[<p>I just upgraded my workstation to Jaunty (Ubuntu 9.04) and the key repeat delay and speed dropped to a frustrating level.</p>

<p>gnome-control-center can be used to fix this, but it requires that the gnome-settings-daemon be running, which forces it&#8217;s opinions on many other aspects of my environment (I run Enlightenment dr17).</p>

<p>Poking around a bit, and help from #e on freenode, revealed that <code>xset</code> can be used to fix the key repeat settings.</p>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;"><span class="re3"># Look at the current settings:</span><br />
$ xset q<br />
Keyboard Control:<br />
&nbsp; auto repeat:&nbsp; on&nbsp; &nbsp; key click percent:&nbsp; <span class="nu0">0</span>&nbsp; &nbsp; LED mask:&nbsp; <span class="nu0">00000000</span><br />
&nbsp; auto repeat delay:&nbsp; <span class="nu0">660</span>&nbsp; &nbsp; repeat rate:&nbsp; <span class="nu0">25</span><br />
&nbsp; auto repeating keys:&nbsp; 00ffffffdffffbbf<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fadfffefffedffff<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9fffffffffffffff<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fff7ffffffffffff<br />
<span class="re3"># lets speed things up a bit...</span><br />
$ xset r rate <span class="nu0">250</span> <span class="nu0">40</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/05/fixing-the-key-repeat-in-ubuntu-904.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things are a little messy&#8230;</title>
		<link>http://blog.ciscavate.org/2009/03/things-are-a-little-messy.html</link>
		<comments>http://blog.ciscavate.org/2009/03/things-are-a-little-messy.html#comments</comments>
		<pubDate>Mon, 30 Mar 2009 19:02:56 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=96</guid>
		<description><![CDATA[I&#8217;ve had some minor upgrade issues with the blog lately, and I am only about halfway through updating everything.  In the meantime, I&#8217;m afraid things will look a bit messy.  (Syntax highlighting is currently broken, and there are probably other formatting / data issues as well.  I think I have to restore [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had some minor upgrade issues with the blog lately, and I am only about halfway through updating everything.  In the meantime, I&#8217;m afraid things will look a bit messy.  (Syntax highlighting is currently broken, and there are probably other formatting / data issues as well.  I think I have to restore the uploads directory, for one, so there probably won&#8217;t be any images in the posts for a while.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/03/things-are-a-little-messy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Linux Tablet: Wacom rotations &#8211; waking up on the wrong side</title>
		<link>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-rotations-waking-up-on-the-wrong-side.html</link>
		<comments>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-rotations-waking-up-on-the-wrong-side.html#comments</comments>
		<pubDate>Mon, 26 Jan 2009 06:45:46 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[x61]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=64</guid>
		<description><![CDATA[Update: updated the script with improved (functional) error output.  added notes about xhost.

There is an annoying bug in the sequence of code that manages the wacom rotation / sleep / resume and stylus calibration right now. (Where &#8220;right now&#8221; is Ubuntu Intrepid, with the 0.8.2-1 wacom drivers.)

This is a document bug over at the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: updated the script with improved (functional) error output.  added notes about xhost.</strong></p>

<p>There is an annoying bug in the sequence of code that manages the wacom rotation / sleep / resume and stylus calibration right now. (Where &#8220;right now&#8221; is Ubuntu Intrepid, with the <a href="http://linuxwacom.sourceforge.net/">0.8.2-1 wacom drivers</a>.)</p>

<p>This is a document bug over at the <a href="https://bugs.launchpad.net/ubuntu/+source/wacom-tools/+bug/295292">ubuntu launchpad</a>, and the poster there does a fine job of describing the intricacies of reproducing the bug, so I&#8217;ll only give a brief explanation here to help get indexed.</p>

<p>If you rotate the screen any amount, even returning to the original rotation, and then sleep the machine, when it wakes up, the stylus will not be calibrated properly &#8212; the cursor will be off to the side of the stylus point.  It doesn&#8217;t seem to matter how it was calibrated when the machine slept, nor does it matter what rotation you&#8217;re in when you put the machine to sleep.</p>

<p>There is one straightforward workaround:  When you wake the machine, run wacomcpl, click on stylus, click calibrate (the mouse should now be under the stylus again), and exit wacomcpl.  This is incredibly cumbersome, but at least it&#8217;s better than restarting X, which is what I have been doing.</p>

<p>Further inspection (based largely on the thread of comments on that launchpad bug) reveals that the problem is actually related to bad values for the TopX, TopY, BottomX and BottomY settings on the wacom devices after a resume.  By resetting these to their proper values for the current rotation, we can reestablish the proper calibration.  First off, we need to know the proper values, and the easiest way to get them is with <code>xsetwacom</code>:</p>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;"><span class="re3">#!/bin/bash</span><br />
<span class="re3"># wacomSettings</span><br />
<br />
<span class="kw3">echo</span> <span class="st0">&quot;TopX=&quot;</span> `xsetwacom get stylus TopX`<br />
<span class="kw3">echo</span> <span class="st0">&quot;TopY=&quot;</span> `xsetwacom get stylus TopY`<br />
<span class="kw3">echo</span> <span class="st0">&quot;BottomX=&quot;</span> `xsetwacom get stylus BottomX`<br />
<span class="kw3">echo</span> <span class="st0">&quot;BottomY=&quot;</span> `xsetwacom get stylus BottomY`</div></div>

<p>Now, we&#8217;ll run this for each rotation, and save the results.  You should end up with something like the following:</p>

<div class="codecolorer-container bash" style="height:280px;"><div class="codecolorer" style="font-family: monospace;">|rogue on bach |AC <span class="nu0">70</span>% | @ <span class="nu0">00</span>:<span class="nu0">02</span>:<span class="nu0">26</span> ~|<br />
&nbsp;$ xrotate <span class="nu0">1</span> &amp;&amp; wacomSettings<br />
xrandr to left, xsetwacom to <span class="nu0">2</span><br />
<span class="re2">TopX=</span> <span class="nu0">-46</span><br />
<span class="re2">TopY=</span> <span class="nu0">-3</span><br />
<span class="re2">BottomX=</span> <span class="nu0">18605</span><br />
<span class="re2">BottomY=</span> <span class="nu0">24518</span><br />
&nbsp;|rogue on bach |AC <span class="nu0">70</span>% | @ <span class="nu0">00</span>:<span class="nu0">02</span>:<span class="nu0">28</span> ~|<br />
&nbsp;$ xrotate <span class="nu0">2</span> &amp;&amp; wacomSettings<br />
xrandr to inverted, xsetwacom to <span class="nu0">3</span><br />
<span class="re2">TopX=</span> <span class="nu0">58</span><br />
<span class="re2">TopY=</span> <span class="nu0">-46</span><br />
<span class="re2">BottomX=</span> <span class="nu0">24579</span><br />
<span class="re2">BottomY=</span> <span class="nu0">18605</span><br />
&nbsp;|rogue on bach |AC <span class="nu0">70</span>% | @ <span class="nu0">00</span>:<span class="nu0">02</span>:<span class="nu0">35</span> ~|<br />
&nbsp;$ xrotate <span class="nu0">3</span> &amp;&amp; wacomSettings<br />
xrandr to right, xsetwacom to <span class="nu0">1</span><br />
<span class="re2">TopX=</span> <span class="nu0">-173</span><br />
<span class="re2">TopY=</span> <span class="nu0">58</span><br />
<span class="re2">BottomX=</span> <span class="nu0">18478</span><br />
<span class="re2">BottomY=</span> <span class="nu0">24579</span><br />
&nbsp;|rogue on bach |AC <span class="nu0">70</span>% | @ <span class="nu0">00</span>:<span class="nu0">02</span>:<span class="nu0">41</span> ~|<br />
&nbsp;$ xrotate <span class="nu0">0</span> &amp;&amp; wacomSettings<br />
xrandr to normal, xsetwacom to <span class="nu0">0</span><br />
<span class="re2">TopX=</span> <span class="nu0">-3</span><br />
<span class="re2">TopY=</span> <span class="nu0">-173</span><br />
<span class="re2">BottomX=</span> <span class="nu0">24518</span><br />
<span class="re2">BottomY=</span> <span class="nu0">18478</span></div></div>

<p>(Note that my bash prompt looks like &amp; command lines above are indented, and the output is left-aligned)</p>

<p>That gives us enough information to script the calibration when we resume.  For example, when resuming to a &#8220;normal&#8221; rotation, I need to run:</p>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;">xsetwacom <span class="kw3">set</span> stylus TopX <span class="nu0">-3</span><br />
xsetwacom <span class="kw3">set</span> stylus TopY <span class="nu0">-173</span><br />
xsetwacom <span class="kw3">set</span> stylus BottomX <span class="nu0">24518</span><br />
xsetwacom <span class="kw3">set</span> stylus BottomY <span class="nu0">18478</span></div></div>

<p>(Wrap that in a bash script and give it a shot!)</p>

<p>Here&#8217;s the full script that gets the current orientation and then calibrates the common wacom devices:</p>

<div class="codecolorer-container bash" style="height:280px;"><div class="codecolorer" style="font-family: monospace;"><span class="re3">#!/bin/bash</span><br />
<span class="re3">#</span><br />
<span class="re3"># waCalibrate.sh: recalibrates the wacom stylus</span><br />
<span class="re3">#</span><br />
<span class="re3"># Author: Rogan Creswick</span><br />
<span class="re3"># License: just be nice</span><br />
<br />
<span class="re3"># Set LOG to something reasonable: </span><br />
<span class="re3"># <span class="br0">&#40;</span>The file does not need to exist, but the *directory* does<span class="br0">&#41;</span></span><br />
<span class="re2">LOG=</span>/home/rogue/calibration.out<br />
<span class="re2">XSETWACOM=</span>/usr/<span class="kw3">local</span>/bin/xsetwacom<br />
<br />
<br />
<span class="re3">#</span><br />
<span class="re3"># Calibrates the wacom devices <span class="br0">&#123;</span>stylus, eraser, cursor<span class="br0">&#125;</span> with the </span><br />
<span class="re3"># given offsets:</span><br />
<span class="re3">#</span><br />
<span class="re3">#&nbsp; Usage:</span><br />
<span class="re3">#&nbsp; &nbsp; &nbsp;calibrate &lt;topx&gt; &lt;topy&gt; &lt;bottomx&gt; &lt;bottomy&gt;</span><br />
<span class="re3">#</span><br />
<span class="kw1">function</span> calibrate <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> stylus TopX $<span class="nu0">1</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> stylus TopY $<span class="nu0">2</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> stylus BottomX $<span class="nu0">3</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> stylus BottomY $<span class="nu0">4</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
<br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> eraser TopX $<span class="nu0">1</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> eraser TopY $<span class="nu0">2</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> eraser BottomX $<span class="nu0">3</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> eraser BottomY $<span class="nu0">4</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
<br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> cursor TopX $<span class="nu0">1</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> cursor TopY $<span class="nu0">2</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> cursor BottomX $<span class="nu0">3</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re0">$<span class="br0">&#123;</span>XSETWACOM<span class="br0">&#125;</span></span> --display :<span class="nu0">0.0</span> <span class="kw3">set</span> cursor BottomY $<span class="nu0">4</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <span class="nu0">2</span>&gt;&amp;<span class="nu0">1</span><br />
<span class="br0">&#125;</span><br />
<br />
<br />
<span class="kw1">function</span> fixCalibration <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re3"># get the current orientation:</span><br />
&nbsp; &nbsp; <span class="re2">ORIENTATION=</span>`xrandr --verbose --query | grep <span class="st0">&quot; connected&quot;</span> | awk <span class="st0">'{print $5}'</span>`<br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Orientation: ${ORIENTATION}&quot;</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&quot;${ORIENTATION}&quot;</span> <span class="kw1">in</span><br />
&nbsp; &nbsp; normal<span class="br0">&#41;</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;calibrate <span class="nu0">-3</span> <span class="nu0">-173</span> <span class="nu0">24518</span> <span class="nu0">18478</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;;;<br />
&nbsp; &nbsp; left<span class="br0">&#41;</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;calibrate <span class="nu0">-46</span> <span class="nu0">-3</span> <span class="nu0">18605</span> <span class="nu0">24518</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;;;<br />
&nbsp; &nbsp; right<span class="br0">&#41;</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;calibrate <span class="nu0">-173</span> <span class="nu0">58</span> <span class="nu0">18478</span> <span class="nu0">24579</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;;;<br />
&nbsp; &nbsp; inverted<span class="br0">&#41;</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;calibrate <span class="nu0">58</span> <span class="nu0">-46</span> <span class="nu0">24579</span> <span class="nu0">18605</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;;;<br />
&nbsp; &nbsp; *<span class="br0">&#41;</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;calibrate <span class="nu0">-3</span> <span class="nu0">-173</span> <span class="nu0">24518</span> <span class="nu0">18478</span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span class="kw3">echo</span> <span class="st0">&quot;ERROR!! unknown orientation! ${ORIENTATION}&quot;</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span><br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;;;<br />
&nbsp; &nbsp; <span class="kw1">esac</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">case</span> <span class="st0">&quot;$1&quot;</span> <span class="kw1">in</span><br />
&nbsp; &nbsp; resume|thaw<span class="br0">&#41;</span><br />
&nbsp; &nbsp; date &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span><br />
&nbsp; &nbsp; fixCalibration <br />
&nbsp; &nbsp; whoami &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
&nbsp; &nbsp; *<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;not a resum|thaw event: $1&quot;</span> &gt;&gt; <span class="re0">$<span class="br0">&#123;</span>LOG<span class="br0">&#125;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ;;<br />
<span class="kw1">esac</span></div></div>

<p>Stick that in <code>/etc/pm/sleep.d/40wacomCalibrate</code> (or some similarly named file), make it executable by all (<code>chmod a+x /etc/pm/sleep.d/40wacomCalibrate</code>) and it should be run when the system resumes.</p>

<p><strong>Update:</strong> I found that the logging of the old script didn&#8217;t work, so I&#8217;ve updated the script to reflect that.  There were also some problems with how I was testing the first script, and the actions I was taking didn&#8217;t actually trigger the bug.  (The bug seems to be quite state-dependent, and markovian assumption was wrong.)  To get this to work, root will need to have access to the display that xsetwacom uses.  The simplest way to do this is to add <code>xhost +</code> to you x startup.  (I put it in my ~/.xsession just before <code>exec enlightenment-start</code>).
</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-rotations-waking-up-on-the-wrong-side.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The Linux Tablet: Wacom drivers</title>
		<link>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-drivers.html</link>
		<comments>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-drivers.html#comments</comments>
		<pubDate>Sun, 11 Jan 2009 23:06:28 +0000</pubDate>
		<dc:creator>rcreswick</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[x61]]></category>

		<guid isPermaLink="false">http://blog.ciscavate.org/?p=56</guid>
		<description><![CDATA[Ubuntu 8.10 configured most everything properly, as mentioned in the previous post in this series, but it did not result in a functional pen.

The tablet screen is a wacom digitizer with a pen that has two buttons (eraser and a finger button), and the tablet can differentiate between touching and hovering.  The linux wacom [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 8.10 configured most everything properly, as mentioned in the <a href="http://blog.ciscavate.org/2009/01/the-path-to-a-linux-tablet.html">previous post</a> in this series, but it did not result in a functional pen.</p>

<p>The tablet screen is a wacom digitizer with a pen that has two buttons (eraser and a finger button), and the tablet can differentiate between touching and hovering.  The linux wacom driver &amp; tools are necessary to get this all working.  While I didn&#8217;t find a single page with instructions that worked flawlessly, I was able to figure it out from a collection of links:</p>

<ul>
<li>The Linux Wacom project: 

<ul>
<li><a href="http://linuxwacom.sourceforge.net/index.php/minihowto">http://linuxwacom.sourceforge.net/index.php/minihowto</a></li>
<li><a href="http://linuxwacom.sourceforge.net/index.php/howto/x11">http://linuxwacom.sourceforge.net/index.php/howto/x11</a></li>
</ul></li>
<li>The Aliencam blog:

<ul>
<li><a href="http://blog.aliencam.net/articles/aliencams-customized-ubuntu-setup-guide/">http://blog.aliencam.net/articles/aliencams-customized-ubuntu-setup-guide/</a></li>
</ul></li>
</ul>

<p>First off, you will need the latest version of the linux Wacom driver (8.2.1 at the time of this writing).  The driver versions seem to be tied to your kernel versions, so this is quite important.  The wacom-tools package that comes with Ubuntu is not sufficient (in fact, you&#8217;ll want to uninstall it if you have it already).</p>

<p>Once you have the wacom package downloaded, follow the directions for installing it in the howto (linked above).  The wacom package uses a typical configure, make, make install process but there are a few kinks:</p>

<ul>
<li>configure (almost?) always succeeds, regardless of the dependencies you have yet to fill.  The make step will simply not build all the things you need if this happens, but it won&#8217;t fail visibly.</li>
<li>You&#8217;ll need to copy the kernel module into the /lib/modules/<code>uname -r</code>/kernel/drivers/usb/input/ directory manually (creating subdirs if necessary), <em>before</em> running make install.  (This is outlined in the mini-howto.)</li>
</ul>

<p>Once wacom is installed, you can begin working with the X.org configuration.  This is fairly clearly explained at the aliencam blog linked above, or you can use my xorg.conf here.</p>

<div class="codecolorer-container bash" style="height:280px;"><div class="codecolorer" style="font-family: monospace;">Section <span class="st0">&quot;Device&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;Configured Video Device&quot;</span><br />
EndSection<br />
<br />
Section <span class="st0">&quot;Monitor&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;Configured Monitor&quot;</span><br />
EndSection<br />
<br />
Section <span class="st0">&quot;Screen&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;Default Screen&quot;</span><br />
&nbsp; &nbsp; Monitor&nbsp;&nbsp;<span class="st0">&quot;Configured Monitor&quot;</span><br />
&nbsp; &nbsp; Device&nbsp; &nbsp; <span class="st0">&quot;Configured Video Device&quot;</span><br />
EndSection<br />
<br />
<br />
<span class="re3">#BEGIN TABLET SECTION</span><br />
Section <span class="st0">&quot;InputDevice&quot;</span><br />
&nbsp; &nbsp; Driver&nbsp; &nbsp; <span class="st0">&quot;wacom&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;stylus&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Device&quot;</span>&nbsp; <span class="st0">&quot;/dev/ttyS0&quot;</span>&nbsp; <span class="re3"># serial ONLY</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Type&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;stylus&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;ForceDevice&quot;</span>&nbsp;<span class="st0">&quot;ISDV4&quot;</span>&nbsp; &nbsp; <span class="re3"># Tablet PC ONLY</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Button2&quot;</span>&nbsp;<span class="st0">&quot;3&quot;</span><br />
EndSection<br />
<br />
Section <span class="st0">&quot;InputDevice&quot;</span><br />
&nbsp; &nbsp; Driver&nbsp; &nbsp; <span class="st0">&quot;wacom&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;eraser&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Device&quot;</span>&nbsp; <span class="st0">&quot;/dev/ttyS0&quot;</span>&nbsp; &nbsp;<span class="re3"># serial ONLY</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Type&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;eraser&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;ForceDevice&quot;</span>&nbsp; &nbsp;<span class="st0">&quot;ISDV4&quot;</span>&nbsp; &nbsp;&nbsp; &nbsp;<span class="re3"># Tablet PC ONLY</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; <span class="st0">&quot;Button3&quot;</span>&nbsp;<span class="st0">&quot;2&quot;</span><br />
EndSection<br />
<br />
Section <span class="st0">&quot;InputDevice&quot;</span><br />
&nbsp; &nbsp; Driver&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;wacom&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; &nbsp; <span class="st0">&quot;cursor&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;Device&quot;</span>&nbsp; &nbsp; <span class="st0">&quot;/dev/ttyS0&quot;</span>&nbsp; <span class="re3"># serial ONLY</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;Type&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;cursor&quot;</span><br />
&nbsp; &nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;ForceDevice&quot;</span>&nbsp;<span class="st0">&quot;ISDV4&quot;</span>&nbsp; &nbsp; <span class="re3"># Tablet PC ONLY</span><br />
<span class="re3">#&nbsp; &nbsp;Option&nbsp;&nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;Mode&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;Absolute&quot;</span><br />
EndSection<br />
<br />
<span class="re3"># This section is <span class="kw1">for</span> the TabletPC that supports touch</span><br />
<span class="re3">#Section </span><span class="st0">&quot;InputDevice&quot;</span><br />
<span class="re3">#&nbsp; Driver&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;wacom&quot;</span><br />
<span class="re3">#&nbsp; Identifier&nbsp; &nbsp; </span><span class="st0">&quot;touch&quot;</span><br />
<span class="re3">#&nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;Device&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;/dev/input/wacom&quot;</span>&nbsp; <span class="re3"># USB ONLY</span><br />
<span class="re3">#&nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;Type&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;touch&quot;</span><br />
<span class="re3">#&nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;ForceDevice&quot;</span>&nbsp; &nbsp;<span class="st0">&quot;ISDV4&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re3"># Tablet PC ONLY</span><br />
<span class="re3">#&nbsp; Option&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="st0">&quot;USB&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&quot;on&quot;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re3"># USB ONLY</span><br />
<span class="re3">#EndSection</span><br />
<span class="re3">#END TABLET SECTION</span><br />
<br />
Section <span class="st0">&quot;ServerLayout&quot;</span><br />
&nbsp; &nbsp; Identifier&nbsp; <span class="st0">&quot;Default Layout&quot;</span><br />
&nbsp; &nbsp; Screen&nbsp; &nbsp; <span class="st0">&quot;Default Screen&quot;</span><br />
<span class="re3">#&nbsp; &nbsp;InputDevice&nbsp; &nbsp; </span><span class="st0">&quot;Synaptics Touchpad&quot;</span><br />
<br />
<span class="re3">#added to get tablet working</span><br />
&nbsp; &nbsp; InputDevice&nbsp; &nbsp; &nbsp;<span class="st0">&quot;stylus&quot;</span>&nbsp; &nbsp; <span class="st0">&quot;SendCoreEvents&quot;</span><br />
&nbsp; &nbsp; InputDevice&nbsp; &nbsp; &nbsp;<span class="st0">&quot;cursor&quot;</span>&nbsp; &nbsp; <span class="st0">&quot;SendCoreEvents&quot;</span><br />
&nbsp; &nbsp; InputDevice&nbsp; &nbsp; &nbsp;<span class="st0">&quot;eraser&quot;</span>&nbsp; &nbsp; <span class="st0">&quot;SendCoreEvents&quot;</span><br />
<span class="re3">#&nbsp; &nbsp;InputDevice&nbsp; &nbsp; </span><span class="st0">&quot;touch&quot;</span>&nbsp;&nbsp;<span class="st0">&quot;SendCoreEvents&quot;</span><br />
EndSection</div></div>

<p>After doing that, you should be able to reboot and the pen should be working.  You can do things like configure the buttons with <code>xsetwacom</code> (and you&#8217;ll need that when it comes time to rotate the screen), but I kept getting this error when I tried to run <code>xsetwacom</code>:</p>

<div class="codecolorer-container bash"><div class="codecolorer" style="font-family: monospace;">$ xsetwacom <br />
xsetwacom: error <span class="kw1">while</span> loading shared libraries: libwacomcfg.so<span class="nu0">.0</span>: cannot open shared object file: no such file or directory.</div></div>

<p>I made a lucky guess, and fixed the problem with a quick ldconfig:</p>

<div class="codecolorer-container bash" style="height:35px;"><div class="codecolorer" style="font-family: monospace;">$ sudo ldconfig&nbsp; <span class="re3"># that was a lucky guess.</span></div></div>

<p><em>Update:</em> There were some issues with the wacom calibration after a sleep/resume cycle <em>if</em> the laptop screen had been rotated during that prior wake cycle (this happens a <em>lot</em> more than it seems, given how complex that description is.)  I&#8217;ve written up a workaround <a href="http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-rotations-waking-up-on-the-wrong-side.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ciscavate.org/2009/01/the-linux-tablet-wacom-drivers.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
