<?xml version="1.0" encoding="UTF-8"?>
     <rss version="2.0">
         <channel>
             <title>Dobrica Pavlinušić&apos;s Weblog / Blog</title>
             <link>http://blog.rot13.org/</link>
             <description>Personal weblog about technology, Open Source, perl, GNU etc...</description>
             <language>en</language>
             <copyright>Copyright 2013</copyright>
             <lastBuildDate>Tue, 19 Feb 2013 19:23:15 +0100</lastBuildDate>
             <generator>http://www.sixapart.com/movabletype/</generator>
             <docs>http://www.rssboard.org/rss-specification</docs>
     
             <item>
                 <title>NSND 2013 Osijek : RTL-SDR software defined radio</title>
                 <description><![CDATA[<p>
For a long time, doing anything with various devices which use radio waves proved to be almost impossible for software geeks like me. Fortunately with RTL DVB-T sticks all this is about to change, and at our last meeting <a href="http://www.nsnd.org/2013/02/13/nsnd-osijek-2013-the-birth/">Ništa se neće dogoditi in Osijek</a> I tried to show some of possibilities using them.
</p>
<p>
For a start you need compatible Realtek RTL2832U DVB-T tuner. Just go over to <a href="http://sdr.osmocom.org/trac/wiki/rtl-sdr">rtl-sdr osmocomSDR</a> and examine supported tuner list. 

Choice of DVB-T sticks in Croatia isn't so good. They are about <a href="http://saturn.ffzg.hr/rot13/index.cgi?rtl_sdr">170 kn and come with FC001[23] tuners</a>: Hama 53176  has FC0013 tuner and TV LV5TDLX has FC0012 tuner.

I did some research and ordered this <a href="http://dx.com/p/dvb-t-digital-tv-receiver-usb-dongle-w-fm-remote-control-antenna-black-149928">$13 DVB-T from dealextreme</a> which has R820T tuner:
<pre>
dpavlin@blue:~$ sudo rtl_test -t
Using device 0: ezcap USB 2.0 DVB-T/DAB/FM dongle
Found Rafael Micro R820T tuner
</pre>
It's a good choice, shipping is free (but takes few weeks), and it works well with ADS-B which was first interesting application which I wanted to try.
<br>
I also ordered <a href="http://dx.com/p/e4000-2832u-usb-dvb-t-tv-receiver-stick-white-black-172105">E4000+2832U USB DVB-T TV Receiver Stick for $16.50</a> but it hasn't arrived yet so I don't have any experience with it.
</p>

<a href="http://blog.rot13.org/assets_c/2013/02/IMG_20130216_130118-155.html" onclick="window.open('http://blog.rot13.org/assets_c/2013/02/IMG_20130216_130118-155.html','popup','width=2592,height=1944,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2013/02/IMG_20130216_130118-thumb-320x240-155.jpg" width="320" height="240" alt="IMG_20130216_130118.jpg" class="mt-image-center" /></a>

<p>
I also have a good fortune that my friend is very skillful in radio communications, so he created variant of <a href="http://www.balarad.net/">Coaxial Collinear Antenna for ADS-B Receiver</a>. This one is more sensitive to static electricity which means it's not suitable for top of skyscraper scenarios, but in works very nicely. Under construction is filter which would cut everything expect interesting part of RF spectrum which would also solve problem of static electricity.
</p><p>
On the picture, you can see part of it together with output in browser created using <a href="https://github.com/antirez/dump1090">dump1090</a>. It's important to note that normal DVB-T antena without any modification will work with R820T tuner since it's most sensitive so far, but range will be much smaller. 
</p>
<p>
<a href="http://blog.rot13.org/assets_c/2013/02/IMG-20121223-WA0000-158.html" onclick="window.open('http://blog.rot13.org/assets_c/2013/02/IMG-20121223-WA0000-158.html','popup','width=800,height=600,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2013/02/IMG-20121223-WA0000-thumb-320x240-158.jpg" width="320" height="240" alt="IMG-20121223-WA0000.jpg" class="mt-image-center"  /></a>
We also had good luck with getting data about keypresses from power-socket controlling device using <a href="https://github.com/merbanan/rtl_433">rtl_433 from github</a> with just a peace of wire as antenna for short range tests.
</p>
]]></description>
                 <link>http://blog.rot13.org/2013/02/nsnd-2013-osijek-rtl-sdr-software-defined-radio.html</link>
                 <guid>http://blog.rot13.org/2013/02/nsnd-2013-osijek-rtl-sdr-software-defined-radio.html</guid>
         
                          <pubDate>Tue, 19 Feb 2013 19:23:15 +0100</pubDate>
             </item>
     
             <item>
                 <title>libvirt vnc console without virt-manager</title>
                 <description><![CDATA[<p>
We have all been in this situation. We need quick access to hardware console of machine to debug nasty hang (kernel oops in my example). But now-days, we are all in the cloud, and that machine is libvirt's kvm. I just need access to VNC console, and installing whole <tt>virt-manager</tt> seems like overkill. So, let's see if we can make it somewhat easier and quicker.
</p>
<p>
First ssh into your host machine (<tt>garak</tt> in this example, tunneling some VNC ports along the way:
<pre>
dpavlin@x200:~$ ssh $(seq 5900 5904 | awk '{ print "-L "$1":localhost:"$1 }') garak
</pre>
If you have more than 4 vms running on this machine, increase 5904 above.
</p>
<p>
Then, using <tt>virtsh</tt> list all domains, and examine vnc port:
<pre>
virsh # list
 Id    Name                           State
----------------------------------------------------
 1     stargate                       running
 2     treca                          running
 15    hroug                          running
 16    close                          running

virsh # vncdisplay close
:2
</pre>
Now, back on laptop, in another terminal start vnc viewer:
<pre>
dpavlin@x200:~$ vncviewer :2
</pre>
Since close didn't respond to <tt>reboot</tt>, <tt>reset</tt> or <tt>shutdown</tt> commands in <tt>virsh</tt>, I opted to kill kvm process and start it again with <tt>start close</tt>. Quick alternative to virt-manager installation.
</p>]]></description>
                 <link>http://blog.rot13.org/2012/12/libvirt-vnc-console-without-virt-manager.html</link>
                 <guid>http://blog.rot13.org/2012/12/libvirt-vnc-console-without-virt-manager.html</guid>
         
                          <pubDate>Fri, 21 Dec 2012 01:10:42 +0100</pubDate>
             </item>
     
             <item>
                 <title>Is wireless keyboard safe for your passwords?</title>
                 <description><![CDATA[<p>
<a href="http://blog.rot13.org/assets_c/2012/12/usb-extesion-cable-152.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/12/usb-extesion-cable-152.html','popup','width=877,height=425,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/12/usb-extesion-cable-thumb-320x155-152.jpg" width="320" height="155" alt="usb-extesion-cable.jpg" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
I recently got big screen TV (big for my living room at least). It came with few HDMI ports and VGA, so next logical step was to connect computer to it. And of course, then I noticed that it would be really handy to have wireless keyboard and mouse to complete this nice setup. However, I also wanted to ssh over that networks, so I started examining how secure wireless keyboards are. tl;dr; summary: they are not secure.
</p>
<p>
First I asked for suggestions which wireless keyboard to buy. I have quite big fingers, so mini models just doesn't do it for me. I got suggestion to take a look at <a href="http://www.logitech.com/en-us/product/wireless-touch-keyboard-k400?crid=26">Logitech K400</a> and sure enough it seemed like good choice. One of first things that I noticed is that it supports 128-bit AES encryption. I started to have a good feeling about it, but I wanted to know more, so I hoped to 
<a href="http://www.logitech.com/images/pdf/roem/Logitech_Adv_24_Ghz_Whitepaper_BPG2009.pdf">Logitech Advanced 2.4 GHz Technology</a> pdf and discovered that not all keys are encrypted.To quote documentation:
<blockquote>
The encryption applies to all standard keyboard keys (a, s, d, f...) and modifiers (Shift, Ctrl, Alt...). The 
multimedia keys (Play, Pause, Mute...) that may be implemented in some keyboards are transmitted in 
clear text. 
</blockquote>
 How can I trust keyboard which doesn't encrypt all traffic? This got me thinking. Can I somehow verify that keys are encrypted? Is this wide-spread problem? Can I make mistake and broadcast my keystrokes to whole world?
</p>
<p>
Sure I can. For older 27Mhz keyboards there is <a href="http://www.remote-exploit.org/articles/keykeriki_v1_0_-_27mhz/index.html">KeyKeriki v1.0 - 27MHz</a> project which implement sniffer for it (<a href="http://youtu.be/jEvb2c0FOHo">video DeepSec 2009: Keykeriki: Universal Wireless Keyboard Sniffing For The Masses</a>). But, Logitech is 2.4Ghz, so it's secure, right? Well, there is <a href="http://www.remote-exploit.org/articles/keykeriki_v2_0__8211_2_4ghz/index.html">KeyKeriki v2.0 - 2.4GHz</a> which does same for 2.4Ghz (<a href="http://youtu.be/qBEPX4qIbMw">video Keykeriki V2 - Practical Exploitation of Modern Wireless Devices [SIGINT10]</a>). OK, Logitech does some kind of AES on top of that, but since it does transfer some keys unencrypted, and it's proprietary technology I can't really check that.
</p>
<p>
I also got suggestion to use bluetooth keyboard because it's secure. Well, quick search revealed <a href="http://greatscottgadgets.com/ubertoothone/">Ubertooth One</a> which basically defeats bluetooth protection with a <a href="http://youtu.be/KSd_1FE6z4Y">bit of sniffing and a little brute force</a>.
</p>
<p>
By this point, I was puzzled. Is there secure wireless keyboard with touchpad which I can buy? Something I can be sure that it encrypts all traffic as opposed to only some keys? Or is usb extension cable only real solution for me?
</p>
]]></description>
                 <link>http://blog.rot13.org/2012/12/is-wireless-keyboard-safe-for-your-passwords.html</link>
                 <guid>http://blog.rot13.org/2012/12/is-wireless-keyboard-safe-for-your-passwords.html</guid>
         
                          <pubDate>Tue, 11 Dec 2012 16:47:11 +0100</pubDate>
             </item>
     
             <item>
                 <title>Printrbot experience - 3D printers are not for everyone</title>
                 <description><![CDATA[<p>
Allmost a year ago, me and three other friends decided it's a very good idea to support <a href="http://www.kickstarter.com/projects/printrbot/printrbot-your-first-3d-printer">Printrbot kickstarter</a> project and get our-selfs 3D printer. We didn't have any particular use for it (other than printing Raspberry Pi case when it arrives) but it <em>seemed like the right thing to do</em>. This post will try to explain how far did we manage to get with it and why we where wrong.
</p>
<p>
If you examine original Kickstarter page you will see following description:
<blockquote>
A desktop 3D printer you can build in a couple hours. Print plastic parts you design or download - even parts for another printer.
</blockquote>
Our experience can't be further from that statement. For a start, Brook Drumm (to whom I'm ethereally grateful for his efforts to make 3D printers commonplace) got his campaign funded with 
1,808 backers who spent $830,827 instead of just $25,000 goal he envisioned. This was both good and bad. Good part was that after funding we knew that we will have 3D printer (I'm carefully not mentioning printing anything), but the bad part was logistics: there was simply no way he would be able to print 1808 versions of original design on 3D printers themselves (idea of RapRap-like printers, which Printrbot was one iteration, was always to make them self-replicating). So, he decided to change design and move toward wooden laster-cut parts for most of construction, and print just parts which where necessary.
</p>
<p>
This also introduced significant delay in printer shipment, but when you are funding Kickstarter project, you should be prepared for it, so I'm not complaining. When it finally arrived this summer (10 months after end of Kickstarter campaign), it was significantly bigger than I expected:
</p>

<a href="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_174405-134.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/IMG_20120907_174405-134.html','popup','width=1944,height=2592,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_174405-thumb-320x426-134.jpg" width="320" height="426" alt="IMG_20120907_174405.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

<p>
To be honest, we did upgrade to bigger <a href="http://printrbot.com/shop/plus/">Printrbot PLUS</a> so I guess we should expect a lot of parts.
As we are mostly software geeks, we did only reasonable thing to do: check if all parts are present comparing it with <a href="http://printrbot.com/wp-content/uploads/2012/11/PLUS-BOM-11-1-12.pdf">bill of materials</a> which we got printed out.
</p>

<a href="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183819-137.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183819-137.html','popup','width=2592,height=1944,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183819-thumb-320x240-137.jpg" width="320" height="240" alt="IMG_20120907_183819.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

<a href="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183833-140.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183833-140.html','popup','width=1944,height=2592,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_183833-thumb-320x426-140.jpg" width="320" height="426" alt="IMG_20120907_183833.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

<a href="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_185152-143.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/IMG_20120907_185152-143.html','popup','width=1944,height=2592,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/IMG_20120907_185152-thumb-320x426-143.jpg" width="320" height="426" alt="IMG_20120907_185152.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

<p>
This is the point where our problems started. We had missing one bag of parts which included termistor and switches. We contacted Printrbot HQ and they sent us missing parts. We started assembling following
<a href="http://www.youtube.com/playlist?list=PL8F5E3B9A7DFA840C">Printrbot Building Instructions by Brook Drumm</a> and it took us more than 50 hours to get to our first blob.
</p>

<a href="http://blog.rot13.org/assets_c/2012/11/IMG_20121019_232542-146.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/IMG_20121019_232542-146.html','popup','width=2592,height=1944,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/IMG_20121019_232542-thumb-320x240-146.jpg" width="320" height="240" alt="IMG_20121019_232542.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>



<p>
Of course, it didn't work perfectly on first run. We where trying to print <a href="http://www.thingiverse.com/thing:24238">5mm Calibration Cube Steps</a> is ABS plastic which we received with our Printrbot (we even got additional 450g of ABS plastic as replacement for power supply which wasn't part of international shipments).
</p>

<a href="http://blog.rot13.org/assets_c/2012/11/5mm_Cal_Cubes-149.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/11/5mm_Cal_Cubes-149.html','popup','width=1200,height=986,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/11/5mm_Cal_Cubes-thumb-320x262-149.jpg" width="320" height="262" alt="5mm_Cal_Cubes.jpg" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></a>

</p>
Actually, it still doesn't work well as you can see in video below, but we are hopeful. In the meantime we figure out that best source of information is <a href="http://www.printrbottalk.com/forum/">Printrbot Talk forum</a> and <a href="http://www.printrbottalk.com/wiki">wiki</a>. Forum is somewhat depressive since most users have some kind of problems with their built, just as we do.
</p>

<iframe width="560" height="315" src="http://www.youtube.com/embed/52TAynbSfLU" frameborder="0" allowfullscreen></iframe>

<p>
To be honest, we didn't expect smooth ride. However, as I mentioned before we are not really hardware hackers, and my only conclusion is that home-made 3D printers are really for people who already have enough experience to make their own 3D printer, and not for software guys like us.
However, we won't give up, and I fully expect to have working printer (after we get replacement barrings from Printrbot HQ because our are sticky). We are collecting <a href="http://wiki.rot13.org/rot13/index.cgi?printrbot">useful add-on models and instructions on our Printrbot wiki page</a> but I didn't expect that we will have to contact Printrbot HQ twice for missing and replacement parts. But eventually we will be able to <a href="http://www.thingiverse.com/search?q=Raspberry+Pi+box&sa=Search">print Raspberry Pi box</a>, I hope :-)
</p>

</p>]]></description>
                 <link>http://blog.rot13.org/2012/11/printrbot-experience-3d-printers-are-not-for-everyone.html</link>
                 <guid>http://blog.rot13.org/2012/11/printrbot-experience-3d-printers-are-not-for-everyone.html</guid>
         
                          <pubDate>Sat, 10 Nov 2012 17:57:42 +0100</pubDate>
             </item>
     
             <item>
                 <title>mdadm - how to tune your md software RAID</title>
                 <description><![CDATA[<p>
We had software RAID in form of <tt>md</tt> devices on Linux for a long time. Here are few useful hints how to make it work better...
</p>

<h2>Scrub your array to check data consistency</h2>
<p>
I will assume that you are already monitoring your disks using smart, but from time to time it's useful to force full re-scan of your array to make sure that all data is still there and consistent. Some filesystems provide this option to scrub data on it's own (zfs and btrfs comes to mind) but if your filesystem is located on md array you can always force it using
<pre>
echo check > /sys/block/md0/md/sync_action
</pre>
I would suggest to do this from cron, hopefully during weekend or some other time when your load is lower.
</p>

<h2>Adding write-intent bitmap to speed up recovery</h2>
<p>
If you installed your md array a long time ago, you probably didn't turn on <a href="https://raid.wiki.kernel.org/index.php/Bitmap">write-intent bitmap</a>. It's very useful when you have to recover because bitmap will track changes and this will prevent long re-sync times when disks have to read and compare every block. To turn it on use:
<pre>
mdadm --grow --bitmap=internal /dev/md0
</pre>
</p>

<h2>Mirror between two devices of same speed</h2>
<p>
Recently, one of my 500Gb disks in RAID1 (mirror) failed. I decided to replace it with 1Gb drive which was unfortunately green drive (which basically means slow). Adding two drives of different speed in mirror will reduce performance to single <b>slower</b> drive which is a shame. Since I wasn't able to add additional disk and wasn't prepared to give up redundancy of data I started searching around and found that I can specify one disk as write-mostly using:
<pre>
mdadm --add /dev/md0 --write-mostly /dev/sdb1
</pre>
Same trick will work on combination of hard drive and SSD, but in that case, you will slow down writes to speed of your hard drive.
</p>]]></description>
                 <link>http://blog.rot13.org/2012/10/mdadm-how-to-tune-your-md-software-raid.html</link>
                 <guid>http://blog.rot13.org/2012/10/mdadm-how-to-tune-your-md-software-raid.html</guid>
         
                          <pubDate>Wed, 03 Oct 2012 13:43:20 +0100</pubDate>
             </item>
     
             <item>
                 <title>X11 running on Nook Color without Android stack</title>
                 <description><![CDATA[<p>
<a href="http://blog.rot13.org/assets_c/2012/08/Nook%20Color%20X11%20frame%20buffer-131.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/08/Nook%20Color%20X11%20frame%20buffer-131.html','popup','width=1920,height=2560,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/08/Nook%20Color%20X11%20frame%20buffer-thumb-320x426-131.jpg" width="320" height="426" alt="Nook Color X11 frame buffer.jpg" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
I have been toying around with idea of having real Linux stack (X11 and friends) on Nook Color. While this seems like a silly thing to do, it does allow me to use <a href="http://en.wikipedia.org/wiki/X2x">x2x</a> and transfer keyboard and mouse from my laptop to tablet which is handy. If also allows me to run X11 applications on tablet screen using <tt>DISPLAY=nook.lan:0</tt>. I was fortunate enough to find <a href="http://thomaspolasek.blogspot.ca/2012/04/arch-linux-lxde-w-xorg-mouse-keyboard_16.html">blog post how to run Linux framebuffer X server on Android</a> but I wanted to use touchscreen so I decided to write my own <tt>xorg.conf</tt> (this brings back memories...).
</p>
<p>
To get full-blown Debian-based distribution on your Android take a look at <a href="https://play.google.com/store/apps/details?id=com.botbrew.basil">BotBrew Basil</a>. It's <a href="http://www.emdebian.org">Emdebian</a> based distribution which will setup mount points and various other stuff so you don't have to do that manually. Since it's Debian based, you are not limited to Emdebian packages -- you can (and will have to) add normal sid:
<pre>
(BotBrew)root@localhost:/# cat /etc/apt/sources.list.d/sid.list 
deb [arch=armel] http://ftp.debian.org/debian sid main contrib non-free
</pre>
If you want to know more about Emdebian hop over to <a href="http://penta.debconf.org/dc12_schedule/track/Building%20and%20porting/852.en.html">DebConf 12: Integrating Emdebian into Debian</a>
[<a href="http://debconf12.debconf.org/video.xhtml">video</a>].
</p>
<p>
With all this prepared, we are ready to shut down Android stack:
<pre>
adb shell setprop ctl.stop media
adb shell setprop ctl.stop zygote
adb shell setprop ctl.stop surfaceflinger
adb shell setprop ctl.stop drm
</pre>
Next step is installation of required packages:
<pre>
dpavlin@t61p:~$ adb shell
root@android:/ # TERM=xterm chroot /data/botbrew-basil/ /bin/bash --login
(BotBrew)root@localhost:/# apt-get install xserver-xorg-video-fbdev xserver-xorg-input-evdev \
   xserver-xorg-input-multitouch x11-xserver-utils xinit \
   matchbox matchbox-keyboard xterm
</pre>
I decided to use matchbox, mostly becuase it's only window manager which comes with on-screen keyboard which is useful on touch screen device.
</p>
<p>
After installation you will need to setup X symlink and create <tt>.xinitrc</tt>:
<pre>
root@android:/ # ln -s /usr/bin/Xorg /usr/bin/X

root@android:/ # cat ~/.xinitrc                                              
( sleep 1 ; matchbox-keyboard -o portrait ) &
xhost 192.168.1.61
matchbox-session
</pre>
Finally, you need to create <tt>xorg.conf</tt>:
<pre>
Section "ServerLayout"
    Identifier    "Layout0"
    Screen        "Screen0"
    InputDevice   "cyttsp-i2c" "CorePointer"
    InputDevice   "gpio-keys" "CoreKeyboard"
    InputDevice   "twl4030-keypad" "CoreKeyboard"
EndSection

Section "InputDevice"
    Identifier    "gpio-keys"
    Driver        "evdev"
    Option        "Device" "/dev/input/event0"
    # code 102 (KEY_HOME)
    # code 116 (KEY_POWER)
EndSection

Section "InputDevice"
    Identifier     "twl4030-keypad"
    Driver         "evdev"
    Option         "Device" "/dev/input/event1"
    # code 114 (KEY_VOLUMEDOWN)
    # code 115 (KEY_VOLUMEUP)
EndSection

Section "InputDevice"
    Identifier     "cyttsp-i2c"
    Driver         "multitouch"
    Option         "Device" "/dev/input/event2"
    # mouse should move as fast as finger and not faster
    Option         "AccelerationScheme" "none"
    # evdev has it, multitouch doesn't so it behaves like touchpad
#   Option         "IgnoreRelativeAxes" "True"
EndSection

Section "Device"
    Identifier    "Card0"
    Driver        "fbdev"
    Option        "fbdev" "/dev/graphics/fb0"
    # rotate screen to be in sync with touchpad orientation
    Option        "Rotate" "CCW" # CW=90 UD=180 CCW=270
EndSection

Section "Screen"
    Identifier    "Screen0"
    Device        "Card0"
EndSection
</pre>
This will map all hardware keys and use mutitouch driver for screen. To make it work, I used <tt>evtest</tt> package which allows you to see events from input devices so you will know which device produce keyboard events and which produce multitouch events. To be honest, this solution isn't prefect, because screen behaves like touchpad, so you can't just point to screen and expect your cursor to just to that position.
</p>
<p>Following <a href="http://blog.rot13.org/video/nook-x11-fb-no-android.flv">video</a> shows X server in action.
<iframe width="560" height="315" src="http://www.youtube.com/embed/6huSlMdjtPk?rel=0" frameborder="0" allowfullscreen></iframe>
</p>
<p>
This is simple unaccelerated frame buffer. This makes performance less then desirable. There are a few implementations of OMAP xorg server:
<ul>
<li>
<a href="http://anonscm.debian.org/gitweb/?p=collab-maint/xf86-video-omapfb.git;a=blob;f=README;hb=HEAD">xf86-video-omapfb</a>
uses DSS kernel support which seems to be part of CM kernel, so this might be good next thing to try out
</li>
<li>
<a href="http://cgit.freedesktop.org/xorg/driver/xf86-video-omap/tree/README">xf86-video-omap</a>
is newer implementation, but this requires 3.3 kernel and is not yet stable.
</li>
</ul>
Having accelerated OMAP X server and fixed touchscreen issues would make Nook somewhat nice Linux tablet, if only it isn't so heavy for day-to-day use :-)
</p>
]]></description>
                 <link>http://blog.rot13.org/2012/08/x11-running-on-nook-color-without-android-stack.html</link>
                 <guid>http://blog.rot13.org/2012/08/x11-running-on-nook-color-without-android-stack.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">Android</category>
         
                          <pubDate>Mon, 13 Aug 2012 11:26:33 +0100</pubDate>
             </item>
     
             <item>
                 <title>Internet Archive BookReader plack server</title>
                 <description><![CDATA[<p>
Last year, I had good fortune to get acquiented with great work which <a href="http://openlibrary.org/">Open Library</a> does. It's part of <a href="http://blog.archive.org/2011/12/03/brewster-kahle%E2%80%99s-30-november-long-now-talk/">Internet Archive</a> which itself is a library. So, libraries are not (yet) dead it seems. <a href="http://longnow.org/seminars/02011/nov/30/universal-access-all-knowledge/">Brewster Kahle's Long Now Talk</a> explains it much better than I can do, so take 90 minutes to listen to it.
</p>
<p>
Most interesting part of Open Library (IMHO) is <a href="http://openlibrary.org/dev/docs/bookreader">Internet Archive BookReader</a> which is JavaScript application which allows users to browse scanned books on-line. For quite some time, I wanted to install something similar to provide web access to our collection of scanned documents. I have found instructions for <a href="http://raj.blog.archive.org/2011/03/17/how-to-serve-ia-style-books-from-your-own-cluster/">serving IA like books from own cluster</a>, but I didn't have a cluster, and converting all documents to IA book format seemed like an overhead which I would like to avoid.
</p>
<p>
Instead, I decided to write image server for JavaScript front-end using <a href="http://plackperl.org/">plack</a>. I mean, it's basically a directory with images, right? Oh, how wrong can I be? <tt>:-)</tt>
</p>
<p>
It turs out that we have pictures in multiple formats (so sorting them required removing common prefix and using number only to get correct order), and most of are scanned images in pdf documents. Here are all types of documents which can be automatically collected into book for on-line browsing:
<ul>
<li>images of scanned pages
<li>multi-file pdf file with single image per page
<li>single pdf file with one image for each page
<li>single pdf file with more than one (usually 4) horizontal bitmap strips for each page
<li>normal pdf documents which contain text and needs rendering to bitmap
</ul>

</p>
<p>Source code of my <a href="https://github.com/dpavlin/bookreader">plack server for Internet Archive book reader is on github</a>, so if you want to take a look, hop over there...</p>]]></description>
                 <link>http://blog.rot13.org/2012/07/internet-archive-bookreader-plack-server.html</link>
                 <guid>http://blog.rot13.org/2012/07/internet-archive-bookreader-plack-server.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">code</category>
         
         
                     <category domain="http://www.sixapart.com/ns/types#tag">perl</category>
         
                     <category domain="http://www.sixapart.com/ns/types#tag">plack</category>
                          <pubDate>Thu, 05 Jul 2012 14:42:42 +0100</pubDate>
             </item>
     
             <item>
                 <title>DORS/CLUC 2012 conference</title>
                 <description><![CDATA[<p>
As you all know by now, last week we had another <a href="http://www.dorscluc.org/">DORS/CLUC conference</a>. This time I had two talks and one workshop.
</p>
<a href="http://blog.rot13.org/assets_c/2012/05/SysAdmin%20Cookbook-122.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/05/SysAdmin%20Cookbook-122.html','popup','width=960,height=720,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/05/SysAdmin%20Cookbook-thumb-150x112-122.png" width="150" height="112" alt="SysAdmin Cookbook.png" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
<h2><a href="http://www.slideshare.net/dpavlin/sysadmin-cookbook-13049855">Sysadmin cookbook</a></h2>
<p>
I never proparly introduced this project here, but if you want to know more about my convention based documentation examine the presentation of hop over to <a href="http://sysadmin-cookbook.rot13.org/">http://sysadmin-cookbook.rot13.org/</a> and take a look at generated documentation.
</p>
<p>
Basic idea is to document changes in easy to write files on file system (preserving symlinks to files on system which allows you to quickly see if cookbook is deployed or not and diff between template and deployed configuration). I know that my cookbook is mix of various things I did in last three years, but I do find it useful, so hopefully it might be useful to you also.
</p>
<a href="http://blog.rot13.org/assets_c/2012/05/Kindle%20-%20so%20much%20more%20than%20ebook%20reader-125.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/05/Kindle%20-%20so%20much%20more%20than%20ebook%20reader-125.html','popup','width=960,height=720,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/05/Kindle%20-%20so%20much%20more%20than%20ebook%20reader-thumb-150x112-125.png" width="150" height="112" alt="Kindle - so much more than ebook reader.png" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
<h2><a href="http://www.slideshare.net/dpavlin/kindle-so-much-more-than-ebook-reader">Kindle - so much more than ebook reader</a></h2>
This was longer talk about my one year experience with Kindle. I must say that I'm still very happy user of Kindle, but in this talk, I tried to cover <a href="http://www.mobileread.com/forums/forumdisplay.php?f=150">Kindle Developer's Corner at mobileread forum</a> as well as other related projects:
<ul>
<li><a href="https://github.com/dpavlin/k3libre/">Free Libre command-line tools for Kindle development</a></li>
<li><a href="https://github.com/hwhw/kindlepdfviewer">A PDF (plus DJVU, ePub, TXT, CHM, FB2, HTML...) viewer</a> made for e-ink framebuffer devices, using muPDF, djvulibre, crengine
<a href="http://www.mobileread.com/forums/showthread.php?t=157047">mobileread forum thread</a></li>
<li><a href="https://github.com/hwhw/kindlevncviewer">A VNC viewer for ebook readers</a> which allows you to use Kindle as second screen
<a href="http://www.mobileread.com/forums/showthread.php?t=150434">mobileread forum thread</a>
</li>
</ul>
So if you are still wondering if it's worth the effort to install third-party software on Kindle, answer is <em>yes, it is!</em>.
</p>
<a href="http://blog.rot13.org/assets_c/2012/05/Web%20scale%20monitoring-128.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/05/Web%20scale%20monitoring-128.html','popup','width=960,height=720,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/05/Web%20scale%20monitoring-thumb-150x112-128.png" width="150" height="112" alt="Web scale monitoring.png" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
<h2><a href="http://www.slideshare.net/dpavlin/web-scale-monitoring">Web scale monitoring</a></h2>
<p>
This was a workshop which doesn't have much with web (it's about monitoring ADSL CPE devices and provider equipment in-between), but it shows (I hope) nice way to integrate several project to provide nice scalable monitoring infrastructure. It's composed of:
<ul>
<li><a href="http://gearman.org/">Gearman</a> message queue together with <a href="http://search.cpan.org/dist/Gearman-Driver/">Gearman::Driver</a> provide on-demand scaling of workers</li>
<li><a href="http://redis.io/">redis</a> saves all data from external systems (LDAP, CRM) and all results from statistics collection nicely providing data for web interface</li>
<li><a href="http://www.postgresql.org/">PostgreSQL</a> stores all collected data, using hstore to provide unstructured key value store for different data from different devices while still allowing us to use SQL to query data (and export it to data warehouse)</li>
<li><a href="http://mojolicio.us/">Mojolicious</a> provides web interface which uses data from redis and provides JSONP REST interface for <a href="http://angularjs.org/">Angular.js</a></li>
</ul>
All in all it's a nice combination of tools which served my need quite well, so I hope it was also useful to people who attended workshop.
</p>]]></description>
                 <link>http://blog.rot13.org/2012/05/dorscluc-2012-conference.html</link>
                 <guid>http://blog.rot13.org/2012/05/dorscluc-2012-conference.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">conferences</category>
         
                          <pubDate>Tue, 29 May 2012 12:16:13 +0100</pubDate>
             </item>
     
             <item>
                 <title>rpcbind is new portmap or how to make nfs secure</title>
                 <description><![CDATA[<p>
I was installing NFS server on otherwise public host recently, and noticed that <a href="http://tldp.org/HOWTO/NFS-HOWTO/security.html">conventional wisdom about securing NFS server</a> is somewhat dated. My goal was to expose NFS on two internal interfaces without exposing it to whole wide Internet (assumptions about network security changed a lot since NFS was designed, sadly).
</p>
<p>
For a start, you are probably running <tt>rpcbind</tt> instead of portmap on recent Debian installations. So you will need to modify flags which are passed to portmap on startup:
<pre>
root@rsync1:~# cat /etc/default/rpcbind 
OPTIONS="-w -l -h 172.16.10.2 -h 192.168.0.219"
</pre>
You will also need to add following line:
<pre>
root@rsync1:~# grep rpcbind /etc/hosts.deny 
rpcbind: ALL
</pre>
Now you will notice that <tt>rpcinfo -p</tt> still works OK on localhost. That's because rpcbind will always add loopback address, so we have to test it from another machine:
<pre>
root@rsync1-dev:~# rpcinfo -p 192.168.0.219
rpcinfo: can't contact portmapper: RPC: Authentication error; why = Client credential too weak
</pre>
That's more like it! If we take a look in log...
<pre>
root@rsync1:~# tail -1 /var/log/auth.log
May  8 20:31:51 rsync1 rpcbind: connect from 192.168.0.21 to dump(): request from unauthorized host
</pre>
...we don't even have to guess local system IP adress. We'll allow this host to connect with...
<pre>
root@rsync1:~# grep rpcbind /etc/hosts.allow 
rpcbind: 192.168.0.21
</pre>
We can also check our tcp wrappers configuration with:
<pre>
root@rsync1:~# tcpdmatch rpcbind 192.168.0.21
client:   address  192.168.0.21
server:   process  rpcbind
access:   granted
</pre>
]]></description>
                 <link>http://blog.rot13.org/2012/05/rpcbind-is-new-portmap-or-how-to-make-nfs-secure.html</link>
                 <guid>http://blog.rot13.org/2012/05/rpcbind-is-new-portmap-or-how-to-make-nfs-secure.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">howto</category>
         
         
                     <category domain="http://www.sixapart.com/ns/types#tag">sysadmin nfs</category>
                          <pubDate>Tue, 08 May 2012 21:32:42 +0100</pubDate>
             </item>
     
             <item>
                 <title>munin migration and upgrade to v2</title>
                 <description><![CDATA[<p>
I always loved graphs. For my monitoring needs I'm using <a href="http://munin-monitoring.org/">munin</a> so in last few days I was migrating one installation from machine behind DSL line to co-location (virtual) server. Using old munin server, I would occasionally get e-mail alerts about unavailable services, mostly because <a href="http://www.ntop.org/products/n2n/">n2n</a> (which we use to connect to nodes) forgot about node or dropped packets because of busy DSL line. In the process, I decided to jump ahead and install version 2.0-rc5 from Debian unstable. This blog post will try to describe my journey...
</p>
<p>
I started simply by installing new munin instance in new (virtual) machine. I decided that historic data is important, so I decided to move configuration and graphs over to new instance. Simply coping rrd files over didn't went all that well and resulted in dreaded <tt>This RRD was created on another architecture</tt> error. This was unfortunate but rrd files where so large, that transfer won't fit into 5 minute munin poll interval anyway, so I had to take different approach.
</p>
<p>
To keep all historical data and not loose any munin polls while I transfer them I decided to first configure new munin node to poll all clients (so new updates will be preserved) and while this is running copy over rrd files from old server. This involved editing all nodes (9 of them!) and <a href="http://sourceforge.net/projects/clusterssh/">Cluster SSH</a> came as perfect solution to add additional <tt>allow ^192\.168\.0\.10$</tt> lines in <tt>/etc/munin/munin-node.conf</tt> on all nodes.
</p>
<p>
Coping rrd files had to be done using <tt>rrdtool dump/restore</tt> and it had to be done over compressed ssh link due to slow DSL line. For that, small shell script came very handy:
<pre>
#!/bin/sh -x

dir=/var/lib/munin/maxxo


via_ssh="ssh -o ControlPath=/tmp/ssh_sock -o ControlMaster=auto -o Compression=yes root@10.1.3.10"

if [ ! -e /tmp/ssh_sock ] ; then
        $via_ssh read
fi

ls $dir/*.rrd | while read file
do
        echo $file
        rrdtool dump $file | $via_ssh rrdtool restore - $file --force-overwrite
done
</pre>
You need to start it <em>twice</em>. First invocation will ask for password and open master ssh socket which next invocation will use for transfers of rrd files using compressed ssh link, without connection overhead for each file. We are talking about <b>4560</b> rrd files with total of over 250Mb, after all... Even with all this, it took hour and a half to transfer all that over, so setting up update of existing files was really required.
</p>
<p>
You might think that it's all, but unfortunately, it's not. Looking in <tt>/var/log/munin/munin-update.log</tt> I could see <tt> [FATAL] Socket read timed out to node.  Terminating process.</tt>. Some of nodes required more time than default value provided by munin (30 sec) to respond with all data. It seems that ipmi plugins are notoriously snow to respond for example. To change server-side timeout, you have to pass <tt>--timeout 90</tt> to <tt>munin-update</tt> utility. Unfortunately, in Debian you can't do that by modifying <tt>munin-cron</tt> invocation in <tt>/etc/cron.d/munin</tt> because it passes all parameters to <tt>munin-limit</tt> which doesn't have timeout option and dies on you (moral of the story: check cron e-mail while configuring cron jobs). In the end, I edited <tt>/usr/bin/munin-cron</tt> directly, changing one line:
<pre>
/usr/share/munin/munin-update <b>--timeout 90</b> $@ || exit 1
</pre>
This will probably break with next update, but this blog post will remind me to change it again :-)
</p>
<p>
There where also a few tweaks on munin-node plugins to make them work inside kvm. <tt>iostat_ios</tt> plugin from <tt>munin-plugins-extra</tt> didn't like virtio devices which have major number 254, same as LVM2 devices which it ignores. Following patch solved this problem:
<pre>
diff --git a/cs-munin/etc/munin/plugins/iostat_ios b/cs-munin/etc/munin/plugins/iostat_ios
index 1380eb1..823df63 100755
--- a/cs-munin/etc/munin/plugins/iostat_ios
+++ b/cs-munin/etc/munin/plugins/iostat_ios
@@ -101,7 +101,7 @@ sub filter {
         return 0 if ($major ==   1); # RAM devices
         return 0 if ($major ==   9); # MD devices
         return 0 if ($major ==  58); # LVM devices
-        return 0 if ($major == 254); # LVM2 devices
+        return 1 if ($major == 254); # LVM2 devices and KVM virtio
     }
     if(defined($tmpnam)) {
         return 0 if ($tmpnam =~ /part\d+$/);
</pre>
</p>
<a href="http://blog.rot13.org/assets_c/2012/05/ksm-day-119.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/05/ksm-day-119.html','popup','width=497,height=316,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/05/ksm-day-thumb-320x203-119.png" width="320" height="203" alt="ksm-day.png" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
<p>
I also decided to use <a href="http://lwn.net/Articles/326364/">ksm</a> which is enabled by following line in <tt>/etc/rc.local</tt>:
<pre>
echo 1 > /sys/kernel/mm/ksm/run
</pre>
And of course, now I had to graph it with <a href="https://github.com/HeMan/ksm-plugin">simple shell ksm munin plugin</a>. Dropping sharing line on this graph makes me think that it wasn't really needed, but we'll see in few more days.
</p>
<p>
To track other kvm parameters, I used <tt>munin-libvirt-plugins</tt> which comes with it's own helper script <tt>munin-libvirt-plugins-detect</tt> which you have to run to enable plugin and generate configuration.
</p>
<p>
For a web server, I opted to use <tt>apache2</tt> and <tt>libapache2-mod-fastcgi</tt>  together with <tt>graph_strategy cgi</tt> and <tt>html_strategy cgi</tt> in <tt>/etc/munin/munin.conf</tt> mostly to save some performance on polling machine. To make it work, I had to copy <tt>/etc/munin/apache.conf</tt> into <tt>/etc/apache2/conf.d/munin</tt> and uncomment relevant fast-cgi lines inside. After that, dynamically generated html is available at <code>http://munin.example.com/munin-cgi/</code> and if you ever run <tt>munin-html</tt> before, you will still get old (obsolete) html pages if you visit page directly.
</p>
<p>
Next step would probably be to get <a href="http://munin-monitoring.org/wiki/rrdcached">rrdcached</a> up and running...
</p>
<p>
<em>Update:</em> If you 404 or 500 errors when generating cgi graphs, and you will have to add <tt>cgitmpdir /tmp/munin/</tt> to <tt>/etc/munin/munin.conf</tt>.
</p>]]></description>
                 <link>http://blog.rot13.org/2012/05/munin-migration-and-upgrade-to-v2.html</link>
                 <guid>http://blog.rot13.org/2012/05/munin-migration-and-upgrade-to-v2.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">howto</category>
         
         
                     <category domain="http://www.sixapart.com/ns/types#tag">munin</category>
                          <pubDate>Wed, 02 May 2012 20:15:50 +0100</pubDate>
             </item>
     
             <item>
                 <title>Read two-column pdf files on Kindle</title>
                 <description><![CDATA[<p>
I really like Kindle because it allows me to run <a href="http://blog.rot13.org/2011/12/liberate-your-kindle-3-and-get-full-screen-terminal.html">my own selection of software</a> on it. However, when I try to persuade other Kindle owners in all the benefits of running custom software, I usually get response like: <em>but it already does everything I need</em>. That might be true, but that's only because you never tried to read two column article on Kindle...
</p>
<p>
Fortunately, we have <a href="https://github.com/hwhw/kindlepdfviewer">alternative pdf reader for Kindle</a> based on <a href="http://www.mupdf.com/">muPDF</a> library which is mostly written in lua. This is especially nice since it allowed me to <a href="https://github.com/hwhw/kindlepdfviewer/pull/21">add support for reading two-column pdf layouts</a> which you can see in <a href="http://youtu.be/moiRFi6Ttp4">following video</a>:
</p>

<p>
<iframe width="420" height="315" src="http://www.youtube.com/embed/moiRFi6Ttp4?rel=0" frameborder="0" allowfullscreen></iframe>
</p>

<p>
Basically, you press <tt>F</tt> to switch to new layout and then use <tt>fiveway</tt> buttons to move down the column, or right to move to top of next column, with page change if needed. If you move to left, you will be positioned to bottom of previous column which is useful if you want to read again last thing.
</p>
<p>
If you like this feature, <a href="https://github.com/dpavlin/k3libre/blob/master/liberate-kindle.txt">liberate your kindle</a> and <a href="https://github.com/dpavlin/kindlepdfviewer/downloads">download latest version of pdf reader</a>, drop it in <tt>/mnt/us/customupdates</tt> and press <tt>Shift Shift I</tt> to install it from louchpad. Then press <tt>Shift P D</tt> to start it. <a href="https://github.com/hwhw/kindlepdfviewer/wiki">Wiki pages</a> of project describe all available shortcuts and there is <a href="http://www.mobileread.com/forums/showthread.php?t=157047">active thread on mobileread forum</a>.
</p>]]></description>
                 <link>http://blog.rot13.org/2012/03/read-two-column-pdf-files-on-kindle.html</link>
                 <guid>http://blog.rot13.org/2012/03/read-two-column-pdf-files-on-kindle.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">Kindle</category>
         
         
                     <category domain="http://www.sixapart.com/ns/types#tag">pdf</category>
                          <pubDate>Thu, 01 Mar 2012 23:48:49 +0100</pubDate>
             </item>
     
             <item>
                 <title>Printing from Koha to Zebra printers on local Windows machine</title>
                 <description><![CDATA[<p>
<a href="http://blog.rot13.org/assets_c/2012/02/zebra%20S4m-115.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/02/zebra%20S4m-115.html','popup','width=1500,height=1500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/02/zebra%20S4m-thumb-320x320-115.jpg" width="320" height="320" alt="zebra S4m.jpg" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>

As you know by now, I'm somewhat biased towards <a href="http://blog.rot13.org/2010/08/evolis-dualys-pixel-exact-printing-without-cups.html">pixel-exact printing on strange printers</a>. This time around, I was tasked with requirement to make Koha print bar-code labels from web interface on <a href="http://www.zebra.com/id/zebra/na/en/index/products/printers/industrial_commercial/s4m.html">Zebra S4M printers</a> which are locally connected to Windows clients over USB.
</p>
<p>
At first sight, this seems like an easy task. Zebra printers are supported under CUPS on Linux and OSX, so there shouldn't be any problems, right? For a start I found out that CUPS driver doesn't work well, mostly because it's older that Windows version of driver, and doesn't seem to send all ZPL codes required to print label.
<br>
To make thing even worse, since printer is connected locally to Windows machine, it presents itself as Windows GDI printer which doesn't want to print ZPL (printer protocol) directly without wrapping ZPL in magic quotes and enabling it in Windows.
</p>
<p>
On the other side, Koha tries to print labels using normal print dialog in Windows. This won't work well, because we (again) need pixel exact label as opposed to web page randomly scaled to printer label. To make this worse, client Windows machines are behind firewall, so I can't send label to IP address of client because all I can see in request is IP address of our firewall.
</p>
<p>
To solve all this problem I decided to deploy following setup:
<ul>
<li>Label design is done in Inkscape. To rasterize it to bitmap I decided to use <a href="http://librsvg.sourceforge.net/">rsvg-convert</a> which has nice option to create exact bitmap size from SVG file in which I replace placeholders with variable values (bar-code and call number)
<li>Printers are installed in Windows using Generic/Text driver which is only one which will just pass data directly to printer
<li>To share printer to Linux, I decided to install <tt>lpd</tt> server so I don't have to open local Windows accounts to access printer (and they are behind firewall, so It's safe)
<li>To get local IP address of client (so I can send ZPL to internal IP address on which lpd is listening) I decided to redirect client to internal web server (behind firewall, same as clients) which knows client IP address, and knows where to send label.
<li>From user's perspective, Koha redirects clients to internal CGI script, which in turn rasterize label from request parameters, sends it to printer and redirect browser back to Koha page (with additional parameter of IP address of client/printer). This page shows label which was just printerd by pointing directly to internal server's PNG rendering of label. It also inserts data about printed label (including printer IP) in database for audit log.
</ul>
</p>
<p>
Since I couldn't use CUPS to produce ZPL for printer, I wrote <a href="https://github.com/dpavlin/Printer-Zebra">Printer-Zebra</a> which can convert <tt>pbm</tt> and <tt>pnm</tt> formats (easily created from png label using <tt>pgntopnm</tt>). Even better, it also includes script which can render ZPL printer output back to <tt>pbm</tt> bitmap which is the only good way to verify that your solution doesn't anti-alias bar-codes or does something similar to reduce print quality on back and white printers.
Rasterizer was also very useful when tracking differences between Windows driver output (gathered by printing to File on Windows) and CUPS one. 
</p>

]]></description>
                 <link>http://blog.rot13.org/2012/02/printing-from-koha-to-zebra-printers-on-local-windows-machine.html</link>
                 <guid>http://blog.rot13.org/2012/02/printing-from-koha-to-zebra-printers-on-local-windows-machine.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">projects</category>
         
                          <pubDate>Fri, 10 Feb 2012 12:20:56 +0100</pubDate>
             </item>
     
             <item>
                 <title>Nook Color as Android tablet</title>
                 <description><![CDATA[<p>
<a href="http://blog.rot13.org/assets_c/2012/01/nook-ics-112.html" onclick="window.open('http://blog.rot13.org/assets_c/2012/01/nook-ics-112.html','popup','width=540,height=720,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2012/01/nook-ics-thumb-320x426-112.jpg" width="320" height="426" alt="nook-ics.jpg" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>

For a last month or so I used <a href="http://www.barnesandnoble.com/p/nook-color-barnes-noble/1100437663">Barnes & Noble Nook Color</a> as Android tablet. This post will try to explain what is wrong with Android tablets and now to fix this.
</p>
<p>
For a start, original Android distribution on Nook doesn't make it really Android tablet (no market). But there is easy solution since this device is supported by <a href="http://www.cyanogenmod.com/devices/nook-color">CynanogenMod 7 for Nook Color</a> to get proper Android distribution. So, let's get started with hints for easier life with your new tablet...
</p>

<h2>adb doesn't see Nook Color</h2>

<p>
For a start, you won't see Nook in <tt>adb devices</tt> listing. This is easily fixed with proper device id in <tt>~/.android/adb_usb.ini</tt> like this:

<pre>
dpavlin@t61p:~/.android$ echo 0x2080 &gt; ~/.android/adb_usb.ini && adb kill-server && adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
2011120012345678        device
</pre>

</p>

<h2>Nook Color specific application</h2>

<p>
There are lot of application which will look quite broken on your Nook when running Android 2.3. Some of them require audio input, GPS or camera and they generally won't work. There is also problem with application which just don't know about wired 1024*600 screen size and produce strange small screen centered on big display.
</p>
<p>
However, this is just a list of few extremely useful apps which you should install on Nook with CM7:

<ul>
<li><a href="https://market.android.com/details?id=com.dalingrin.nookcolortweaks">Nook Color Tweaks</a> - change speed of CPU, turn USB host more and more
<li><a href="https://market.android.com/details?id=com.assid.android.nookrecalibrate">Nook Screen Recalibrate</a> - having problems with screen sensitivity?
<li><a href="http://forum.xda-developers.com/showthread.php?t=965023">Nook Key Editor</a> allows you to map back and menu keys which are very useful on Android 2.3 to volume up/down which makes tablet much more useful.
</ul>

Once you install all of this, you will be painfully aware that Android 2.3 just isn't OS which works well on tables. So, let's try to see what Google has in source for tablets...
</p>

<h2>Ice Cream Sandwich</h2>

<p>
To get most out of Android on tablet, you have to hop over to <a href="http://forum.xda-developers.com/showthread.php?t=1444943">CM9/ICS Nightly Builds</a> and install unstable builds on ICS on Nook Color.
After initial install reboot into recovery, flash Google Applications from <tt>gapps-ics-4.0.3-sam-noinit.zip</tt>, turn off signature verification and install <tt>fix-bootanimation.zip</tt> and <tt>telephony-permission-fix.zip</tt>. Unfortunately browser application doesn't work for me well, and usually segfaults with:
<pre>
F/libc    ( 2878): Fatal signal 11 (SIGSEGV) at 0x0000001f (code=1)
I/DEBUG   ( 1072): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 1072): Build fingerprint: 'bn/bn_encore/encore:2.3.4/IML74K/228551:user/release-keys'
I/DEBUG   ( 1072): pid: 2878, tid: 2895  >>> com.android.browser <<<
</pre>
</p>
<p>
ICS on Nook currently doesn't have hardware acceleration (<a href="https://plus.google.com/105051985738280261832/posts/2FXDCz8x93s">but older Androids also doesn't have it</a>) and it freezes from time to time (so you will get quite used to holding power button for 8 seconds or more to turn it off), but ICS is really so much better experience on tablet that I would really recommend it.
</p>
<p>
Finally a note about hardware performance: Nook Color has 512Mb of RAM and Ti OMAP 3621 @ 800 MHz which makes it probably a bit slow for ICS. As o consequence I wouldn't really recommend any Android laptops which are slower than this for ICS.
</p>
<p>
<em>Update 2012-02-07</em>: There is also <a href="http://techerrata.com/browse/nightly_kangs/encore">CyanogenMod Kang build with OpenGL</a> enabled which works very well. In fact, so well that it fixes <a href="http://code.google.com/p/hackerskeyboard/issues/detail?id=169">problem in Hacker's keyboard</a> :-)
</p>
]]></description>
                 <link>http://blog.rot13.org/2012/01/nook-color-as-android-tablet.html</link>
                 <guid>http://blog.rot13.org/2012/01/nook-color-as-android-tablet.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">howto</category>
         
         
                     <category domain="http://www.sixapart.com/ns/types#tag">Android</category>
         
                     <category domain="http://www.sixapart.com/ns/types#tag">Nook</category>
                          <pubDate>Sat, 21 Jan 2012 12:30:42 +0100</pubDate>
             </item>
     
             <item>
                 <title>28C3: recommended watching</title>
                 <description><![CDATA[<img alt="28c3.png" src="http://blog.rot13.org/2011/12/31/28c3.png" width="145" height="141" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" />
<p>
Each year, we get a treat right before end of the year in form of <a href="http://events.ccc.de/congress/2011/wiki/Welcome">28C3</a>. This year, I can recommend following lectures as a must-see:
<ul>

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4777.en.html">r0ket++</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4777-en-r0ket_h264.mp4">video</a>
<br>Very nice ARM Cortex M3 embedded device with Nokia LCD, battery, RF interface and extension headers.

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4766.en.html">802.11 Packets in Packets</a> 
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4766-en-802_11_packets_in_packets_h264.mp4">video</a>
<br>Drop wifi packet on unsuspecting listeners without access to network segment!

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4736.en.html">Defending mobile phones</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4736-en-defending_mobile_phones_h264.mp4">video</a>
<br>Visit <a href="http://gsmmap.org">GSMmap.org</a> to see if your GSM networks are protecting you or <a href="http://srlabs.de/gsm-map-tutorial/">contribute data</a>!

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4847.en.html">Reverse Engineering USB Devices</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4847-en-reverse_engineering_usb_devices_h264.mp4">video</a>
<br>Very similar to my approach to USB examinations.

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4800.en.html">How governments have tried to block Tor</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4800-en-how_governments_have_tried_to_block_tor_h264.mp4">video</a>
<br>It's arms race all over again, this time on Internet.

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4735.en.html">Reverse-engineering a Qualcomm baseband</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4735-en-reverse_engineering_a_qualcomm_baseband_h264.mp4">video</a>
<br><del>
I can't wait to see release of this tools on <a href="http://code.google.com/u/112978292662734058287/">code.google.com</a></del>
Available at <a href="http://code.google.com/p/qcombbdbg/">http://code.google.com/p/qcombbdbg/</a>

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4928.en.html">KinectFusion</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4928-en-kinectfusion_h264.mp4">video</a>
<br>I would love to see something similar in open source code.

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4663.en.html">Cellular protocol stacks for Internet</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4663-en-cellular_protocol_stacks_for_internet_h264.mp4">video</a>
<br>Very good overview of cellular stack as it is today

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4686.en.html">Implementation of MITM Attack on HDCP-Secured Links</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4686-en-implementation_of_mitm_attack_on_hdcp_secured_links_h264.mp4">video</a>
<br>NeTv is very interesting ARM/FPGA/Linux device which overlays webkit content over HDMI signal on your TV using chroma key.

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4688.en.html">Introducing Osmo-GMR</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4688-en-introducing_osmo_gmr_h264.mp4">video</a>
<br>Osmocom got some support for satellite phones

<li>
<a href="http://events.ccc.de/congress/2011/Fahrplan/events/4587.en.html">bup: Git for backups</a>
<a href="http://ftp.ccc.de/congress/28C3/mp4-h264-HQ/28c3-4587-en-bup_git_for_backups_h264.mp4">video</a>
<br>Nice backup system with de-duplication implemented on top of git's pack file

</ul>

</p>
]]></description>
                 <link>http://blog.rot13.org/2011/12/28c3-recommended-watching.html</link>
                 <guid>http://blog.rot13.org/2011/12/28c3-recommended-watching.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">conferences</category>
         
                          <pubDate>Sat, 31 Dec 2011 14:13:49 +0100</pubDate>
             </item>
     
             <item>
                 <title>batman-adv layer 2 mesh ad-hoc network at NSND Moravice 2011</title>
                 <description><![CDATA[<a href="http://blog.rot13.org/assets_c/2011/12/NSND2011Moravicewifi-106.html" onclick="window.open('http://blog.rot13.org/assets_c/2011/12/NSND2011Moravicewifi-106.html','popup','width=960,height=720,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://blog.rot13.org/assets_c/2011/12/NSND2011Moravicewifi-thumb-320x240-106.png" width="320" height="240" alt="NSND2011Moravicewifi.png" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;" /></a>
<p>
We had another gathering called Nothing will happen in Moravice, and this time we wanted to be prepared for it. So we got 2 WRT and 2 TP-Link devices with good faith that we will have stable Internet there. However, our telecom provider decided to screw up our order to increase bandwidth from 4Mbit/s to 10Mbit/s for event and instead decided to downgrade our access to 512Kbit/s. So we opted to create following simple network architecture which involved multiple hops to alternative 4Mbit/s upstream and batman-adv mesh setup.
</p>
<p>
<a href="http://www.open-mesh.org/wiki/batman-adv">batman-adv</a> is quite cool layer-2 mash network which operates in ad-hoc mode and allows adaptive routing over mash and multiple upstream providers (at DHCP request or renew time, so we made our DHCP lease time down to 5 minutes). Joining network is quite simple:
<pre>
iwconfig wlan0 mode ad-hoc essid nsnd-batman
ifconfig wlan0 mtu 1528
modprobe batman_adv
batctl if add wlan0

ifconfig wlan0 up
ifconfig bat0 up
dhclient bat0
</pre>
This will bring any laptop with ad-hoc support (and not all of them have it), and relatively recent kernel (2.6.32 from Debian stable is a bit too old - batman-adv got included in <a href="http://kernelnewbies.org/Linux_2_6_33">2.6.33</a> kernel) up and running on mash network.
</p>
<p>
My own experience with this experiment is very positive, mostly because we had around 5 clients in mash at any time, compared with overloaded WRTs which handled rest of 40 wifi enabled devices. But, I hope that during next event more people will upgrade to 2.6.33 or newer kernels, so we can have even better mash connectivity.
</p>
]]></description>
                 <link>http://blog.rot13.org/2011/12/batman-adv-layer-2-mesh-ad-hoc-network-at-nsnd-moravice-2011.html</link>
                 <guid>http://blog.rot13.org/2011/12/batman-adv-layer-2-mesh-ad-hoc-network-at-nsnd-moravice-2011.html</guid>
         
                     <category domain="http://www.sixapart.com/ns/types#category">hack-of-the-week</category>
         
                          <pubDate>Wed, 21 Dec 2011 22:35:13 +0100</pubDate>
             </item>
     
         </channel>
     </rss>

