Monday, 9 March 2009

Detecting endianness when making a FreeBSD port makefile

The title really says it all, my porting foo and Google foo was insufficent when I was working on a port for the IMS Corpus Workbench this weekend. I had to turn to the good people at #bsdports@EFnet and to aid me was @stass. He supplied me with what I at time suspected to be the only way, to use a regexp to extract the information from endian.h (yuck!). Here are the two options he provided.

LITTLE_ENDIAN!= ${EGREP} \
'^#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$' \
/usr/include/machine/endian.h | ${AWK} '{if ($3 == \
"_LITTLE_ENDIAN") print 1;}'

LITTLE_ENDIAN!= ${AWK} \
'/^#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$/
{if ($3 == "_LITTLE_ENDIAN") print 1;}' \
/usr/include/machine/endian.h

These work just fine for an ordinary shell but the same thing in a makefile needs some small adjustments. I prefered the purely AWK one, so here it is.

LITTLE_ENDIAN= ${AWK} \
'/^\#define[[:space:]]+_BYTE_ORDER[[:space:]]+[^[:space:]]+$$/ ' + \
'{if ($$3 == "_LITTLE_ENDIAN") print 1;}' /usr/include/machine/endian.h

Now hopefully the Google Bot will crawl over this and allow the next porter to find what I could not. Once again, thank you @stass. =)

Monday, 5 January 2009

Njorak isn't dead (yet (now lives on a lone E6400))

Yes, I admit it! I am still a Dvorak typer. I tried going back recently when learning Vim using my new Vim book, but I just can't. Something about Qwerty makes me squirm when trying it. Perhaps it's just that I have become accustomed to the strangeness of Dvorak but in general I don't see any reason to switch back. Sure, I am not that quick when I get in front of someone's Qwerty laptop, but I'll manage.

Now with my new Dell E6400 it's time for yet another njorak layout. Since Swedish characters are too precious to miss out on, but not precious enough to get rid of all the good things about pure and clean Dvorak (hmm, I does sound like a fanatic don't I?). Here it is, the all magical njorak for Dell Latitude E6400 using the Windows key to access Swedish characters.

! njorak, not-quite-dvorak. Version 1.2
! By Pontus Stenetorp
! Derived from us dvorak, accesses Swedish characters through
! altgr or similar combos. Also swaps caps and esc.
! Apply it to an ordinary dvorak keymap using xmodmap.
! Dell Latitude E6400 version
! still dedicated to spatrik

! Set up Swedish special characters
keycode 43 = d D aring
keycode 44 = h H adiaeresis
keycode 45 = t T odiaeresis

! Windows key on a Dell Latitude E6400
keycode 115 = Mode_switch

! Swap escape and caps lock
remove Lock = Caps_Lock
remove Control = Escape
keycode 66 = Escape
keycode 9 = Caps_Lock
add Lock = Caps_Lock
add Control = Escape


I have also added a Caps-lock Escape switch to this version. The reason, there is never a good reason not to remove caps-lock. The only I reason I can come up with is that it's not expected behaviour for anyone who is new to your layout. But being a Vim user (and a Dvorak user, which makes most people perplexed when trying out my keyboard) and also having taken a couple of seconds to ponder on which key I use the most, the switch really is a sane thing to do.

Sunday, 4 January 2009

Portssearch alias and portmaster

In order to manage FreeBSD ports I have used portupgrade for some time. It provides neat facilites such as the command portinstall and portupgrade, I am sure that the use of these commands is pretty straight forward. The standard way to install a port is the following.

> cd /usr/ports/category/portname
> make install clean


Instead portupgrade allows you to do.

> portinstall portname

Or

> portinstall category/portname

One problem with portupgrade is that it's written in Ruby. One might argue that this is not really a problem, but when you have a fresh FreeBSD install you don't want to drag in Ruby as your first package. This takes time and you would rather focus on something else.

Luckily there is an alternative that I quite recently stumbled upon. portmaster supports pretty much the same set of operations but is written in shell script. It's quick to install and you are ready to go in a jiffy. It also handles fetching and port configuration first and then starts building and installing.

> portmaster category/portname

The only problem is that it enforces the use of category/portname as arguments. This is most likely to avoid conflicts since the portname might conflict with other portnames. To resolve this portupgrade presents all "likely" matches and asks you to choose from them, portmaster just dismisses your arguments as invalid. I have considered adding this functionality in some way. Perhaps printing "likely" matches and/or conflicts and then terminating would be a good option?

So, now we have a tool to handle port installation with ease. Then we need a way to search for ports when we don't know the actual name or category. There are of course several such tools but out of the box ports supplies the following way.

> cd /usr/ports
> make search name=searchstring


Or if you want to search in dependencies etc. you can always use key instead of name. But this usually give you far too many hits to browse through. But the output even from name is usually a bit too much, listing dependencies, web addresses and maintainers. For example.

> cd /usr/ports
> make search name=hugs98
Port: hugs98-200609_2
Path: /usr/ports/lang/hugs
Info: An interpreter for the functional programming language Haskell 98
Maint: haskell@FreeBSD.org
B-deps: bash-3.2.39_1 bison-2.3_4,1 damageproto-1.1.0_2 fixesproto-4.0 gettext-0.17_1 gmake-3.81_3 inputproto-1.4.2.1 kbproto-1.0.3 libGL-7.0.3 libGLU-7.0.3 libICE-1.0.4_1,1 libSM-1.0.3_1,1 libX11-1.1.3_1,1 libXau-1.0.3_2 libXdamage-1.1.1 libXdmcp-1.0.2_1 libXext-1.0.3,1 libXfixes-4.0.3_1 libXi-1.1.3,1 libXmu-1.0.3,1 libXt-1.0.5_1 libXxf86vm-1.0.1 libdrm-2.3.1 libglut-7.0.3 libiconv-1.11_1 m4-1.4.11,1 pkg-config-0.23_1 xextproto-7.0.2 xf86vidmodeproto-2.2.2 xproto-7.0.10_1
R-deps: damageproto-1.1.0_2 fixesproto-4.0 inputproto-1.4.2.1 kbproto-1.0.3 libGL-7.0.3 libGLU-7.0.3 libICE-1.0.4_1,1 libSM-1.0.3_1,1 libX11-1.1.3_1,1 libXau-1.0.3_2 libXdamage-1.1.1 libXdmcp-1.0.2_1 libXext-1.0.3,1 libXfixes-4.0.3_1 libXi-1.1.3,1 libXmu-1.0.3,1 libXt-1.0.5_1 libXxf86vm-1.0.1 libdrm-2.3.1 libglut-7.0.3 pkg-config-0.23_1 xextproto-7.0.2 xf86vidmodeproto-2.2.2 xproto-7.0.10_1
WWW: http://www.haskell.org/hugs/

Usually I remedy this using grep, but perhaps I could do better with some scripting? I quickly hacked together an alias to add to my cshrc that would allow to simply type.

> portssearch searchstring

For example.

> portssearch hugs
Port: hugs98-200609_2
Path: /usr/ports/lang/hugs
Info: An interpreter for the functional programming language Haskell 98

Port: ohugs-0.5_5
Path: /usr/ports/lang/ohugs
Info: Interpreter for Haskell with object-oriented features


All this with just two lines, an extra line to work around some difficulties with escaping strings.

set AWKSTR='{ if ( $0 ~ /^Info:/ ) { print $0; print ""; } else { print $0; } }'
alias portssearch "make -C /usr/ports search name=\!:1 | grep -E '^(Port|Path|In
fo):' | awk '$AWKSTR'"


The only problem I have encountered so far is when a port lacks a comment in it's Makefile and Info: is left out you end up with some ugly output. Like this.

Port: japanese/diclookup-emacs20
Port: japanese/navi2ch-emacs20
Port: textproc/dictum-emacs22


But it's usually a non-issue. For now, I am happy with portmaster and my little portssearch alias.

For more information on portmaster see http://dougbarton.us/portmaster.html

Wednesday, 24 December 2008

Philosophy of change

Recently I involuntary got involved in a religious debate (yes, again). My observation of how my counterpart argued became apparent pretty quickly. Change, is bad. Now, we should further define change in this particular context. Change, as in changes made to laid down principles or things considered to be facts.

If you become a part of a doctrine, a book that rigidly defines good and bad, your habits and your afterlife. You get the feeling of certainness, at least when it comes to these things. Certainness feels good, doesn't it? You can stop worrying about these specific issues, because they have been taken care of. This observation upon religion is not new, but what are the consequences?

Any change made to these principles or any element that might cause your principles to change is now causing you to feel less certain. Can god exist if we have evolved from microbes? Can my morale be justified if we are not created? Asking those questions hurt, I know, I have been there. You are faced with what seems to be two options, to abandon your principles and become a "devil", someone with no morale or certainty or to shut your eyes, perhaps even work against these "forces". For these "forces" must truly be "evil" if they tempt you to doubt? Even though they make no such claims.

But I see it in another light. I see change as good. My opponent brings up things such as Einstein proving that the ether is not a necessity. That it is indeed possible that science is wrong and that it _will_ change. I agree, I wholeheartedly agree that science will change and I think that most likely science is wrong. Wrong of course means not in perfect harmony with the physical world. Theories will change in accordance to future observations.

But my opponent and I don't agree upon change. I think that change is good, I don't think that the claims of science are rigid and forever true. Instead, they will change, but most likely for the better. You proved me wrong, thank you, thank you for allowing me to discard what was faulty and move on. To me, change is good, change is the very essence of living. I strive to pass something on, not what I learnt from those before me, but what I learnt, verified and tried to take further. This goes both regarding morale and knowledge. For how else can my children be wiser than me? I am the rope, humanity is the rope dancer.

Sunday, 21 December 2008

Sorting all the mail

I am subscribed to numerous mailing lists, ranging from FreeBSD to Python. As a result, I get a couple of hundreds of mail every day. Most of my mail boxes, such as the one I got from my school can't withstand such a bombardment for very long. Within matter of days the inbox will be full.

My old solution was to use Thunderbird on my workstation to filter out all the mails into a directory structure on my disk. That way the mails were pulled from the server and stored at a place where storage space was plenty. It worked, but it was a bit ugly. As soon as the machine was turned off or my connection went down I would have my inbox filled until a got home and started the workstation again. Now, not being at home and not having a workstation things needed to change. But how?

GMail is kind of neat, and free. You get a couple of gigabytes of storage and Google gets to index your mail and give you relevant ads. The only thing that really bothers me is that GMail sometimes uses a different terminology which clashes with ordinary email terminology. You use "labels", which really are folders on the IMAP server (took me a couple of seconds to understand what it meant to "tag" an email and to "archive it"). Sure, GMail is to date _the_ best and most intuitive way to display mails, but it is a bit confusing at times. Would I make a similar user-interface definitely, there's a lot of thought put into it.

Anyway, on to the point. I unsubscribed my old email, signed up for a GMail account and subscribed my new email to about 75 lists. Then used the GMail UI to "label" all my incoming mails from the mailing lists, mails from Python/Dev are now labeled as python/dev and are thus stored in the //INBOX/python/dev directory. It's tedious, I got there. I then added my GMail account to my mail client of choice (Thunderbird) and I could read them just like in the old days, but being accessible from any computer and not having to worry about filling my inbox.

Now, everything could have been just fine. But Thunderbird was not playing along. As a default Thunderbird won't check other boxes than the inbox. This is most likely due to the fact that it takes quite some time to check all the directories. But I just won't find it comfortable to click every single folder every time I want to check for mail. You can force Thunderbird to check every single one of them, but doing so requires you to edit the properties for all your directories (no, you can't change more than one at the time). This, is tedious, _very_ tedious.

To make matters worse, for my ordinary inbox I sort mails by date. This is really good for simple conversations but for a mailing list like FreeBSD/Current, it just becomes a huge mess. For these cases you want to sort by threads, as in, a conversation becomes a tree, the first mail is the root, all mails are leaves and an edge is established to the mail which the mail replied to. This also requires you to change the properties on a per-directory basis. I have three operating systems and a workstation at work. I don't want to reboot to check my mail, so setting it up would force me to make about 200 clicks per client. This is not acceptable, so I turned to Google.

I found the following. There is a configuration editor and there is a way to achieve this without grinding your teeth for all too long.

Check all IMAP folders for new mail
http://www.mozilla.org/support/thunderbird/tips#beh_downloadstartup

Sort order for mail/news not configurable by default
https://bugzilla.mozilla.org/show_bug.cgi?id=86845#c74

Just remember that you need to delete the old directories information files in order to rebuild them with the new defaults (in my case, threaded sorting). Why not use a one-liner? Remember to shut down Thunderbird before applying it and then start Thunderbirds afterwards and you are all done.

find ${PATH_TO_GMAIL_INBOX} -name '*.msf' | xargs rm

I hope you enjoy the "easier way to do it" (tm) as much as I did.

SSSB and automation

Recently I began reading up a bit on this whole web thing (yes, I lost my interest in coding HTML and web pages back in grade school). Things have changed and I better learn a bit since it will be beneficial for my work on my thesis. I wanted to try out authentication and HTML forms. Here's the story.

SSSB is a company that rents out flats to students in Stockholm. Back in the good old days (see 2005) you registered and for every day you got a day in line. These days could be traded in for a flat when you needed one, the more days, the better the flat. But, those things changed, the rules of the game are basically the same but you need to log in now and then to show that you are active enough. This of course, is tedious, most other non-student flat renting companies in Stockholm either don't bother or charge a fee. Already back in 2005 this annoyed me a bit but now being in the US and all it's a gun to my head. If I forget I will not have anywhere to live when I get back, or worse, I may loose three years of days. This seemed like an excellent task for a small hack.

The script I created has been tested a bit, but as always, use it at your own risk and take into consideration any moral implications. I will most likely not deploy it, but at least it might prove useful to someone.


#!/usr/bin/env python

'''
Author: Pontus Stenetorp
Version: $Id: sssb.py,v 1.2 2008/12/21 08:07:04 ninjin Exp $

Simple script to keep logging on the SSSB website to keep your days in line
for a flat in Stockholm. Meant to be executed by cron now and then.

This does not violate the agreement on sssb.se but the morality of automating
this is somewhat questionable. *sigh* I remember the good old days before this
log in every 'n' days silliness.
'''

import os
import random
import sys
import time
import urllib
import urllib2

### Constants
## User settings
USERNAME = '1234567890'
PASSWORD = '1234'

# The maximum amount of days to wait between logins, this value should be
# lower than the actual required amount of days (90)
WAIT_MAX = 90/2

# The minimum amount of days to wait between logins, this is to not log in
# all too often
WAIT_MIN = 14

# Faking is _not_ nice, but it is sometimes the only option
FAKE_USERAGENT = True

# If you want to fake, you may choose from the list below and give the index
# here. If set to negative the script will choose one at random and note it
# in the data file for future logins.
FAKE_USERAGENT_INDEX = -1

## Web page specifics
SSSB_URL = 'http://www.sssb.se/index.php?page=login'
VALUES = {'m6input_username': USERNAME, 'm6input_password': PASSWORD,
'mact': 'FrontEndUsers,m6,do_login,1', 'm6returnid': '794',
'page': '794'}

## Script internals
DATA_FILE_PATH = os.path.expanduser('~/.sssb_data')

# Look for this to confirm a successful login
LOGGED_IN_MATCH = 'Du %sr inloggad som:' % ''.join(['&', 'auml;'])

SECONDS_PER_DAY = 60 * 60 * 24

# If you are honest you will show that you are actually running a script
REAL_USERAGENT = 'SSSB login Python script 1.0'

# Thank you http://www.zytrax.com/tech/web/browser_ids.htm for the user-agents
# A mix of user agents to choose from, ranging from MSIE to Opera on several
# operating systems.
FAKE_USERAGENTS = [
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; SLCC1; ' +
'.NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; .NET ' +
'CLR 1.1.4322)',
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SU 3.1; SLCC1; ' +
'.NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; Tablet ' +
'PC 2.0; .NET CLR 3.5.21022)',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8pre) ' +
'Gecko/20071019 Firefox/2.0.0.8 Navigator/9.0.0.1',
'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) ' +
'Gecko/20050519 Netscape/8.0.1',
'Opera/9.60 (X11; Linux i686; U; en) Presto/2.1.1, Opera/9.02 ' +
'(Windows NT 5.0; U; en)',
'Mozilla/5.0 (Windows NT 5.1; U; en) Opera 8.00',
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 ' +
'(KHTML, like Gecko) Version/3.1.2 Safari/525.21']
###

def main(argv=None):

def read_data_file():
data_file = open(DATA_FILE_PATH, 'r')
last_login, next_login, user_agent = [line.strip() for line
in data_file]
data_file.close()
return int(last_login), int(next_login), user_agent

def write_data_file(last_login, next_login, user_agent):
if os.path.isfile(DATA_FILE_PATH):
os.remove(DATA_FILE_PATH)
data_file = open(DATA_FILE_PATH, 'w')
data_file.write(str(last_login) + '\n')
data_file.write(str(next_login) + '\n')
data_file.write(user_agent + '\n')
data_file.close()
return

if not os.path.isfile(DATA_FILE_PATH):
if not FAKE_USERAGENT:
user_agent = REAL_USERAGENT
elif FAKE_USERAGENT_INDEX < user_agent =" random.choice(FAKE_USERAGENTS)" user_agent =" FAKE_USERAGENTS[FAKE_USERAGENT_INDEX]" next_login =" 0," user_agent =" read_data_file()" current_time =" int(time.time())">= next_login:
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
data = urllib.urlencode(VALUES)
request = urllib2.Request(SSSB_URL, data)
request.add_header('User-agent', user_agent)
response = opener.open(request)

logged_in_line = [line for line in response if
LOGGED_IN_MATCH in line]

if not logged_in_line:
print 'FATAL: Log-in failed'
return -1

next_login = random.randint(
current_time + WAIT_MIN * SECONDS_PER_DAY,
current_time + WAIT_MAX * SECONDS_PER_DAY)
last_login = current_time
write_data_file(last_login, next_login, user_agent)
return 0

if __name__ == '__main__':

sys.exit(main(argv=sys.argv))



At line #53 you may notice a strange ''.join(), Blogger finds it a good idea to translate my escaped Swedish characters. This is a remedy, so enjoy the special Blogger version which is slightly uglier than my own version.

EDIT:
Blogger is really _terrible_ at displaying code, one almost weeps when you take a look at it. All the 80 width formatting killed by static width. *sigh* Paste it into an editor and take it away from this awful place.

Saturday, 21 June 2008

P990i USB issues

Recently I got a new cell phone, my old one being 9 years old it was quite a change. I wanted one that played music, had WiFi (since I spend most of my time at school and then I could check things up without using my laptop) etc. I found a used Sony Ericsson P990i for 1000 SEK which was quite reasonable.

It all worked fine until I transfered some music to it and the sound was all choppy and made my ears bleed. I phoned SE and they said that they never had heard of such an error. I was puzzled, what could cause this?

I tried analyzing the encoding of the files, nothing strange about it. But when I transfered a song that I considered to be more likely not to contain errors it played flawlessly. How come? It was encoded in the same way. I even checked using SE encoding and transfer tool.

Then I got it, when I played the song transfered from the phone to the computer it was still choppy. What must have happened is that SE tries to make the P990i act like a USB utility but somehow does not do it accurately (I find this likely, the phone needs a bundle of drivers), or that FreeBSD has some sort of bug in the USB handling (I find this unlikely). The first file was transfered using FreeBSD, ending up corrupted, and the second one using Windows, working just fine. This is not a pleasant surprise but now I can finally use my SE head phones.

Wednesday, 5 March 2008

The curse of being an amateur photographer

The biggest curse of being an amateur photographer, is that you never ever get a picture of yourself. I still don't have a picture of myself where I don't look like a complete fool.


Last Tuesday I brought my camera to school (to take photos for KTH), a friend snatched it and tried it out and took a picture of an unsuspecting me. It's alright I suppose, but the focus is all off and I look far too serious. If it was me, I'd take another set but... that's impossible. Thanks Auno for taking it, being your first shot it's really decent ;)

Monday, 3 March 2008

Stallman, the return

This is going to be a long one, bring a cup of tea and get reading.

Richard M Stallman (I will refer to him as Stallman from now on) visited KTH back in 1986 and held a famous lecture. At that time he and FSF also received a considerable amount of money from KTH as a thank for producing useful software for the university, 5000 USD I believe.

Last Tuesday he was back, this time it was not due to the computer club (in which I am a member) but by the union "Unionen" (it means "The union" in Swedish. Yes, I know, it's a terrible name).

Now, how does yours truly get into this mess of free software gurus, unions and university staff? You see, back in 1996 Stallman received an honorary doctors title from KTH, but he didn't attend the ceremony. I know one of our elder professors (he's a nice chap and I have helped him out in the past, I also look up to him as a teacher, but don't tell him ;) ).

The day before Stallman arrived I didn't know if I was to attend the lecture or not, after all, I pretty much know Stallmans opinions on software and I had a deadline that Wednesday. Then, out of nowhere comes an email and I am asked if I can help out with some things just before Stallman arrives and during the lecture. The next morning when my friends woke up I asked whether or not it was alright for me to take three hours off and help out at the lecture. They said that it was alright and I informed my friend the professor that I could help him with what he wanted and bring my camera in-case KTH wanted pictures. I also asked for three of the posters KTH had made for the event, you will learn more about those later.

Now, before we proceed you should know the following. When being awarded an honorary doctors title you receive a hat, it's a symbolic thing really. Because you don't really get to keep the hat.

FSFE (FSF in Europe) was to bring Stallman to KTH at roughly 17:15, so I was there at 16:30. F1 which is the largest lecture hall at KTH had half it's seats taken at 17:00 and we counted an approximate of 700 people (probably more) when the doors closed. It was packed, people in the stairs, I have not seen that many people in a lecture hall before. At ~17:00 Stallman arrived. Meeting him was a strange feeling, he looks like a hacker, talks like a hacker and certainly behaves like a hacker. He's very very frank, no "excuse me" just "I don't hear a word what you are saying." if you didn't speak up well enough. It took a while for yours truly to adapt from his usual very humble and nervous self. I should mention that I did not greet him or anything, picture me as the man in the background waiting for something to do, like bring this or that. My dear professor took care of all the official business.

Stallman wanted to prepare before the lecture (and plug in his laptop), so he was lead into a lecture room near F1. Unfortunately there was to be a lecture in German, so he had to leave in a hurry and was lead into the lecture hall before the huge crowd. He just relaxed, plugged in his laptop and a water boiler and waited for the clock to turn 17:30. I took the opportunity to take some photos, as you can see below. I also managed to talk to the photographer from Computer Sweden, he pointed out something about "Well, I prefer to use natural light sources, when he noticed my flash". I thought "Well, why not?" and switched from my normal zoom to my much more light sensitive 50mm lens and tossed my flash into the bag.

After being introduced by a representative from Unionen, Henrik Eriksson (the professor I mentioned earlier) took the stage.

Ironically, the best shot I got is probably the shot of him. Not one of the ones I took of Stallman, well well, I am still an amateur photographer. First Henrik asked how many that were present back in 1986, I spotted two people raising their hands, there couldn't have been more than 10. Henrik then explained how all went well that day back in 1996, cannon shots were fired (Stallman pointed out "But they missed me!" and grinned) at the doctors ceremony but no Stallman was there. After reading the text which explained why Stallman received the title of honorary doctor at KTH another professor approached him and placed the hat on his head.


Now, that's a picture that you won't see every day. For more images see my dA account, since this blog post is supposed to be more of a story, not a set of images.

Henrik then reclaimed the hat, he also mentioned that it quite looked like a magicians hat and that there probably were rabbits in it. Stallman the made a quick sprint, grabbed the hat and mimicked petting a rabbit, the crowd burst out in laughter.

Now, the main event. Stallman was to speak for roughly an hour and half. For those who don't know Stallman, he's about as radical as you get when it comes to software. You don't think software is politics? That software isn't closely related to the state of our society? Well, Stallman does, and he will tell you.

The speech was exactly what I expected from Stallman, he presented his view on how all software was to guarantee four freedoms for it's users. He made jokes now and then about software vendors and Bush. The only thing that surprised me was that he often pointed out that "Just because mentioned Microsoft as an example, don't think that this just applies to Microsoft, all proprietary software vendors are capable of doing this and many do". He also made an interesting remark about piracy, "When people ask me what I think about piracy, I say, burning ships is very bad", this made the crowd burst out into laughter once more.

To be honest, you can find a ton of better sources than me on Stallmans views so just read one of those instead of my interpretation. Instead I will present some points he made.


*Four freedoms of software and how the GPL guarantees them.
*How freedom of software guarantee a free society without unjust control.
*The GNU project and how it was like back in the good old days.
*How GNU/Linux is split into separate camps due to all the distros and this potentially stops what he wants to achieve with free software. He want users to care about what they are using, not just to go for "Well this works"
*How attitudes like Linus Torvalds hurts the movement since he won't side with the philosophy of the GPL.
*And more...

Personally, I agree with him on some of his views, for example that free and open source software might benefit our society in many ways. But in just as many ways I disagree with his views. I am happy for what he has done, but I won't stand beside him. His views are in many ways a religion, good and bad, it's all there.

The aftermath is Swedish papers has been very much about Stallman being paranoid. He mentioned a lot of things about cellphones being able to track you, programs spying on you, credit cards etc. etc. I agree that it might sound like he is all afraid of being tracked, but I think the answer is much more reasonable. Stallman is a freedom fighter, a radical one. He wants people to have, in a way, an ultimate power over their devices. He wants them to be able to choose whether or not they want someone to know anything about them. It's a philosophical stand, not a statement of some paranoia. I was once told that you should never rush to the conclusion that someone is stupid if there is a more rational conclusion, and although I am not a Stallman expert this very much seems to be the case here.

Afterwards, Stallman stayed and wrote autographs in exchange for a 30 SEK donation to the FSF. I got one for free on one of the posters which I handed to another Stacken member. He promised to put it on the wall in the computer club room. What ever you say about Stallman, he has been influential and probably will be for the years to come. For good or for bad? I guess we won't know for sure for at least another 20 years.

Sunday, 17 February 2008

Observations on my way home


When walking home this Friday I noticed something peculiar. Usually when a pedestrian enter a store he moves in an arch, much like my sketch to the right. He also maintains roughly the same speed as before entering the arch until he reaches the door to the store where he slows down slightly, opens the door and enters the store.

But one store is different, here, people enter the store in a radically different way. They maintain normal walking speed and keep their eyes fixed straight forward, unlike when entering other stores where they always look around observing other stores and pedestrians. Then, when they have passed the point when at other stores they would begin their approach in an arch, they suddenly turn at a sharp angle and increase their speed substantially. They maintain this increased speed pushing the door open with force and does not appear to slow down until inside.

The reason might be, that the store is the most well known adult video store in Stockholm.

Saturday, 5 January 2008

Swedish Anti-Piracy Commercial

Now and then Swedish anti-piracy agencies and the Swedish movie and music industry makes a commercial in order to tell us, the people of Sweden, how morally wrong piracy is. If you just cut the crap and don't argue whether piracy is wrong in the first place, the latest movie, and all other movies they have ever made, has a pattern. Let's describe the latest one.

A person walks up to a public toilet and pays the fee of roughly 5 SEK (about 1 USD). Just as he enters the booth, another person forces his way into the booth with him. He is then forced to pee along with a stranger although he paid for the booth himself and the stranger does various embarrassing things and is not the least embarrassed about "stealing" his spot.

Something like this is usually the theme, previously we have seen people borrowing movies from rental shops without paying.

Now, what is the problem with this? It portrays the person conducting piracy as someone who is stealing from a customer or a store. Is this really the case? I certainly don't think so, a person conducting piracy don't steal anything. They certainly do some economic damage, but they don't steal. By portraying them as simple thieves, the industry leaves an open goal, their opponents laugh at them and most Swedes just think that they are silly. They look stupid, and won't get paid.

What should the industry show instead? You don't have to be a genius to come up with an honest and probably better commercial. So, here you are STIM, APB, SF and so on, here's my suggestion, all for free. Instead of portraying the person who you so clearly, don't want to continue copying your material, as a thief, which he is not and will never associate himself with and therefore will continue copying your material and you have run down your many million SEK commercial down the drain. Why not show him what he actually does, show him how a movie is made, show him how money spent on a movie get people paid for their hard job, show him the set of actors and so on, showing numbers and faces. Don't go all silly and show sentimental letters, just facts, "When you condone piracy, all these people get nothing and to you, they give you the very best of their efforts". This will work, this is honest, this is what piracy is all about and how you might actually win. Stop acting like idiots with a multi-million SEK budget who are unable to send a message but able to make great movies, albums, etc. It ain't that hard, all you need is the ability to reason.

Thursday, 6 December 2007

Glögg review 2: Tillmans Glögg av Svarta Vinbär

I have had the luck of finding a really strange bottle of glögg. Tillman, which is a small rather local brand, makes glögg using black currants instead of red wine. It's also completely alcohol free, let's see how good it gets.


The smell is stronger than usual, it reminds me of some glögg sweets that I stumbled upon last summer in a small candy shop. It doesn't smell like glögg usually does, but it still is rather pleasing. I suspect the smell is because of the black currants, because after the initial aroma of spices it's something like a strong cup of black currant tea.

The taste is a little less punchy than one would expect from a sip of glögg, there is a lot of taste from the berries and it's not even remotely as sweet as one would fear. But, you miss the wine, the taste just won't last as long and be as deep as wine. But it is not a bad substitute for red wine, unlike most mixes of grape juice and other juices that makes glögg taste terrible you do enjoy drinking the strange mixture of black currants and glögg seasoning. I would certainly recommend it, perhaps not for a big party, but certainly as a pleasant and refreshing Christmas beverage for yourself or in the company of a friend or two.

Tillmans Glögg av Svarta Vinbär
3/5
Price: ~40SEK per bottle of 750ml

Sunday, 18 November 2007

Glögg review 1: Blossa lättglögg

As you have seen in my profile, I like glögg. Glögg is rather typical for northern europe and is served hot with raisins and almond during the winter season. It's most of all associated with Christmas, but some (like me) enjoy it from mid November to mid January. Glögg is made from wine, traditionally red but nowadays also white. It's seasoned, which gives it a unique sweet and rich taste. Do note that during my test sessions, I do not add almond, raisins or eat ginger snaps. It's only the glögg and nothing else that I will test.

Since a lot of people never hear of this excellent beverage I thought that I'd make a set of reviews of different kinds of glögg with low-alcohol content. There are plenty of brands and flavours to chose from when it comes to high-alcohol content, but for low-alcohol there are about eight kinds to chose from. But I will try to find more.

First out is the true classic "Blossa lättglögg". When you think of glögg, this is the brand that first springs to mind. It's sweet and has a rather spicy taste. You can clearly make out the traces red wine somewhere amidst all the other tastes.


Currently, this is my personal favourite. But it's rather plain, most Swedes ought to be used to this taste, so it's really nothing special about it. You just see it as what defines glögg. Therefore, I can't give it five out of five. Since, you can't stop thinking that perhaps there is another glögg out there, one that is richer, leaner and will taste even better with your ginger snaps. I therefore give it four out of five, it's good, really good. But still, there is nothing special about it.

Blossa lättglögg
4/5
Price: ~25SEK per bottle of 750ml

Those who want to know more about glögg should take a look at the Wikipedia article.

Saturday, 17 November 2007

Friday night, is physics and Python night

It's Friday night, you don't have anything to do. Well, you could of course work. But after working hard for more than a week and not even having a weekend last weekend you don't want to do that. Besides, your studies and your employer must let you have some fun.

What I did was dig up Python, some upper secondary school physics and my Fundamentals of Physics (as I am a CS student I have only taken one course in physics at university level) and started to hack some code. Planetary orbits and gravity, I thought, could look rather nice when simulated. So a few hours later I have constructed a small program that simulates the effects of gravity.


What you see is a "sun", well, it's really just a much bigger astral body (just like a sun) and some smaller planets moving in orbits around it. The lines represent gravity vectors, speed vectors, acceleration vectors and so on. They are just there to help me debug the whole thing.

It has been a rather nice Friday night in my opinion. Perhaps I should hack a little more on the concept, who knows. Now I will get some sleep and tomorrow it's all school work and work again.

Thursday, 15 November 2007

Is God dead?

Idling in the web I read the following about a Norwegian trying to prove that God doesn't exist.

-"Our project is nothing less than proving that God doesn't exist. In each program I will commit a deadly sin in a new country. ... If God doesn't react by the end of the series he is declared dead."

Well, I wouldn't care if God was dead. But this Norwegian clearly know nothing about how to prove that God doesn't exist. Any believer might just as well say "He chose not to act". In order to falsify the existance of God you need God to be falsifiable. Otherwise it's like beating someone capable of changing the rules of the game while playing.

An example of this. Say that I have constructed a device that can detect with 100% accuracy if God is within a 25m radius. I start the device and it says that God is not within 25m. I claim that this is a proof that God doesn't exist. How ever, any believer might simply say "You can't detect God if he doesn't want to be detected." or "He wasn't there at the time, since he doesn't want to proved, he wants to be believed.". Thus, any godly being can't be proven to not exist. Any attempts at doing this are futile and therefore should be ignored. It's better to spend our time at tasks that may lead to results that benefit us, rather than to chase ghosts.

Article in SvD (In Swedish)

Thursday, 8 November 2007

Misuse of statistics?

DN has published an article by Pressens Mediaservice, some news agency (I haven't looked into it very much). The article is about the failure of Radiohead's latest CD release which was available for free, on line. You could chose to pay if you wanted to. The article deems this as a failure, since 62 percent chose not to pay.

Now, 62 percent is a lot, but it's not even close to what we would need to know in order to deem it a failure. How many downloaded it? How much did they earn? How much do they usually earn? How much does an old-fashioned way of distributing a CD cost? Perhaps knowing this and probably even more, we will have knowledge enough to judge whether it was a success or not. As it is now, the company who carried out the analysis (
Comscore, and if they judged it a failure based on only these numbers it's time to give a free and mandatory course in statistics to each and every employee) or a journalist at Pressens Mediaservice have taken misuse of statistics to a whole new level. Statistics is a powerful tool, but one is not to take only so much that it provides a point of view that you want to present or that you feel comfortable with. Stay true to the data, at all costs, data never lies, people do.


Link to the article in DN (Swedish).

Wednesday, 10 October 2007

Visions of the future

This morning I began pondering upon how we envision the future. Given a rather vague description in a text will most certainly result in an envisioned picture of your imagination that is very real indeed. You will "see" much more than the author originally intended and this of course is a good thing. The text and story should be more likely to suit your taste.

Now, through this argument rises an interesting question. How different would that inner picture be? It would be very interesting to give the text below to several subjects. Shall we say five families and that the experiment is carried out at the age of twenty for five generations? This of course will risk the older family members to pass on their visions, so perhaps a choice at random among the population currently 20 years of age is more appropriate? But then instead we risk not to have a similar social context instead, which could affect the result. Considering both options above, I'd say that determining several social attributes and then choosing randomly within several combinations at each experiment. The same combination for each experiment, so there would be several lines of pictures. This is likely to yield better results than the first two options.

Now to the text, I imagine something like. "When he got home from work later that day, the stars were already visible. As he reached the doorstep, he stood still for a moment and looked up at the serene sky." How different could that image be? Perhaps this is the very reason that some books never feel old, unlike films which age very quickly. Does our imagination aid us when reading, turning the authors hints about a world into our very own creation?

Sunday, 9 September 2007

Learn Swedish online?

For some reason, a bunch of people in Japan want to learn Swedish. ^^ It's a bit charming actually, but are there any language resources out there? I set out on a small quest to find some.

Since I work and study at the Computer Science department at KTH, the first thing I thought of was Lexin, Stava and Granska.

Lexin is a Swedish to many-languages dictionary, it's a good tool both for us Swedes who sometimes need to check our spelling twice, or when translating Swedish. Give it a try, it's the best Swedish dictionary that is available for free.

Lexin also offers a set of images, marked with the Swedish names for the things in the picture. Like the ones you get in elementary school books. The text is in Swedish, but try out the 33 image sets.

Stava is a spelling tool and also some grammar checking is done. I think one of the creators hinted me that it did beat Microsoft Word's Swedish grammar checking in a scientific test. So although it looks simple, it's far superior to anything I have found on the web. The only drawback is that it is in Swedish, but it's fairly easy to make out which buttons to press and how it suggests change of spelling.

Granska is a grammar checking tool, it's fairly new compared to the previous two tools. And to be honest, I only know that it has proven to be very good at detecting a grammatic mistake called "särskrivning" in Swedish. For example, unlike English, Swedish is very liberal when it comes to forming new words by using two words and turning them into a single word. "Get" goat, "Ryggsäck" rucksack and "Tillverkare" maker can be turned into "Getryggsäckstillverkare" Goat rucksack maker. This is a perfectly legal word, although rather strange. The language group at the CS department is responsible for this and it aims to aid non-native speakers of Swedish.

I think this is all the CS department has to offer at the moment. So I set out onto the world wild web for more resources.

Stockholm School of Economics has a good 40 page introduction to Swedish. It's free and basic.

Leif Stensson has made a quick guide to Swedish grammar, although not finished it gives some insight into Swedish grammar.

FSI has a rather large collection of audio files for practising pronunciation, I checked out the first one and it was quite al right. This is in fact the only good audio resources I did find.

Transparent Language
has a Swedish Proficiency Test on line, it's not very extensive but might give you a hint. It's not easy though, so study for a while before looking at it.

I hope you get some help using these links, and good luck on your Swedish studies. Att lära sig Svenska är en utmaning, men en utmaning som i slutänden troligen ger dig en hel del glädje.

Sunday, 2 September 2007

Unix Party pin?

Yesterday I watched the movie Contact, based on a novel by Carl Sagan. I found it rather interesting, but that's not why I am making this post. On one of the computer monitors at the antenna array in New Mexico, there is a pin. Saying "Unix Party". I am not American, but I think it resembles to a political party pin, used during US elections. I have done some research about it, but I haven't found anything. Does anyone know anything about this? I would be happy to know more about this little novelty.

I took a photo of the screen. It's a bit blurry, but you can clearly make out "Unix Party".

Friday, 31 August 2007

Respecting and understanding differences

Lars Vilks has recently become rather famous. I have never cared much for his art, it's a bit too strange for my taste. How ever, lately, conservative Muslims have reacted with anger to his latest work. Apparently, Vilks thought that it would be a good piece of art to make a statue of the prophet Muhammed. Swedish law allows you to publish, make, etc. all sorts of things. We call it freedom of speech, basically you are allowed to do most things if the intent is not to offend. Vilks intent can be discussed, but most likely he is trying to get some attention along with creating a debate on whether or not you can mock anything. To be honest, the statue is rather silly and deserve little attention.

Personally, I think you have the right to make fun of anything. As long as the sole intent is not to offend or humiliate a living person or group of individuals. In a democratic society you can make blows and take blows. Making something holy and making it taboo is not the way of an open society. If I was Vilks I'd make a piece of art mocking most religions. That way, I'd think it was more fair. And perhaps there would be some debate among believers (concerning why some burn flags and others ignore it as a silly piece of art) instead of focusing on a single religion.

As I mentioned earlier, it really deserves little attention. The right thing to do is to protest peacefully at the publisher and criticise those who you do not agree with. An excellent example is the protest in Örebro, they were aimed at the paper and Vilks. I don't agree with them on whether or not it should be published, but it was nicely done and they showed their point of view.

As with all things, there is also the wrong thing to do. For example, if you would go and burn flags. You are no longer criticising Vilks and the paper that published his works. You are instead blaming a group of people, who most of them don't give a damn about Vilks, of being the source of your discontent. Doing so is no longer a protest, but an attack on an open society. You could also proceed to threatening the artist and thus placing you and your beliefs above Swedish law, thereby eliminating all doubts that you are not a citizen who believes in freedom of speech (apart from your own freedom to do and say what ever you like of course). Why not burn a doll of a man who had nothing to do with the whole thing, apart from being the same nationality as the artist.

Why can't fanatics act rationally? Why are they so blinded that they can't see how they should show their point of view (without being considered to be mental cases that are better off locked away from society)? Well, I guess that's what makes them fanatics.