December 16, 2009

Norsk Tipping på Gentoo Linux

Etter at smartkortleseren til Buypass sluttet å fungere i Windows 7 betaen min, tenkte jeg at det var på tide å se om jeg fikk den til å fungere i OSet jeg bruker mest til daglig, Gentoo Linux.
Litt kjapp googling viste meg at dette i grunn ikke burde være spesielt vanskelig. Buypass har tilogmed en egen miniguide for dette.

  • Nødvendige pakker installeres enkelt med:
    sudo emerge -av pcsc-lite ccid

  • Legg til nsplugin som make-flagg for java. (evt legg det inn for hele systemet ved å legge det i /etc/make.conf). Installer deretter vanlig Sun Java:
    sudo emerge sun-jre-bin

  • Start smartkort-daemonen
    sudo /etc/init.d/pcscd start

  • Bruk en browser som støtter javapluginsen og gå til Norsk Tipping. (Jeg brukte chromium-bin, da jeg ikke umiddelbart fikk det til å fungere med Firefox og Opera)

  • Til slutt, sørg for at smartkort-daemonen starter etter neste kjerneoppgradering:
    sudo rc-update add pcscd default

    Husk nå å ikke spille bort alle pengene du har. :)
  • November 15, 2009

    Opera user javascripts: Remove redirection URLs

    A little known feature of the Opera web browser is the built-in support for adding personal Javascripts that are run on each page. The uses for this is left to the user, so here I will present a few small snippets that I currently use.

    Basics

    To enable user javascripts, open the Preferences dialog, go to the Advanced tab, then the Content page. Click the Javascript options and set the directory where you want to keep your files. All *.js files in this directory will be loaded on all pages.

    To avoid all javascripts being run on all pages, it is recommended to wrap all code in a test checking which server is currently in use. This is easily done using the location.hostname attribute.

    if(location.hostname == 'www.dagbladet.no') {
    function do_stuff() {
    alert("time to do stuff");
    }
    document.addEventListener ('load', do_stuff, false);
    };

    Dagbladet No-Go

    Dagbladet (and some other Norwegian news sites) employ a redirection service for keeping track of which links are being actively used by the readers. In essence this is rather harmless, but unfortunatly this redirection service seems to be less stable than the news sites themselves. The result being that every now and then all links on the page starts failing. The following little piece of code strips the redirection bit from the URLs, leaving just the base URLs.

    if(location.hostname == 'www.dagbladet.no'
    || location.hostname == 'www.kjendis.no'
    || location.hostname == 'www.se.no') {

    function no_go() {
    var anchors = document.getElementsByTagName("a");
    for (var i in anchors) {
    var a = anchors[i];
    if (a.href) {
    var b = a.href.replace(/.*go.dagbladet.no.*(http.*)/, "$1");
    a.href = b;
    }
    };
    };
    document.addEventListener ('load', no_go, false);
    }

    This can of course easily be modified for other pages using the same, such as vg.no.

    October 20, 2009

    Subversion helper functions in zsh

    Subversion has taken over the position as the boring version control system that just works. And even though several good alternatives have come up from the camp of distributed VCS's, I still prefer the good old central repository model. The drawback of having a central server is in my opinion subversion's strong side. Scattering multiple copies around just makes getting everything into a system and ready for production a whole lot more difficult.

    As an old Linux user, I'm also quite fond of using a proper shell to help my workday along. And for that I prefer zsh, mostly because of its strong completion system. Like most unix shells, zsh can be extended with custom functions, simple or complex. Below are three such functions that I use frequently. (They can probably easily be ported to bash or other shells as well, but the syntax used here is for zsh).

    Filtered status view

    If you're anything like me, you frequently pollute your repository with dump files, debug files and other junk while working. This will clutter the status check with a bunch of files that subversion does not recognize, and therefore displays with a '?' at the front, like this:

    .-(gobo@fraggle)-()--------------------------------------(~/Projects/hottipi)-.
    '-(18:51:%)-- svn status --(Tue,Oct20)-'
    ? pypi-classifiers.txt
    ? dump.pcap
    M src/httpchat.py

    If you just want to see what files have changed since last sync with the repository the following small function is helpful.

    svnstatus () {
    templist=`svn status $*`
    echo `echo $templist | grep '^?' | wc -l` unversioned files/directories
    echo $templist | grep -v '^?'
    }

    This will print a quick summary of unknown files, and then list files with modifications since last commit.

    .-(gobo@fraggle)-()--------------------------------------(~/Projects/hottipi)-.
    '-(18:51:%)-- svnstatus --(Tue,Oct20)-'
    2 unversioned files/directories
    M src/httpchat.py

    Show log when updating

    When running svn update a list of modified files is output but there is no mention of what exactly has changed in these files. The following little snippet will display the log before doing the update. Handy for seeing just what your coworkers have been up to lately.

    svnup () {
    svn log --stop-on-copy -r HEAD:BASE $1
    svn up $1
    }

    A little warning on this though. svn log can be slow if run on a huge set of files, or if there has been a very long time since the last update from the server repository.

    Colorful diff tool

    This little function relies on the code2color script often automatically installed in gentoo with the standard less package. If you're not using gentoo, you can get it here. It might need a bit of massaging.

    This little function will simply do what a normal svn diff will, but the output is fed through code2color, and the result is a screenful of pretty colors. If you want to, pipe it further to less as you would normally do.

    export C2C=/usr/bin/code2color
    svndiff () {
    svn diff $* | $C2C -l patch -
    }

    That's it. To use these functions, just add them to your $HOME/.zshrc file, and start a new instance of zsh. (or source $HOME/.zshrc if you like).

    September 7, 2009

    Irssi charset issues

    For future reference, mostly to myself, here's how to get irssi working properly with utf-8 terminals, on latin1 channels, through screen.

    1. Make sure your terminal is utf-8.

    Putty: In the Window->Translation page of the Session configuration, change "Received data assumed to be in which character set" to "UTF-8".

    urxvt: Seems to be Utf-8 by default when the locale is. Check "locale". It should look something like this:

    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    en_US.UTF-8

    2. Start screen in UTF-8 mode

    screen -U is your friend. It is possible to switch this live using C-a followed by :utf8 on.

    3. Irssi.

    • Never ever use irssi 0.8.12 (default in ubuntu for several revisions). If you use ubuntu older than 9.10, install irssi from source (or apropriate .deb if you can find one, I didn't).
    • Set the following options:
      /set term_charset utf-8
      /set recode_out_default_charset iso8859-1
      /set recode transliterate off
      /set recode fallback iso8859-1
      /set recode on
    • The above assumes all channels you use on the server has latin1. To only set latin1 recode for a single channel use /recode add #channel iso8859-1

    4. Joining a channel with latin1 characters in the name.

    This is the tricky bit, and I've yet to find a good solution for it. My best tip so far is to add it to the autojoin list before starting irssi. In ~/.irssi/config add/modify the channels setting:

    channels = (
    {
      name = "#blåbær";
      chatnet = "IRCNet";
      autojoin = "yes";
      },
    );

    Of course, you will need to edit the file with an editor that saves the file as a latin1 file.

    August 4, 2009

    The secret, revealed!

    Some claim that I look too young for my age. Which is nice. Really. I feel a lot younger than I am as well, so that fits. But why is that?

    I think I've figured it out. By old reckoning, one counted age in how many summers one has seen. And for my part, that would currently be 33 summers. Hmm, 34 soon actually. But 15 of those summers are here in Tromsø. And it is common knowledge that the summers here are short. I think it is fair to say that the summer here is about a third of a "proper summer".

    So, by that logic, I've now seen 19+15/3 = 24 summers. :)

    So if you want to stay young? Move to Tromsø.

    June 14, 2009

    Linux media PC woes: Media application

    At this point, I finally have a working X display on my TV. 1024x576 widescreen interlaced. Which flickers quite a bit on static desktop image, but isn't noticable when playing video or showing pictures.

    I have tested MythTV earlier, and found that I didn't really like it much. Don't know why not, just wasn't complete enough I think. So this time I did a new search for linux media PC and came across the linux port of XBMC - the XBox Media Center. Apparently this was already in Gentoo Portage, just had to unmask it.

    I had already tested this on the ATI adapter briefly, and new that it should work. So I was surprised to only see a segfault when trying it on the TV with the nVidia card. Rebuilding latest svn version didn't help either. Core dump on startup. Every time. I decided to attempt using the proprietary nvidia-drivers instead. Bingo! I had planned on testing those anyway to get vdpau support later, so this was okay for me.

    So I finally got the media PC up and running, and except for the occassional hangups of xbmc, which I credit to the fact that I'm running a very fresh svn copy, it's working fine. The overscan adjustment feature saved me all the trouble of adjusting the X modeline overscan to fit the TV as well.

    June 8, 2009

    Linux Media PC woes: VGA-SCART cable

    After deciding to attempt building a VGA out-Scart in cable, I set out to find the required components to build a prototype.

    Since I already had a bunch of cables stowed away, finding the required cabling was not a problem. A bit of cutting, and taping later, I had this:

    Not quite a monster cable, but quite monstrous still. The power input there is used to switch the TV to RGB and Widescreen. Note the nice 1kohm resistor there.

    The moment arrives to connect this monstrosity to the associated hardware. VGA and audio cable connected, I switch the TV on before connecting the molex power. Upon connecting the power, the TV immediatly switches to Video view, and goes into widescreen mode. At least that bit works.

    I can also spot the purple ascii-art gentoo logo of the login screen blurring past in the scrambled image of the text console. I take this as confirmation that the RGB-signals are properly connected, and continues to X configuration.

    Hours (days really) later I give up. I'm not able to get the TV to sync to the X signal, and I seriously have no clue as to why. I (wrongly) decide that this must be due to a lack of a composite sync signal and decides it is time to build this thing properly, with a small circuit to create a composite sync. That would also release the ATI requirement, and allow me to change graphics adapter.

    After a little shopping, I had the resistors required. Salvaged a generic transistor from an old C64 joystick autofire contraption. After a bit of soldering and I had the setup on the right. Didn't look too bad, so I decided to give it a try. Same result as my previous prototype. Blaming the transistor, and guessing I had connected it wrong, I desoldered it and tried another of the same type. Still just a flickering image.

    So I decided to order a few transistors. Searching on Elfa.se I found a transistor with basically the same specs as the one in the circuit description I was following. Next time I'm ordering electronics, I will learn to check the size of the components. Surface mount transistors are tiny. Still, I didn't want to give up, and a bit of more soldering, I managed to connect it. Decided to redo the sync circuit at this point as well to clean up the mess from the previous attempts. Reconnect, retry. Same result.

    Revelation

    At this point I was pretty sure things should be correct, so I finally decided to look for other causes of the problem. After a few hours battling with X Modelines and the ATI driver, it finally dawned on me that the driver was simply ignoring my requests for a video clock that was slow enough to provide a PAL TV sync. The Modelines provided by the marvellous little app called lrmc should have worked, but didn't.

    Well, out with the ATI adapter, and in with an old nVidia adapter. Compiled the nv driver, and voila. Image on the screen!

    For reference, the working modeline for a widescreen PAL TV is:

    Modeline "1024x576x25.00i" 19.750000 1024 1056 1152 1264 576 586 592 625 -HSync -VSync interlace

    Next up, the media PC application.

    Linux media PC woes

    This is going to be short series of articles describing my struggles to get a Linux Media PC connected to an old Widescreen CRT TV set. I started writing this a while ago, but never got around to publish it.

    The setup

    I can't afford buying lots of new stuff just to get a simple home theater set, which is why I'm building this out of the parts I've already got. 

    Computer: My old file server. It already has the media files and storage. The only thing needed is a graphics adapter and the right software. It is running Gentoo Linux as it has been doing for ages now, and I have no intention of changing this. Specs are Athlon 64, 2GB RAM. To use it for media PC purposes I plug in my retired ATI x1950 Pro card that was retired from my main computer in order to get an adapter capable of playing GTA IV.

    Display: An old Philips 32" 50Hz Widescreen CRT TV. This is the only display on this computer, as I haven't needed a display on it until now. Available inputs on the TV are two SCART ports at the rear, and an S-Video port on the side.

    Configuration

    ATI and Linux is in itself a perpetual nightmare. The X.org drivers are generally late and without support for features beyond the immediate needs for a simple desktop, and the native binary drivers are prone to errors as well. After updating and rebuilding quite a bit of the system however, I was still not able to run the native drivers with the new X.org server. The X server simply core dumps while probing drivers. The open drivers however seems mature enough for the old X1950 now, so I decided to try my luck with those.

    First attempt, TV-Out

    The logical thig to do when connecting a computer to a TV is to use the TV-Out on the graphics adapter. Turns out of course that this is not quite supported yet on the X1950 with the radeon drivers. I seemed to almost get an output using an S-Video cable that I think came with the graphics adapter, but not quite. That is, I get an output on the TV when booting the machine and still have it until the X drivers kick in. After that, all black.

    Second attempt, VGA to SCART

    Since this computer only connects to the TV, I figured that it should be possible to connect VGA directly to the SCART input on the TV. After all, VGA provides RGB output, and SCART supports said input. Googling around a bit reveals a few different solutions for this. I decided to go for the simplest approach, since I was using an ATI adapter which should support a composite sync signal.

    More about that later.

    March 30, 2009

    London: Monday wandering

    On monday I went out on my own again, since Alison had to work. I first set course for the Forbidden Planet again. This time they were open. Browsed through the store but found nothing that I wanted, so I left without getting anything. More money not spent.

    Since the weather was lovely though, I decided to go to Hyde Park and just relax a little, and finally write some post cards. Really wished I had my roller blades with me there. The road through the middle of the park seemed wonderful for blading, and there were quite a few people doing so there. But this being London, the weather clouded over again, and sitting in the park soon became too cold. So I left by the Marble Arch gate in the north east of the park and went looking for a pint.

    After having a pint at Tudor Rose I started wandering back to Leicester square to meet with Alison. This took some time, since I really like just wandering through the various small back alley streets just looking around. Finally ended up at the Bear and Staff just by Leicester square to wait for Alison. We stayed there for dinner as well, before taking an evening walk along the south bank of the river, stopping for another pint here and there.

    March 29, 2009

    London: Sunday boating

    Since I booked my Qantas flights to Brisbane back in 2006 through British Airways, they keep sending me spamemails with offers and stuff to do at various destinations. Because of this I was aware that this sunday was the date of the annual Cambridge vs. Oxford boat race. Known simply as The Boat Race. Alison needed to do some work, so I set out on my own down to Hammersmith.

    Arriving at Hammersmith station I realized I wasn't quite prepared for the amount of people that show up for this event. I think this is the only time I've ever seen people queue up for a zebra crossing. According to the TV coverage, a quarter of a million people were gathered along the banks for the race. So even though I arrived a good hour before the event, it was clear that I was at least an hour late already. I caught a bit of the warm-up race 45 minutes before the main event, and then went to see if I could find a better spot. I didn't so I ended up in Furnival Gardens where there was a big screen set up. And lots of people. So I watched the main race from there.

    After the race I decided to go to Kensington to visit the Science Museum. Arriving half an hour before closing time, so I didn't really have the time to visit any of the most interesting exhibitions, such as the new Cracking Ideas exhibit and the IMAX theatre. The pictures show a large circle in the center that I think was supposed to simulate the Large Hadron Collider and occasionally merged the particles into texts.

    From the Science Museum I went to look for the Forbidden Planet Megastore. Finally found it after walking along most of the Shaftesbury Avenu - should have taken the tube stop further - and realized it had closed 15 minutes before. So I went looking for a pub and a pint, before going back to Alison's place.

    March 28, 2009

    London: Saturday at Leyton

    You can't go to England and not catch a football match. Since my trip was during a Fifa break there were no matches in the Premier League or Championship. Which was just as well, since they'd probably be too expensive for me anyway. So instead I searched through the fixtures to find a match in League One. Turned out there was a match just a few stops further out on the tube, at Leyton, where Leyton Orient was receiving Oldham Athletics.

    I used buses to Leyton since it is in zone 3 on the tube, and my Oyster card was only charged for travel within zone 2. A short trip and a failed bus later, I was at Leyton station, and walking to the arena at Brisbane Road. I had checked the stands the night before, and decided to get tickets on the south stand. This turned out to be a good choice, since it seemed the most entusiastic home supporters also uses this stand. According to the website, the northern part of the east stand should have housed the home supporters, but there were not much sound coming from that end.

    The southern end of the east stand however had lots of Oldham supporters cramped together. And it was clearly the away supporters were the more enthusiastic side this day. Particularly when Oldham took the lead after 34 minutes. 0-1 at half time, and the weather was cold and rainy. In the second half the O's came back though. A penalty equalizer in the 60. minute got the crowd warming a bit, and when Demetriou put the 2-1 goal with 6 minutes left all was good.

    After the match I went for the public transports again, trying to find my way to Kilburn where I was to meet up with Alison and some of her friends. Because the tube station was packed and a bus was going back to Stratford already, I decided to catch that bus. Do note that not all buses labelled "Stratford" and similar actually go by the bus terminal by the same name. Second failed bus catch of the day. This didn't delay me that much though, and after getting back on the tube, I was in Kilburn 45 minutes before rendesvouz time. 45 minutes well spent with a pint.

    After having a quite nice curry, we went to The good ship to see the Grave Architects. The venue was kinda weird, with the band playing in a sunken pit in the middle, where you basically had to stand in the stairs around to see anything. Not all that unlike another place I know after all. The bands playing here were a lot better than the ones at Hoxton a few days earlier and The Grave Architects in particular was actually quite good.

    March 27, 2009

    London: Shopping Friday

    Even though I was on a budget, I realized that I had to go back to Camden Town again. When we were there on wednesday quite a few stalls were closing already. First though we went out for a late breakfast. Alison knew a place down in Bethnal Green called "Pellicci". Wonderful place with an atmosphere that put a smile on my face for the rest of the day.

    From Bethnal Green we went down to Leicester Sq to get tickets for the evening's performance of Les Miserables. Got some rather cheap tickets out on the side of the upper gallery. Since we were using a double decker to get around this time, I got to snap a few pics in traffic as well.

    Back in Camden I ended up with only a few t-shirts and a new trolley-backpack-bag to stuff things in for the return trip. Though this was mostly through strict "don't buy stuff you don't really need" attitude on my part.

    In the evening we went back downtown for Les Miserables. As you can see from the pic on the left, the theater is a lot higher than deep, so we ended up watching from above. But the play is still good. And the theater completely full, but mostly tourists though.

    March 26, 2009

    London: Thursday War

    Thursday we decided to follow Kjella's advice and went to the Imperial War Museum. Some interesting stuff to see there, in particular old WW1 and WW2 fighter planes. The exhibition on The Secret War, with spies and stuff was quite interesting as well. From there we moved on to the holocaust exhibition which was generally so depressing we decided to leave after that. Thus skipping the exhibition on crimes against humanity. I'm still quite amazed at what human beings are capable of doing to one another.

    In the evening it was time for the first gig of the trip, a 4-band setup at Hoxton Bar & Kitchen. I rather liked the venue, with a rather large stage room in the back and two bars up front. The bands were mostly disappointing though, so we ended up listening to a couple of tunes from each before going out to the main bar to wait for the next band to come on.

    PS: As you can see, pictures are now up. Click an image to go to the Picasa web album for more.

    March 25, 2009

    London: Wandering Wednesday

    Wednesday started with Alison's power supply failing. So it was decided to start the day with a trip downtown to get a new one. This suited me fine since I wanted to look for a high power battery for my Aspire One as well. The original battery doesn't seem to last even 2 hours with Ubuntu.

    After charging up the Oyster card Alison lent me, we set course for Shopping Hell (or Heaven depending on your point of view): Oxford Street. Luckily we weren't shopping on the main street, but a bit up Tottenham Court Road instead. There are quite a few electronics shops up there of various sizes. I forgot to actually look for an Acer battery, but at least we got a decent PSU for Alison's laptop.

    From TCRd we went to a small rather hidden pub for an english lunch, Pie and Ale. Wonderful little pub with wonderfully low prices. £8 for a large meal and a pint is rather good. 

    After letting the food sink in properly we decided to go to the hill in Regents Park for a good view across London. Which it surely was. From there we took the wrong exit from the park and ended up strolling in a circle through a posh area, before we got back to the canal. We walked along the canal through the London Zoo and up to Camden Town.

    Camden Town turned out to be more my kind of shopping heaven. Lots and lots of tiny stalls selling all manners of weird stuff. Gothwear, vintage stuff, anime wear, etc. As well as the seriously spaced out Cyberdog store. I could easily burn a lot of money up there.

    March 24, 2009

    London Trip: Leaving home

    As some are aware of, I'm currently on a weeks holiday in London. Yeayh! Going to London on a budget (means no major shopping) and without any real plan on what to do. Here's a slightly delayed travel report.

    PS: The SD reader on my laptop isn't working after a recent Ubuntu update, so no pictures until I get home.

    Leaving Tromsø

    I left Tromsø on tuesday afternoon. Norwegian's flight directly to Stansted is rather practical. And cheap. I realised a few days before leaving that I would only have half an hour between landing at Stansted and catching the bus to London that would stop at Bow. If I missed it, I would have to wait another 110 minutes for the next bus. So I decided to travel only with hand luggage. It is fully possible to pack all you need on a trip in a single backpack small enough for carry-on. It did not however leave much room for buying anything in London. So my plan was to buy a bag in London for the return.

    Already while waiting for the bus to Langnes I found out that the flight was delayed, so I would miss the Stansted bus anyhow, but it was too late to run back in and repack at that point.

    The flight to Stansted was as eventful as flights can be. Which means nothing at all. Read a good portion of "Snow White and the seven samurai" by Tom Holt. Quite good light reading, but a bit jumpy storyline. Mind you, still only half done with it. Landed at Stansted the same 40 minutes late that we left Tromsø. Which was just as well, since I had forgotten how much hassle immigration can be. Turned out however that it was really smooth, but then I wasn't stressing either.

    Had a burger at the airport Burger King. Apparently whoppers here are called "Angus" since they got scottish meat. :) Then 20 minutes before the bus was to leave, I went down to the bus station. Bad idea. Should have gone down there earlier, as the Terravision buses are apparently very popular. Might be something about a £9 price... The queue was already quite long. Result: I was one of the last 5-6 people to get on that bus. Phew! And the only one who needed the bus to stop at Bromley-by-Bow.

    I'm staying at my friend Alison's place, and she met me at the bus stop with a helpful umbrella to hide from the inevitable London rain. The flat was just a few minute walk from the bus stop anyway, but a little shelter from the rain is helpful. Some plans were laid over a cup of tea as to what to do the next days, before it was time for sleep.

    March 1, 2009

    Blogging is dead

    I've finally started a blog. That should officially end the age of blogging.

    I'm going to use this blog for commenting about the things happening on my end of the planet. This might and might not interest the rest of the planet, but that's beside the point. Topics will include software projects I'm working on, tips for tools I'm using, football related stuff, gaming and generic stuff. I don't expect to have a steady schedule for posting though, so if you for some reason plans to follow my rants, you better just subscribe it in your favourite feed reader.

    Also note that the blog will probably be bilingual. Most of the stuff regarding computers and games will be in english, but football and generic stuff about Tromsø will probably be written in norwegian.