<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="html">Avian’s Blog</title>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/"/>
<link rel="self" type="application/atom+xml" href="http://www.tablix.org/~avian/blog/atom.xml"/>
<updated>2010-03-03T21:46:47+01:00</updated>
<author>
	<name>Tomaž Šolc</name>
        <uri>http://www.tablix.org/~avian/blog/</uri>
</author>
<id>http://www.tablix.org/~avian/blog/</id>


<entry>
<title type="html">1n41 break 48</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/03/1n41_break_48/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/03/1n41_break_48/</id>
<published>2010-03-03T21:37:20+01:00</published>
<updated>2010-03-03T21:46:47+01:00</updated>

<category term="Life"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://www.tablix.org/~avian/blog/images2/2010/03/1n4148_diode_broken_in_half.jpg"><img alt="1n4148 diode broken in half" src="http://www.tablix.org/~avian/blog/images2/2010/03/1n4148_diode_broken_in_half-t.jpg" /></a>

<p>This is what was left of a <a class="zem_slink" href="http://en.wikipedia.org/wiki/1N4148" title="1N4148">1n4148</a> diode after an aluminum 47 μF electrolytic capacitor was repeatedly charged through it from a low-impedance source. Average power dissipation was well below its specified maximum.</p>


<p>Signal diodes don&#39;t survive peak currents much larger than their continuous current rating.</p>


</div>
</content>
</entry>

<entry>
<title type="html">Doesn&#39;t do what I want</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/03/doesn_t_do_what_i_want/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/03/doesn_t_do_what_i_want/</id>
<published>2010-03-01T19:34:00+01:00</published>
<updated>2010-03-01T19:34:00+01:00</updated>

<category term="Code"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Here&#39;s another weird Perl quirk that has a potential to cause error messages in scripts which lead you into a completely wrong direction.</p>

<pre>
$ mkdir foo
$ perl -le &#39;print open(F, &#34;&#60;foo&#34;);&#39;
1
</pre>

<p>To cite Perl documentation, <i>&#34;Open returns nonzero upon success&#34;</i>. Obviously, this means that Perl thinks the <i>open()</i> call above succeeded. However the filehandle F is useless - all it ever does is return <i>undefs</i>.</p>


<p>So I guess this means that before every call to <i>open()</i> you should check if the argument accidentally points to a directory, so you can give a meaningful error message. Otherwise you might read a bunch of <i>undefs</i> from it without noticing.</p>


</div>
</content>
</entry>

<entry>
<title type="html">No phone home</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/02/no_phone_home/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/02/no_phone_home/</id>
<published>2010-02-28T20:20:04+01:00</published>
<updated>2010-02-28T20:39:11+01:00</updated>

<category term="Code"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>A while ago I wrote about a method of <a href="http://www.tablix.org/~avian/blog/archives/2009/12/walls_around_walled_gardens/">sandboxing</a> certain untrusted applications by using unprivileged user accounts.</p>


<p>Obviously Chrome browser and Skype from that example had to had access to the network to be useful. However applications today have a nasty habit of phoning home and sharing all sorts of data with its creators, some of which you might prefer to keep private. So for an untrusted application that has no business talking to the network its only logical to preemptively prevent it from doing that.</p>


<p>On a recent Linux system, it&#39;s really simple to do that, as long as the application is running under its own user ID:</p>

<pre>
# iptables -D OUTPUT -o \! lo -m owner --uid-owner foo -j DROP
</pre>

<p>What this does is drop all packets originating from a process owned by user <i>foo</i> and are not destined for the loopback interface. You can put this line into <i>/etc/rc.local</i> for instance to make the setting permanent.</p>


<p>Of course, just as with my previous post a warning is in order here. This will only prevent casual network transmissions from applications not specifically written to be resilient to such methods.</p>


<p>Actually, it&#39;s pretty easy to circumvent if you know what you&#39;re dealing with. Pings from <i>/bin/ping</i> for instance, will get through on my system, because that binary is set SUID root.</p>


</div>
</content>
</entry>

<entry>
<title type="html">Lab power supply</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/02/lab_power_supply/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/02/lab_power_supply/</id>
<published>2010-02-26T20:56:19+01:00</published>
<updated>2010-02-26T20:56:19+01:00</updated>

<category term="Analog"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I&#39;ve been wanting to design and build a new 50 W lab power supply for some time now. It has turned out to be one of those projects that you think will take a month tops and then the lack of time stretches it to half a year and counting.</p>


<p>The minimum requirements are 0 - 25 V and 2 A with an adjustable current limit. I&#39;ve considered four approaches for such a design:</p>

<ul>
<li>A plain linear regulator,</li>

<li>linear regulator combined with a transformer with multiple taps,</li>

<li>linear regulator with a thyristor pre-regulator and</li>

<li>switched-mode regulator.</li>
</ul>

<p>These are pretty much sorted by ascending complexity and efficiency.</p>


<p>The power requirements are just barely within the reach of the first option. However that would require a big passive heat sink (I want to keep away as far away from unreliable fans as possible). Plus building a new device that would operate around 10 - 20% efficiency most of the time doesn&#39;t really feel right. So scratch that.</p>


<p>I spent quite a bit of time researching the second option. In fact, I have an almost completed design for it on the drawing board right now. It uses a two-tap transformer with a relay to switch between them - transformers with more taps aren&#39;t easy to find. The regulator part is roughly based on the <a href="http://www.electronics-lab.com/projects/power/003/index.html">0-30 V power supply</a> from Electronics lab.</p>


<p>Still, I&#39;m not really happy with it. I have doubts about the longevity of the relay and worst-case heat dissipation is still uncomfortably high.</p>


<p>By the way, the original Electronics lab design is pretty broken in several ways and I strongly doubt that it meets its specifications - but that is perhaps a topic for another post.</p>


<p>I&#39;m not going to even consider building a switcher for this purpose. It&#39;s noisy and has worse regulation characteristics than a linear design. Not really something I would want in a lab supply. Plus finding appropriate ferrite cores for switchers is always a pain.</p>


<p>So, right now I&#39;m looking into a thyristor pre-regulator. There&#39;s a pretty good <a href="http://cds.linear.com/docs/Application%20Note/an32.pdf">application note</a> from Linear technology that has a basic circuit. It looks solid on paper and I&#39;m going to give it a try tomorrow to see how it behaves in practice. If it works as advertised I&#39;m more than prepared to go back to the drawing board with this.</p>


</div>
</content>
</entry>

<entry>
<title type="html">Catching own tail</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/02/catching_own_tail/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/02/catching_own_tail/</id>
<published>2010-02-22T16:31:50+01:00</published>
<updated>2010-02-25T09:28:39+01:00</updated>

<category term="Code"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>How to make a shell (er, Bash) script wait until a certain line appears in a log file? Sounds simple, but I have yet to find an elegant solution for this task.</p>


<p>A common use case for this is when you start a daemon that forks into background and you need to wait in the script until the daemon has finished doing something.</p>


<p>The following is the best I came up with:</p>

<pre>
tail -f $LOG | ( \
	IFS=&#34;&#34;
	while read LINE; do
		if echo &#34;$LINE&#34; | grep &#34;$CANARY&#34; &#62; /dev/null; then
			break
		fi
	done
	pkill -f &#34;tail -f $LOG&#34;
)
</pre>

<p><i>IFS</i> is unset here because it appears to help with buffering for some reason. Without that line the script will sometimes wait even after the <i>$CANARY</i> has been appended to the file. That can be problematic when the line you&#39;re looking for is the last one that will be written to the log.</p>


<p>The most obvious flaw here is that <i>pkill</i> will kill all <i>tail</i> processes, even those that have not been started from this script.</p>


<p>Any better solutions are most welcome.</p>


<p><i>Update: Thanks to Nace here&#39;s a better version of the script that is more carefull at killing the tail process:</i></p>

<pre>
PARENT=&#34;$BASHPID&#34;                 # (Bash 4.x)
PARENT=`$SHELL -c &#39;echo $PPID&#39;`   # (Bash 3.x)
tail -f $LOG | ( \
	IFS=&#34;&#34;
	while read LINE; do
		if echo &#34;$LINE&#34; | grep &#34;$CANARY&#34; &#62; /dev/null; then
			break
		fi
	done
	pkill -P &#34;$PARENT&#34; -xf &#34;tail -f $LOG&#34;
)
</pre>

</div>
</content>
</entry>

<entry>
<title type="html">RAF museum</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/01/raf_museum/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/01/raf_museum/</id>
<published>2010-01-26T22:16:09+01:00</published>
<updated>2010-01-26T22:32:47+01:00</updated>

<category term="Life"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I spent the better part of the day in the <a class="zem_slink" href="http://www.rafmuseum.org.uk" title="Royal Air Force Museum London">Royal Air Force Museum</a> in London (and the rest of the day traveling to and from it via various combinations of walking, trains, subways and taxis).</p>


<p>Needless to say there&#39;s a lot of amazing technology piled up in there and I would recommend a visit to anyone interested in aircrafts. In fact there are so many machines crammed in the old hangars that it&#39;s quite a challenge to make a good photograph of any single one of them.</p>


<p>The order of exhibitions is a bit chaotic concerning the time line. But that can be a plus - it&#39;s interesting to compare the size of a modern jet fighter with a Spitfire.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2010/01/eurofighter_typhoon.jpg"><img alt="Eurofighter Typhoon" src="http://www.tablix.org/~avian/blog/images2/2010/01/eurofighter_typhoon-t.jpg" /></a>

<p><i>The nose of Eurofighter Typhoon.</i></p>

<a href="http://www.tablix.org/~avian/blog/images2/2010/01/handley_page_victor.jpg"><img alt="Handley Page Victor" src="http://www.tablix.org/~avian/blog/images2/2010/01/handley_page_victor-t.jpg" /></a>

<p><i>Handley Page Victor</i></p>

<a href="http://www.tablix.org/~avian/blog/images2/2010/01/avro_vulcan.jpg"><img alt="Avro Vulcan" src="http://www.tablix.org/~avian/blog/images2/2010/01/avro_vulcan-t.jpg" /></a>

<p><i>Bomb bay of Avro Vulcan</i></p>

<a href="http://www.tablix.org/~avian/blog/images2/2010/01/boeing_b17g.jpg"><img alt="Boeing B17G" src="http://www.tablix.org/~avian/blog/images2/2010/01/boeing_b17g-t.jpg" /></a>

<p><i>Boeing B17G</i></p>


</div>
</content>
</entry>

<entry>
<title type="html">Boiler conclusions</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/01/boiler_conclusions/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/01/boiler_conclusions/</id>
<published>2010-01-23T23:09:20+01:00</published>
<updated>2010-01-23T23:09:20+01:00</updated>

<category term="Life"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Here are a couple of conclusions of my <a href="http://www.tablix.org/~avian/blog/archives/2010/01/camera_in_a_bathroom/">electrical water heater</a> <a href="http://www.tablix.org/~avian/blog/archives/2010/01/image_recognition_101/">monitoring</a> project.</p>

<ul>
<li>On average I use 3 kWh of electrical energy per day on hot water. That&#39;s 90 kWh per month or roughly half my monthly electricity bill.</li>

<li>For comparison, space heating consumes 1120 kWh of heat per month in winter (if I can believe what the district heating company is billing me). According to my last year&#39;s <a href="http://www.tablix.org/~avian/blog/archives/2009/04/my_contribution_to_global_warming/">car calculations</a>, I burned up 740 kWh worth of chemical energy per month in my car.</li>

<li>Shifting all water heater&#39;s consumption to night time would save me 2.2€ per month or 26€ yearly.</li>
</ul>

<p>Surprisingly, providing hot water seems to require an order of magnitude less energy than daily car commute and two orders of magnitude less than providing moderately warm living quarters. That&#39;s something I didn&#39;t really expect.</p>


<p>Accordingly, the savings are low too. A timer would perhaps pay itself back in two years or so if I don&#39;t count in my own time required to install it. And I doubt I&#39;ll still be in the same apartment two years from now.</p>


<p>So it&#39;s not really worth doing anything right now. At least not until there&#39;s a bigger difference in electrical energy prices between day and night or <a href="http://en.wikipedia.org/wiki/Smart_grid">smart grid</a> becomes reality.</p>


</div>
</content>
</entry>

<entry>
<title type="html">Tube clock</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/01/tube_clock/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/01/tube_clock/</id>
<published>2010-01-22T18:51:35+01:00</published>
<updated>2010-01-22T18:51:35+01:00</updated>

<category term="Digital"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I finally found the time to finish assembling the &#34;Russian&#34; <a href="http://www.ladyada.net/make/icetube/">tube clock</a> I got from <a href="http://en.wikipedia.org/wiki/Dedek_Mraz">Dedek Mraz</a>. It seems I&#39;m starting to gather quite a collection of weird <a href="http://www.tablix.org/~avian/blog/archives/2008/03/serial_numbers_001_002/">time keeping devices</a>.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2010/01/assembled_ice_tube_clock_from_adafruit.jpg"><img alt="Assembled Ice Tube Clock from Adafruit." src="http://www.tablix.org/~avian/blog/images2/2010/01/assembled_ice_tube_clock_from_adafruit-t.jpg" /></a>

<p>Assembling the kit was a no-brainer - <a href="http://www.ladyada.net/make/icetube/solder.html">instructions</a> include three pictures for every component you need to solder and have you check parts of the circuit before continuing. The only slightly tricky bit was getting <a href="http://www.tablix.org/~avian/blog/archives/2010/01/vfd_porn/">the tube</a> to align nicely with the casing before soldering its (many) pins.</p>


<p>Considering the kit comes from US, it was a nice touch to include 24 h European time and date format (yes, the clock can also show the day of week and current date). The power brick only had an US power plug though. I replaced it with the EU one - the circuit itself already supported 230 V.</p>


<p>Also, the pictures don&#39;t really show how the display looks like. Mine glows in a blue-green color and isn&#39;t particularly bright (I have the brightness set to 55). If you remember old video recorders that used to blink &#34;12:00&#34; (they also used to have VFDs) - that&#39;s how the tube actually looks like.</p>


<p>One annoying thing I noticed is that it&#39;s hard to set the clock to the second. You can&#39;t wait for the wall clock to catch up with the frozen seconds display because the menu will time out in less than a minute.</p>


<p>This means it&#39;s harder to assess the accuracy. Also this circuit doesn&#39;t provide a trimmer capacitor to fine adjust the oscillator frequency. I had the idea to add a <a class="zem_slink" href="http://en.wikipedia.org/wiki/DCF77" title="DCF77">DCF77</a> receiver (it appears there&#39;s a contact provided on the PCB board for that). However the FAQ page says the boost converter is too noisy for such a receiver to work near the clock. If that&#39;s true, I wonder what other devices also are also affected by this interference.</p>


</div>
</content>
</entry>

<entry>
<title type="html">Avatar</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/01/avatar/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/01/avatar/</id>
<published>2010-01-20T23:45:34+01:00</published>
<updated>2010-01-20T23:45:34+01:00</updated>

<category term="Life"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I went to see Avatar last week.</p>


<p>Yes, if you ignore the visuals it would be boring. But if anything this is the kind of movie to see for the pretty moving images alone. This also means that it was still worth watching even after hearing all kinds of spoilers - it&#39;s been in theaters for a month now and I overheard most of the story in various conversations before I even went to the cinema. Still, I very much enjoyed it. Pseudo-3D-induced headache that followed not that much.</p>


<p>Actually, one of the reasons I didn&#39;t go watch it sooner was because I didn&#39;t found the still frames on posters very appealing. Interesting how the perception changes when things are moving.</p>


<p>One pleasant surprise was that nothing I saw in the movie was outrageously outside the domain of possible. Slower-than-light travel, no artificial gravity, a planet with unbreathable atmosphere and aliens that don&#39;t speak English (and no universal translator) are all rare nice touches in mainstream Hollywood science-fiction. Ok, floating mountains are stretching that a bit, but explanation with the <a class="zem_slink" href="http://en.wikipedia.org/wiki/Meissner_effect" title="Meissner effect">Meissner effect</a> at least passes the first mental plausibility test.</p>


<p>The movie obviously features as much fictional biology as it does technology. There I found some weirdness harder to ignore. One thing that caught my attention was that principles of evolution seemed kind of broken. Take a chunk of Earth and the larger lifeforms walking around (including any humans) will look pretty similar: you know, four limbs, fur, two eyes, mouth, etc. But on Pandora, no animals are seen with fur, they breathe through their stomach and have different numbers of limbs and eyes. The Na&#39;vi with their hair and human-like bodies seem out of place in that scheme.</p>


<p>Talking about the blue folk, it&#39;s interesting how their feline traits (large eyes, ears, tails) on the screen appear to unrealistically amplify your perception of emotion on their faces. I wonder why is that? Reading other people&#39;s feelings is basically an image recognition task and that&#39;s something brain is very well adapted for. I guess such a face combines the features from expressions you instinctively recognize from both animals (ears) and humans (facial gestures). Since these two things never appear on the same individual you can&#39;t experience their combined effect in real life. With a bit of additional exaggeration that&#39;s possible with CGI (for example <a href="http://en.wikipedia.org/wiki/Pupil#Psychological_effects">pupil dilation</a>) no wonder some scenes feel like emotion overload.</p>


<p>In the end I left the theater thinking that a realistic sequel to the story would be very short. In 10 years when the next ship from Earth arrives, somebody says <i>Nuke them from orbit. It&#39;s the only way to be sure.</i> But I guess that would be bad for ticket sales.</p>


</div>
</content>
</entry>

<entry>
<title type="html">VFD porn</title>
<author>
<name>Tomaž</name>
</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2010/01/vfd_porn/"/>
<id>http://www.tablix.org/~avian/blog/archives/2010/01/vfd_porn/</id>
<published>2010-01-18T18:33:39+01:00</published>
<updated>2010-01-18T18:39:10+01:00</updated>

<category term="Digital"/>

<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://www.tablix.org/~avian/blog/images2/2010/01/vacuum_fluorescent_display_from_adafruit_s_ice_tub.jpg"><img alt="Vacuum Fluorescent Display from Adafruit&#39;s Ice Tube Clock" src="http://www.tablix.org/~avian/blog/images2/2010/01/vacuum_fluorescent_display_from_adafruit_s_ice_tub-t.jpg" /></a>

<p>Vacuum Fluorescent Display tube from Adafruit&#39;s <a href="http://www.ladyada.net/make/icetube/">Ice Tube Clock</a>, which I&#39;m assembling right now.</p>


</div>
</content>
</entry>

</feed>
