I got a tip from my friend Pål about the podcast The Skeptics’ Guide to the Universe some time ago, but I haven’t had the time to listen to it before the last week. I really like how they discuss things like pseudo science and why things like creationism is bad. The discussions are kept very relevant, serious and contains lots of very good arguments for their opinions.

I currently at their 5th podcast (June 15, 2005), but I hope to getting up to date by august.

Before I started using Linux as my default OS I used Mac OS for 5 years. In Mac OS the TAB key behaves different in Firefox than Ubuntu (my preferred distro). When using the TAB key in Mac OS it focuses on input fields only rather than every object (images, links, whatever) in a web page .

Today I finally took the time to find out what the difference between the Firefox in Mac OS and Ubuntu. I opened the about:config and searched for “tab”, and what do you know. I found an option called “accessibility.tabfocus” which was set to the value “7″.

A quick google search brought me to this site which tells you everything you want to know about accessibility.tabfocus.

If you want TAB behavior like the one in Mac OS you simply change the value of accessibility.tabfocus to “1″, et voilà, it works!

You can combine options. For example you can set the value “3″ to select any form element on a web page. Read more at http://kb.mozillazine.org/Accessibility.tabfocus.

edit:

For those who didn’t know; you can press Shift+TAB to focus the previous selected element.

This may be old news, but I didn’t notice this before today (thanks to Emil for the tip):
You can actually get the Spotify URI’s to work with wine!

To get this working for Firefox all you have to do is:

Make a runable bash script

echo '#!/bin/sh' > ~/.browser2spotify
echo 'exec wine "C:\Program Files\Spotify\spotify.exe" /uri "$@"' >> ~/.browser2spotify
chmod 755 ~/.browser2spotify

Add settings to Firefox

First open the config window (type about:config in the address field).

You now want to add the following options:

network.protocol-handler.external.spotify = True
network.protocol-handler.app.spotify = ~/.browser2spotify

The last option may vary depending on where you put your browser2spotify script.

You can find everything in this post at http://www.spotify.com/en/help/faq/wine/. They also have a howto for Opera.

Today I decided that I’m going to give twitter another try, but the first thing that struck me was how cumbersome it was to actually post a tweet.

The way I did it:

  1. Open your favourite browser
  2. Go to twitter.com
  3. Log in
  4. Write a tweet

I’m a Linux user and I love the terminal. Wouldn’t it be better to write tweets from the terminal? – Yes it would!

I have written a quick and dirty python script that enables you to write tweets from the terminal.

You can download the script here.

Install guide for Debian:

Step 1: Download

$ wget http://dibon.net/tweet
$ chmod +x tweet
$ sudo mv tweet /usr/bin/

Step 2: Install curl

The script uses curl to send data to twitter, if you don’t have curl installed you have to install it:

$ sudo aptitude install curl

Step 3: Make the config

Make a file called “.tweet” in your home directory:

$ vim .tweet

And insert the following:

[login]
username = YOURUSERNAME
password = YOURPASSWORD

You may want to edit the permissions for the file

$ chmod 0700 .tweet

That’s about it. You may have you reopen your terminal window before you can use the tweet command.

Usage:

$ tweet "I'm writing a tweet in terminal!"

Unfortunately it is necessary to use single or double quotes before and after the message.

I’ve just started watching the documentary series “When We Left Earth” by Discovery and I must say: It is awesome!

It’s about NASA’s accomplishments; the space walk, the moon landing and more. Tons of awesome footage from space in HD (watch this in HD!).

Read more here, and here.

For the last years I’ve been using Mac OS X, but now I’m running Ubuntu. Ubuntu has very much functionality build in, but the Norwegian mac keyboard layout isn’t that great out of the box.

There are three steps required to get the layout partially[NB!] right:

  1. Change 3rd level chooser and switch Alt / Win (cmd) key.
  2. Edit the XKB-file to get keys right.
  3. Set the keyboard in  Ubuntu to “Norway Macintosh”
Step 1:

Open the keyboard settings (System -> Preferences -> Keyboard) and click the “Layouts” tab. Then click the “Other options…” button.

1.1) Press “Alt/Win key behavior” and choose “Left Alt is swapped with left Win-key”.
1.2) Press “Third level choosers” and select “Press any of Alt keys to choose 3rd level” (or “Press left Alt keys to choose 3rd level”).

Step 2:

This part is a bit more tricky.

Open the terminal and open the folder “/usr/share/X11/xkb/symbols”

$ cd /usr/share/X11/xkb/symbols

The file we are going to edit is named “no”, but before we begin lets backup the file!
From now on every command run as root (noted by #).

# cp no no_backup

Now open the “no”-file with your favorite editor, I’m using VIM.

# vim no

Scroll down to the part which starts with:

// Copied from macintosh_vndr/no
partial alphanumeric_keys
xkb_symbols "mac" {

You now need to change the following lines:

key <TLDE>  { [      bar,    section, brokenbar, paragraph    ] };
to:
key <TLDE>  { [      apostrophe, paragraph, bar, brokenbar ] };

And:

key <AE04>    { [         4,  currency,       dollar,       dollar ]    };
to:
key <AE04>    { [         4,   dollar,       currency,       dollar ]    };

Then save.

Step 3:

The only thing remaining is to select “Norwegian Macintosh” as your default keyboard layout.
In System -> Preferences -> Keyboard, press the “Layouts”-tab and press the “+”-button.

If everything is done right you should have the basic Norwegian mac layout.

NB!

This layout is not equivalent to the real Norwegian mac layout. There is a lot of keys that needs mapping to do so. The original layout looks like this (keys are pressed from left to right).

Edit:

It seems that if you use the newer versions of Apple’s keyboard you have to change the setup for the TLDE-key and the LSGT-key. I don’t know why, but it works!

Auto brackets and indent in VIM

February 23rd, 2009

As I mentioned in post gedit + plugins = \o/ you can make gedit auto complete {}, insert proper indentation and place the cursor in the right position.

I have recently moved on to using VIM. Of course I want the same functionality, and therefore had to make this happen!

Here is what you do:

In your ~/.vimrc put:

set autoindent
inoremap {<CR> {<CR>}<Esc>O<Tab>

Enjoy!

Edit:
If you want auto completion for “([])” etc. you might want to check out autoclose.vim!

Edit 2:
If you want the automatic indentation inside {} while using autoclose.vim you need to remove “{“,”}” from the source.

Line 148 then look like:

let s:charsToClose = {'(': ')', '[': ']', '"': '"', "'": "'"}

Tobias found this cool Google Tech Talk about Advanced Topics in Programming Languages: Java Puzzlers.

The puzzles are sometimes very non-intuitive, and is mostly results of bad API’s or other strange features. Some of the puzzles aren’t very useful, but it’s always nice to have a deep understanding of a programming language.

Watch the talk a YouTube:

Learn Python in 10 minutes

June 22nd, 2008

My friend He Yu provided me with a link where you can learn Python in 10 minutes. A nice introduction to Python assuming that you know general programming.

I’m looking into Python for two reasons. One; I want to expand my knowledge of programming languages. Two; Next term I’m taking the course Introduction to Algorithms where Python is the language we will be using. It’s always nice to have a head start.

Update:

It turns out that the professor teaching the course has written books about Python and also written a short tutorial. Click here for tutorial.

I just found a really fascinating documentary about Chris Michael Langan. He has an IQ between 190 and 210, had a very bad childhood, works in a bar and has many interesting views on the world we live in. Particularly the part where he talk about his experience with the school system is interesting. As he says in the documentary:

I found the whole experience of school to be highly annoying. I think I could wrapped the whole thing up in a couples of years. Instead they managed to keep me around for twelve. [...] My teachers just didn’t particularly care for me.

I totally agree with him. We have to realize that smart people need special attention. They should be inspired to learn more about fields they find interesting, and maybe one day make a breakthrough in their field or fields. We need more people like Newton, Einstein, Euler and so on.

The school system in Norway takes care of the people who are less fortunate than the average person, but they don’t seem to care about people who are more fortunate, i.e. people with high IQ. The politicians should really sit down and do some drastic changes to the school system. We need to get back to the basics of learning and get rid of all the pedagogical bullshit that’s being suggested.

See the documentary on YouTube:

Part 1:

Part 2:

Part 3: