Archive for the ‘tech’ Category.

Firefox 3.5 and DNS Prefetches

Perhaps not a very new feature, but Firefox 3.5 prefetches de DNS results of all links on a page.

What does this mean? That firefox does a lot of DNS requests in cleartext(no encryption)  for all links in a website, even if the page itself is encrypted, on a local network or is a local file. When viewing secure pages it then leaks information on what page you are looking at (e.a. if you do a lot of .indymedia.org dns requests, you’re probably looking at the indymedia.nl frontpage), same for pages on an intranet.

For people using webmail, this also means someone(for instance a spammer) can implement a callback/phonehome method by putting a domainname in the mail and whith a 0 cache value.

I’d consider this a bad policy, luckily you can turn it off, but not too easy.
A short howto:

go to the page “about:config”, it might give you a warning about voiding your waranty, I don’t think you have any anyway, so go ahead.

  1. Rightclick on something white in the page and select new->boolean
  2. Name the boolean: network.dns.disablePrefetch
  3. Set the value to True
  4. Rightclick again on something white and select again new->boolean
  5. Name the boolean: network.dns.disablePrefetchFromHTTPS
  6. set the value to True

If you now type network.dns in the filter you should see 2 entries in bold with the names you’ve given them (network.dns.disablePrefetch and network.dns.disablePrefetchFromHTTPS) of the type ‘boolean’ with the values set to ‘true’. Your firefox should now no longer try to fetch lots dns results and it’ll improve your privacy a little bit.

For those running apache webservers, you can control it from the server-side by doing the following:

  1. Enable mod_headers (a2enmod headers)
  2. Add this line to your apache or virtual host configuration: Header add x-dns-prefetch-control “off”
  3. Restart your webserver

For those only having control over the HTML you can add the following to your <head></head> section:

<meta http-equiv="x-dns-prefetch-control" content="off">

Wii Presenter

Just created a small page for packages I build: Packages
Main reason for this is the making and publishing of my wiipresenter packages, Wiipresenter is nice tool for doing presentations with the WiiMote, it’s not finished yet, but works quite well already. Sadly though, the original makers don’t do much about them, but Dag Wiers made some patches to get them to work on recent systems, and packaged them in RPM. Since I don’t use any RPM based systems I build some debian packages for it.
So Wiipresent runs in a terminal still, but intelligently guesses the application in current focus to adapt it’s functionality to it. In openoffice presenter you navigate through the slides, in firefox you can switch your tabs and scroll through the pages. When pressing A+B in any application it toggles the mouse control with the motion sensor. It can also resize text, switch between applications(like alt-tab) and much more.

Great application, and now also as a debian package, i386 and amd64.

Visiting the Cabfablab

Yesterday (27-08-2009), we visited the Cabfablab fablab in The Hague with a small group.

A bit difficult to find it seemed, but we managed to get to the old Cabalero factory and then finally the ‘office’ of the Cabfablab. Two spaces, numbers 73 and 74. One for ‘noisy’ equipment and one for more ‘quiet’ work.

Overall it’s a nice clean place, quite light. They’ve got about the usual on machinery:

  • Laser cutter for cutting wood & plastics or ‘writing’ on metal’
  • Vinyl cutting plotter
  • Heat transfer vinyl and the like on fabrics (e.a. for t-shirts)
  • Small 3D miller
  • 3D-Printer
  • A medium sized CNC machine
  • A wiki
  • A diversity of small tools

They’re with a small group of volunteers, and their aim is mainly to facilitate students, self-employed and artists. Unlike other fablabs the Cabfbalab does not ave free days.

Usage of their equipment comes down to 25 euros per hour + materials. For the 3D-printer you just have to pay for the raw material. There are some exceptions, but see their website for that.

They do try to keep the open spirit quite alive, besides having most tings running on closed source software, it’s kind of a problem with having software that controls the machines.

I think it’s a nice workspace, good atmosphere just  too bad they don’t have free days. Certainly worth a visit.

Link: http://www.cabfablab.nl/

Pictures:

Hacking At Random 2009, post scriptum.

Back from HAR2009 last night, and obviously I loved it.

HAR2009 was quite wonderful, I usually run arround helping out where I can, but this year decided to take it easy and be a ‘visitor’. I can only say it was only slightly more relaxed. I still volunteered a little and still hopped from A to B to C to D. I managed to actually build something though, an Arduino based MIDI-controller, simple but for some odd reason anoying to get it to actually work. Also got to meet and talk to a lot of familiar and unfamiliar people and had overal quite a lot of fun.

I’ve got mixed feelings about the 4 yearly event this time named HAR. It’s big and that creates a paradoxal feeling for me.

I love how it brings people together, and with that how I get to see lots of people again. I also love the atmosphere these events bring, I’m almost always sorry that it’s over. Something about such a lot of cool/like-minded/fun people in one small space. IT’s like the ‘perfect’ town/village.

There is a downside on it though. Or some actually, and it all comes down to size. It’s only a short event and I never get see and talk to everyone there, and for me that ends up usually in lots of short contacts with lots of people. Not ideal, you never get to be really talking to anyone. And if you do, you miss out on quite a lot.

Big events are also expensive like hell, both in time and money. It’s I think always worth it, but because of it, you end up with a high entrance price which font fit everyone’s budget and raising the threshold for joining.

I think events like WTH, CCC-Camp, HAR, etc have a good place, I also think it’s good that they’re not every year. That way there is space for smaller events, sometimes more specialised, ususally a lot easier to join.

Events like ETH0, EasterHegg, ICMP, Opencommunity Camp, Hackmeetings, Megabit, and many more.  They often only have a few hunderd people max, but contact is closer, it’s easier to have a longer event, more intimate and higher impact. And mainly you can have more of them, making the overall experience even longer and diverser (although many people still have the problem with having to work and all that crap ;).

So I’d love to see more people organise more smaller events, and I love for people to work on CCC Camp in 2 years and build another Dutch event in 4 years. Maybe with even more people.

So see you in 4 years, 2 years or maybe in 2 months.

And also Special Thanks to:

  • Organisation & active volunters: You’ve done a load, and by far the most work in getting this event pulled off.
  • HARdware village for providing a great place for hacking on hardware and providing kits.
  • Geraffel village for helping out with my midi project by providing tips, connectors and a synth for testing
  • Arduino village for providing the arduino and help debugging.
  • C-Base for a nice place with nice people and nice food :)
  • Everyone for making this again another wonderful event.

New Perl module

Released a small new perl module, it isn’t extremely unique. But it does do what I want in what I think is the best way. And hopefully also accoording to others.

It’s called Hash::Mogrify and provides a couple of nicely formatted and overloaded functions.

  • kmap provides a map like function for keys
  • vmap a map like functions for values
  • hmap does it for both keys and funtions
  • ktrans is like kmap but works through a translation hash instead of a code block.

I’ve already released a 0.02 version with some added features that where requested. If you have some cool sugestions for what it should do, let me know and I might implement them.

Ofcourse you can find it on CPAN

New Hackerspace

Today I visited the new hackerspace in Amsterdam on the ceintuubaan. Looks cool and has a nice location.

Front the Ceintuurbaan 215

Front the Ceintuurbaan 215

More images and text on: hackerspace.nl

And more info on the SLUG Website

Playing arround with X11::Aosd

So in my desire to map some ACPI buttons on my thinkpad, I noticed this ‘battery’ button (Fn+F2). I thought it would be nice if I get this nice graph showing me my battery state.

Sadly osd_cat only does bars and text, and I wanted a nice pie or something. So I looked around for perl modules which could do more. In comes X11::Aosd.

X11::Aosd is a Cairo powered OSD interface which works quite nicely. As it’s an XS module it works fast and efficient, but as usual lacks in -proper- usage documenation.

The script I ended up writing (which called by another script that actually read the battery info) became as followed:

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use X11::Aosd ':all';

my $per   = 100;
my $mx    = 200;
my $my    = 200;
my $text;

my $res = GetOptions("percentage=i" => \$per,
                     "xoffset=i"    => \$mx,
                     "yoffset=i"    => \$my,
                     "text=s"       => \$text,
);

my $pi = 3.14159265358979;
my $rad = ((2*$pi) / 100) * $per;

my $aosd = X11::Aosd->new;

$aosd->set_transparency(TRANSPARENCY_COMPOSITE);

$aosd->set_position_with_offset(
    COORDINATE_CENTER,
    COORDINATE_CENTER,
    200, 200, 0, 0
);
$aosd->set_renderer(sub {
    my ($cr) = @_;
    $cr->set_source_rgba (1, 0.6, 0, 1) if($per < 30);
    $cr->set_source_rgba (1, 0, 0, 1)   if($per < 10);
    $cr->set_source_rgba (0, 1, 0, 1)   if($per >= 30);

    $cr->set_line_width(10);
    $cr->set_line_cap('round');
    $cr->arc(100, 75, 70, 0, $rad);

    $cr->line_to(100,75);
    $cr->line_to(170,75) if($per < 100);
    $cr->stroke;
    $cr->fill;

    if($text) {
        $cr->move_to(0, 175);
        $cr->select_font_face("Sans", 'normal', 'bold');
        $cr->set_font_size (23);
        $cr->show_text($text);
        $cr->fill;
    }
});

$aosd->show;
$aosd->loop_once;

It’s a simple piece but it works. I kinda like X11:Aosd even though it’s less then perfect docs, toghether with the original cairo docs you get a nice idea. Maybe more examples later.

btw, Thinkpad F<n> acpi buttons(Fn+Function) are quite simple in their acpi mapping: 00000080 00001003 is F3, 00000080 00001002 is F2, etc

Another Thinkpad script, volume.

I was missing my volume buttons on my thinkpad, I’m sure the default flavours of (XU|KU|U)buntu handle this nicely (can’t say I checked though ;). But since I run ion3 I get none of that fluffyness.

There are ofcourse already some onelines and scripts outthere that fix this problem, and I certainly copied from them what was useful, but I wanted my OSD feedback. So I wrote the following script, not fancy but it works.
It depends on the following packages:

  • perl
  • alsa-utils
  • xosd-bin

/usr/local/bin/ibmvolume.pl

#!/usr/bin/perl -w
use strict;
## Script made for Lenovo Thinkpad X61s
## for different cards you might need a different numid.

my $nvol  = '28';
my $nmute = '29';

my $volinfo  = `amixer cget numid=28`;
my $muteinfo = `amixer cget numid=29`;

my ($min, $max, $cur) =
    $volinfo =~ /.*min=(.+?),.*max=(.+?),.*values=([0-9]+).*/si;
my $per = int($cur / ($max / 100));

my ($mute)  = $muteinfo =~ /.*values=([a-z]+).*/si;
my $invmute = ($mute eq 'on') ? 'off' : 'on';

if($#ARGV < 0) {
    print "Min: $min, Max: $max, Cur: $cur($per%), Mute: $mute($invmute)\n";
    print "Usage: $0 (up|down|mute|show)\n";
    exit 1;
}

my $command = shift;

my %controls = (
    up   => "amixer -q cset numid=$nvol ".($cur+1),
    down => "amixer -q cset numid=$nvol ".($cur-1),
    mute => "amixer -q cset numid=$nmute $invmute",
);

system($controls{$command}) if $controls{$command};

my $cmute = ($command eq 'mute') ? $invmute : $mute;

my $font = '*-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1';

system("osd_cat -b percentage -f $font  -c green -A center -o 600 -d 1 -T 'Volume($cmute):' -P $per &");

Sadly the osd_cat tool can wait no shorter than 1 second, I would’ve liked something more like 0.5 second.

This now works from the commandline, taking commands like ‘up’, ‘down’, ‘mute’ and ’show’. Now one can use something like ‘xbindkeys’ to link it to key events like ‘XF86AudioRaiseVolume’ and ‘XF86AudioLowerVolume’.

But I just put the following code in my (lua) config for ion3:

~/.ion3/cfg_bindings.lua

defbindings("WMPlex.toplevel", {
    kpress("XF86AudioRaiseVolume", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl up')"),
    kpress("XF86AudioLowerVolume", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl down')"),
    kpress("XF86AudioMute", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl mute')"),
})

And don’t forget to reload ion3 afterwards :)

Simple but useful ACPI + Thinkpad script

I always got anoyed when X crashed, or hanged and I couldn’t do anything anymore, while I knew the rest of the system was still functional and I should be able to get my screen session back.

The ‘easy’ way for this would be to SSH into your workstation, but I like to keep sshd turned off on those machines. preferably no external services on workstations at all actually.

Now I have a Thinkpad, and Thinkpads have this ugly Thinkpad/Thinkvantage button, especially ugly in it’s inner workings, and because of that it’s useful here.

The Thinkvantage button is not a keyboard event (which at this point is controlled by a broken Xorg) but it’s polled by the ACPI daemon, which runs as root. So when you press the button, an ACPI event is generated, which can have scripts linked to them.

A quick fix would be to put ‘chvt 2′ in the /etc/acpi/thinkpad-thinkpad.sh script on debian. But I wanted a little more and  changed it to the following:

/etc/acpi/thinkpad-thinkpad.sh

#!/bin/sh
CURVT=`/bin/fgconsole`
NEXTVT=`expr $CURVT + 1`

if [ $NEXTVT -gt 8 ]; then
    NEXTVT=1
    echo "looped back to: $NEXTVT" >> /tmp/nextvt.log;
fi

echo "Current VT: $CURVT, Next VT: $NEXTVT" >> /tmp/nextvt.log
if [ "X$NEXTVT" eq "X" ]; then
    /bin/chvt 2;
else
    /bin/chvt $NEXTVT;
fi

So this actually loops through terminal 1 t/m 8, without needing the keyboard-driver.

(don’t forget to reload acpid after chaning any of the scripts).

Dutch Perl Workshop 2009

Sadly the Dutch Perl Workshop or Nederlandse Perl Workshop is over. :(

Even though I was very tired to begin it all with the event was a lot of fun.

The workshop itself was just on friday, but on thursday evening we worked until 01:00 to get the network working. At the event location, Hotspot wireless was provided by the ‘StayOkay’, but this only allowed traffic over port 80 and 443, and was just crappy. So we connected a spare laptop to cisco switch + accespoints we could borrow and let that route all traffic over a OpenVPN link to a freshly setup Virtual Server. Worked like a charm.

On friday the day started early with the first talk at 9.15 (10 minutes late, as was planned :). With a few breaks for coffee/tea and lunch in the afternoon, we had one full track of talks ranging from 5 to 20 minutes. Topics where diverse aswell, from in-depth perl hacks to generic coding strategies and application showcases. A lot of fun, but quite intense.

At the end of the day we had an auction for the Perl Promotion foundation, which organises the event and a fun quiz featuring obscure Perl issues.

Dinner was included and tasty, and the rest of the evening was filled with discussions, playing fluxx and drinking whiskey or beer.

I’d say I can’t wait until next year, but since I’m quite exhausted from this one, I can now :)
I took some pictures with my Practica MTL3, as soon as the film is developed, I’ll post some here.