Wifi survey
27.04.2008 21:46
A laptop on the back seat running a wireless LAN sniffer can yield some interesting results. Here's some statistics I gathered with Kismet while driving on the route Logatec - Ljubljana - Maribor - Graz:
Driving route
Percentage of networks using encryption
Channels used
Kismet has seen a total of 368 different networks.
One thing that I didn't expect to see is the channel distribution. Why are most networks on channel 11? Maybe it's a default setting for some popular equipment.
Also surprising were a couple of networks that are encrypted, but have names that include the owner's GSM number (like "041xxxxxx Call for service"). I haven't seen this before, but it seems like a nice gesture.
Unfortunately I didn't have a GPS attached to the computer, so I can't draw an exact distribution of networks on the map.
Mine's bigger
24.04.2008 19:49
Quote Python documentation:
latex2html: Probably the longest Perl script anyone ever attempted to maintain.
Hm...
avian@toybox:~/dev/html2latex-1.1$ wc -l html2latex HTML/Latex.pm 276 html2latex 1458 HTML/Latex.pm 1734 total
avian@toybox:~/dev/wikiprep$ wc -l *.pl *.pm 2466 wikiprep.pl 129 images.pm 359 languages.pm 80 nowiki.pm 76 revision.pm 183 templates.pm 3293 total
(cue manical laughter)
Another one from the Python dept
23.04.2008 19:32
Update: Please ignore this rant. I don't know what I've been doing wrong here, but my later measurements confirm Hruške's findings.
Python provides a convenient in operator that returns true if the left hand value is an element of the right hand list or dictionary. That's nice and all, but the performance makes it pretty useless in all but trivial cases. Take a look at this graph:
On the vertical axis is time needed for a loop to finish while test_size value is on the horizontal axis.
I ran these three loops that are exactly equivalent as far as the effect of the if statement is concerned:
"in list": the obvious way
list = range(test_size) for m in xrange(2 * test_size): if m in list: a += 1 else: b += 1
"in dict": converting to hash doesn't help
list = range(test_size) dict = dict.fromkeys(list, 1) for m in xrange(2 * test_size): if m in dict: a += 1 else: b += 1
"dict.get": the right way
list = range(test_size) dict = dict.fromkeys(list, 1) for m in xrange(2 * test_size): r = dict.get(m, None) if r: a += 1 else: b += 1
Foxmarks widget
20.04.2008 19:50
If you haven't noticed, this blog is now a bit more web-two-ohish. I've added a Foxmarks widget to the sidebar (the "Shared bookmarks" thing) that shows the last few bookmarks I made (well, those that I let you see).
Foxmarks is a Firefox plug-in and a service that allows you to synchronize Firefox bookmarks between different computers. I've been using it for some time on my desktop and laptop computers and have been very satisfied with it - it quietly lives in the background and does its thing without annoying you with any questions. I prefer it to services like delicious because it's integrated into the browser and because it allows you to use your own sync server instead of theirs if you're concerned about privacy.
They introduced the bookmark sharing service a couple of weeks ago and I thought I'll give it a try.
Python regex trap
17.04.2008 19:09
This simple Python one liner will not do what you expect:
>>> import re
>>> re.sub("the", "", "The Last Lecture", re.I)
Before someone again accuses me of being illiterate: Yes, this behavior is documented. It's still one of those things that go undetected for a long time and bite you in the most inappropriate time. It's right up there with C's "if(x=0) ..." on the annoyance scale.
Dealing with backscatter
15.04.2008 20:13
For a week or so I've been having terrible problems with backscatter (of the email kind, not Rayleigh). I'm receiving hundreds of mails per day to my personal email address from various misconfigured mail servers around the world, telling me that mails I have never sent didn't found their recipients. This has made my mailbox more or less useless until I implemented some filtering over the weekend (if you've sent me a mail - I'm just now going over my cleaned inbox).
It turned out filtering this kind of traffic is quite tough if you don't want to miss out genuine error reports. Not to mention that it really messed up my Bogofilter state. Since I didn't mark those error reports (which contained attached spam) as spam it learned from them and got the idea that I changed my mind and like getting Viagra offers after all.
I don't know what caused this flood of messages. It's suspicious that it started approximately at the time my mail server went down for a couple of hours 10 days ago. However I don't see how that could be related - I have a secondary mailserver in the DNS MX record, so no mail sent to addresses at tablix.org bounced or was lost.
It's also interesting what kind of garbage I got. Most common are of course the ordinary "Undelivered Mail Returned to Sender" and similar messages (usually because the mailbox is over quota). But after digging a through it I also found a surprising number of "Message you sent blocked by our bulk email filter". It looks like some companies actually reply to each and every spam message they get. Unbelievable.
Then there are more personal messages like "please forward all emails sent to this current email address to...", "thank you for contacting us about...", odd errors like "error writing message: File too large" and this gem:
Use of uninitialized value in numeric ge (>=) at /etc/smrsh/vacation.pl line 187. Use of uninitialized value in fcntl at /etc/smrsh/vacation.pl line 238. Use of uninitialized value in fcntl at /etc/smrsh/vacation.pl line 252. untie attempted while 1 inner references still exist at /etc/smrsh/vacation.pl line 202.
So anyway, if by any chance you're running your own mail server, you should make sure that you don't do stuff like that. Read at least the FAQ about backscatter and don't use silly scripts. The first sanity check is quite easy. Fire up a telnet client and try to send mail to a bogus address. You should be rejected right after the RCPT TO step, not later notified by mail:
$ telnet mail.tablix.org 25 Connected to mail.tablix.org. Escape character is '^]'. 220 chandra.tablix.org ESMTP MAIL FROM: someone@example.com 250 OK RCPT TO: foo@tablix.org 550 Unrouteable address
Measuring Eee, part 2
08.04.2008 22:21
Some time ago I attempted to measure the power consumption of my Eee PC with different settings for CPU clock and peripherals and confirm some findings on the Eee User forums.
On the second try I managed to get some results. First the measuring setup:
Eee is obviously very sensitive to voltage swings and I only got it more or less stable after I tried this with a second multimeter (with the first one Eee would not even boot). Soldering the biggest capacitor I could find in the workshop directly to the power connector and shortening the wires as much as possible also helped a bit. Even so turning on the camera repeatedly crashed the machine, so I couldn't measure its effect on the current.
Results (CPU clock as reported by cpufreq-stat):
All peripherals off, CPU idle:
- CPU clock at 113 MHz: 1.06A
- CPU clock at 900 MHz: 1.06A
All peripherals off, CPU busy:
- CPU clock at 113 MHz: 1.12A
- CPU clock at 900 MHz: 1.22A
Wireless LAN on, idle, CPU idle:
- CPU clock at 900 MHz: 1.17A
Card reader on, idle, CPU idle:
- CPU clock at 900 MHz: 1.14A
This confirms what other people have found out. CPU throttling is basically useless in Eee: There is less than 10% difference in current draw at full load and no difference in idle.
I also expected larger savings when you turn off the peripherals. Each thing you turn on but don't use costs you around 100mA, which is not that much. It would be interesting to also see how much difference you can make with backlight settings.
The computer was still crashing every few minutes so I think I satisfied my curiosity (and pushed my luck far enough) for now.
Mutual inductance problem
05.04.2008 17:02
A few days ago I was browsing through my notes from the first year of study and I stumbled upon this interesting problem I've never managed to solve. I've discussed this a couple of times with the late professor Valenčič and we couldn't find a flaw in my line of reasoning. So, if you know what's wrong, please drop me a mail.
In professor's book, there is an introduction to the principles of mutual inductance that goes like this:
Imagine two coils (designated 1 and 2) in some arbitrary relative position to each other. Current i1 that flows through coil 1 will cause a magnetic flux through coil 1 Φ11 = i1 ⋅ L1 (according to the definition of inductance). However some of the flux will also flow through coil 2, designated Φ21.
Mutual inductance between coils 1 and 2 is then by definition:
M21 = Φ21 / i1
Obviously, the magnetic flux Φ21 is less or equal to Φ11, so we define a coupling coefficient k ≤ 1 so that:
Φ21 = k ⋅ Φ11
Now due to principle of reciprocity, the same holds true if the current flows through coil 2 and we calculate the flux through coil 1. Coupling coefficient stays the same:
Φ12 = k ⋅ Φ22
Now multiply both mutual inductances:
M21 M12 = k2 Φ11 / i1 Φ22 / i2
Use definition of inductance:
M2 = k2 L1 L2
M = k sqrt(L1 L2)
Now this final formula is present in a lot of literature and it's certainly correct. It's also certainly true that from the principle of reciprocity M21 = M12. However this way of deriving the formula seems dubious - from steps above you can also see that:
M21 = k Φ11 / i1
M12 = k Φ22 / i2
And since M12 = M21:
M = k L1 = k L2
L1 = L2
Which would mean all pairs of inductances are equal, which is certainly false since we didn't impose any restriction on the geometry of the two coils.
If I would have to guess, I would say something is wrong with the first application of the reciprocity to the fluxes through the coils, however from what I know this should be correct.
So yeah, if you are fluent in electromagnetic theory, I would love to hear your opinion.
Star Trek technobable on the street
01.04.2008 18:33
Sadly, this is not an April fools' day joke. I've seen this sign today outside a store in Ljubljana:
Roughly translated into English, it advertises a tachyonic protection against EM field from cell phones. In common language that means they are selling ignorant customers a very expensive piece of ordinary glass that has protective properties approximately equivalent to an empty beer bottle.
In case you haven't watched enough Star Trek (where they are a very popular plot device) Tachyons are theoretical particles that move faster than the speed of light, have imaginary mass and for which pretty much every solid theory in physics today says they can't exist. So yeah, I'll skip the glass beads and wait until they'll sell me a portable warp coil.
