Archive for the ‘Uncategorized’ Category


Som de fleste geeks bruker jeg adblock til å surfe uten plagsomme reklamer.

Jeg skjønner at antakelig blir hardere rammet enn andre av
at deres brukere i stor stil bruker adblock. Men etter et forsøk på å
laste websiden deres uten adblock har jeg ingen sympati for de lenger.
Og når de putter en stor plagsom panda og tekst øverst for alle som
bruker adblock, så måtte noe gjøres.

Løsningen er å installere dette greasemonkey-scriptet. I Firefox må
man installere GreaseMonkey addon’en først. I Google Chrome bare
trykker man install så kommer den inn som en egen extension.

Vips så er pandaen på og medfølgende tekst borte vekk…

Android 4 and Calendar crash


After I got a new phone with Android 4 (ICS), my calendar crashed as
soon as I enabled sync of my google calendar. After *lots* of
googling, I finally found the cause: At least one of the events in the
calendar is “corrupt”, and in earlier Android versions this has been
handled better than in the new Android. In the new, it gets real sad
and the whole calendar application crashes.

The solution (also found after *lots* of googling):
1) Log into your google calendar on a PC in a browser.
2) Go to calendar settings and export the whole calendar to an ICS-file.
3) Make sure you have the ICS-file (open it in a text editor)
4) Delete your calendar (or all events in it if it’s your main
calendar) on the web / google calendar
5) If you have more than one calendar, repeat steps 2-4
6) Import your ICS-file back to the google calendar 
7) If you have more than one calendar, repeat step 7 

For me this solved everything. From what I read, some will get an
error when importing back in, and then it will state the line number
the problem is in. This can be a malformed time zone, some funky
recurring event and so on. In that case:
a) Open the ICS-file in an editor
b) Fix the malformed line
c) Go to step 6)

Hope that was helpful, it solved all my problems at least 🙂

PS: I read that most of these errors come from using programs that
sync your outlook/exchange calendar to google. It probably messes up
recurring events and timezones sometimes, and the event ends up
corrupt. For some reason Google doesn’t detect this, and you get a
big problem on the Android that crashes when it gets to such a
malformed entry.

amixer in ubuntu


If you want to change the volume in Ubuntu 11.10 it seems that amixer
is kind of bugged when it comes to toggle (mute/unmute). When
toggling Master, it also mutes all the separate groups (Front,
headphone, PCM and so on), but when toggled again it only unmutes
Master, which leaves the rest muted…

I came across a nice workaround that i wanted to share. The solution
was written by Jim Hunziker on this page:

1) Make a with the following content:

#!/bin/bash CURRENT_STATE=`amixer get Master | egrep 'Playback.*?[o' | egrep -o '[o.+]'|head -n 1`if [[ $CURRENT_STATE == '[on]' ]]; then    amixer set Master muteelse   amixer set Master unmute   amixer set Front unmute   amixer set Headphone unmute   amixer set PCM unmutefi

2) chmod u+x

3) Bind it to some key (f.ex. XF86AudioMute) to run



Cutting bits from avi-file with ffmpeg/mencoder


I wanted to cut out two bits from an avi-file and then join them to
get one small file from a large file. I thought using ffmpeg would be
easy for this, but it turns out it might have a but with avi/wmv so I
ended up using mencoder instead.

The original try I did with ffmpeg was:
ffmpeg –ss 00:05:52 -t 00:00:11 -i bigfile.avi small_clip.avi
It looks like it wants to do what I want, since it makes a file where
the first 11 seconds are the ones I want, but then the sound
disappears and all of the rest of bigfile.avi is there (the video at

I could not find any solution for this on the interwebs, so I ended up
trying mencoder which worked:
mencoder -oac copy -ovc copy -ss 00:05:52 -endPos 00:00:11 bigfile.avi
-o small_clip.avi
I repeated the above for all the clips from bigfile.avi and then put
them together:
mencoder -oac copy -ovs copy -idx -o joined_clip.avi small_clip1.avi
small_clip2.avi and so on

Google Chrome and Kerberos


Just a short tip for those of you that use Google Chrome and want to
utilize Kerberos to login to sites:
You need to start Chrome with an extra command-line option. Why this
isn’t configurable inside Chrome is a mystery, but anyways – here is
the solution:
1) Make sure you have a kerberos ticket (check with klist or do a new kinit )
2) Start Chrome as this:
google-chrome –auth-server-whitelist=”domain”
domain can f.ex. be *

Voila, Kerberos-login works.

How to make IE8 trust a self-signed certificate in 20 irritating steps (and also for Google Chrome)

  1. Browse to the site whose certificate you want to trust. 
  2. When told “There is a problem with this website’s security certificate.”, choose “Continue to this website (not recommended).” 
  3. Select Tools->Internet Options. 
  4. Select Security->Trusted sites->Sites. 
  5. Confirm the URL matches, and click “Add” then “Close”. 
  6. Close the “Internet Options” dialog box with either “OK” or “Cancel”. 
  7. Refresh the current page. 
  8. When told “There is a problem with this website’s security certificate.”, choose “Continue to this website (not recommended).” 
  9. Click on “Certificate Error” at the right of the address bar and select “View certificates”. 
  10. Click on “Install Certificate…”, then in the wizard, click “Next”. 
  11. On the next page select “Place all certificates in the following store”. 
  12. Click “Browse”, select “Trusted Root Certification Authorities”, and click “OK”. 
  13. Back in the wizard, click “Next”, then “Finish”. 
  14. If you get a “Security Warning” message box, click “Yes”. 
  15. Dismiss the message box with “OK”. 
  16. Select Tools->Internet Options. 
  17. Select Security->Trusted sites->Sites. 
  18. Select the URL you just added, click “Remove”, then “Close”. 
  19. Now shut down all running instances of IE, and start up IE again. 
  20. The site’s certificate should now be trusted.

API and RedHat Network


If you use RedHat Enterprise Linux in a big environment, you probably
use RedHat Network (RHN) as well.

RHN has a very well documented API, which can be used for all tasks
you want to do.

Here is a small script I wrote to list out all of our systems and when
they last checked in:


import xmlrpclib
import getpass
from sys import stderr
import sys

RHN_URL = “”

# Using stderr so redirect of the script to a file still works for prompts:
stderr.write(‘Please input your RHN username: ‘)
u = raw_input().rstrip(‘n’)
p = getpass.getpass(stream=sys.stderr)

client = xmlrpclib.Server(RHN_URL, verbose=0)
key = client.auth.login(u, p)
list = client.system.listUserSystems(key)

for group in list:
sysname = group.get(‘name’)
sysid = group.get(‘id’)
last_checkin = group.get(‘last_checkin’)
print ‘{0} – {1} ‘ .format (sysname, last_checkin)


Hope that might be useful for someone else.

For more info on RHN’s APIs:

Wlan Password for guests


If you, as me, have a very long password for your wlan, it’s tiresome
to give out the password to random guests who need to connect.

Easy solution: Go to this web page and choose Wifi Network. Then fill
in your ssid, password and type of encryption and you get a QR-code to
print and give to guests. All your guest need to do, is scan the QR
code with f.ex barcode scanner on Android (or similar on other
phones), and they will connect automatically!


How to change memory card on an Android-phone



Many upgrade their memory cards in their Android phones to a bigger
one, and as many of those I thought it was just to insert the new one,
and copy back all the data. For many reasons, that is not just so

1) Your old card most likely contains more than one partition – a
swap, an ext2/3 partition and the big fat32-partition with your files
on it.
2) Your applications might depend on the data on your old partitions
to start, and your phone might not boot up without it being present

So, here is how to do it (with linux anyway):
1) Turn off your phone
2) Insert the new memory card
3) Start your phone in rescue mode by holding down the volume down
while turning it on
4) Partition it through rescue mode
5) Format it through rescue mode

Now we are ready to move your old data over to the new memory card.
If you have two card readers, you can do it directly from card to
card, if not, you need to go through an extra step. But the steps are
basicly the same.

If you have two card readers:
1) dd if=/dev/old_memory_card_partition
of=/dev/new_memory_card_partition conv=notrunc,noerror

If you only have one card reader:
1) Insert the old memory card
2) dd if=/dev/old_memory_card_partition
of=/location/to/save/memory_file.dd conv=notrunc,noerror
3) dd if=/location/to/save/memory_file.dd
of=/dev/new_memory_card_partition conv=notrunc,noerror

Repeat the dd-process for each partition (except swap).

At this point the new memory card has all your old data, and will work
if you insert it. However, since we copied the whole partition with
dd, it includes file system information like the size of the
partition. Which means that even though the new partition might be a
lot bigger than your old, it will only use up to the same space as the
old partition. You can see this if you insert the new memory card in
your card readser/linux machine and do a df – it will show a total
size that is right, use space is right, but free space is very small.
So we need to resize the filesystem(s):

1) Insert your new memory card
2) Start ‘parted’
3) Write ‘print devices’
4) Write ‘select ‘ and the device name for your memory card
5) Write ‘print’
6) Write ‘resize’ and follow the step by step choices it gives you.
Just resize it to fill the whole partition. It should be rather quick
to do
7) Repeat step 6 for each partition you copied over with dd
8) Write ‘quit’

At this point you should be able to mount your new partitions on the
linux machine and see that you have the right amount of free disk
space. You can unmount it, insert it into your phone and turn it on
and use it all 🙂

Good Luck!


The stress of disk failure



A few weeks ago my ZFS raid containing 12 1.5tb Western Digital green
drives was degraded due to a drive failure. As I have a hot spare
added to the raid as well, the raid was quickly rebuilt and has been
working fine through the problems and afterwards. I ordered two new
drives, and today I thought I would change the defective drive, and
let the replacement-drive become the new hot spare. Before I started,
I did a detach of the defective drive to make the hot spare
permanently stay in place of the defective drive: ‘zpool detach DATA



Before I started, I thought it would be a good idea to reboot the
server, just to see if the server works as it should before I started
tinkering. I reboot, and the server starts beeping loudly about a
drive missing (this was from the raid controller before the OS had
started). I thought nothing of it, thinking that it was the one that
was defective. So, I started the OS to see if everything worked as it

A quick ‘zpool status’ showed me that I had indeed a new problem: A
new drive had failed, and one of the three raidz1-groups was now
degraded as I did not have any hot spare free to rebuild the raid.
While doing some ‘zpool status’ my heart suddenly skipped a few beats
as I noticed a second drive in the same raidz1-group missing, and the
message was now that the zpool did not have enough replicas to
function at all. Luckily I have been in tough situations when it
comes to drives and hardware before, so I thought this was not a good
time to panick. I descended from the attic, and took a break with
some coca cola.


I thought, why would two “new” drives fail at the same time, before I
had even touched anything? I got back up to the attic, and now one of
the drives missing was suddenly working again and some data had been
resilvered. This made me think that maybe the drives were not
defective after all, maybe they just had some bad cables. I turned
off and opened the server, and checked every cable thouroughly.
Having close to 20 hard drives in this server, there are as you can
understand quite a few power splits. One of them was going to the two
drives that were missing (of which one had luckily come back). I
changed out the powersplit, and also changed the defective drive that
was the original problem. I booted the server and did the changes in
the raid controller, making new volumes for the new drive and the
changed one. Then booted the OS in single user mode.

Luckily drive number two of the two that went missing was still
working, and I did a ‘zpool replace DATA c0t3d0 c0t3d0’ to get the
zpool to rebuild and start using the first drive that had been
missing. Then I added the new hot spare to the zpool:
‘zpool add DATA spare c3t5d0’ After about 1.5 hours the raid had
been rebuilt, and was back in normal mode with no faults.

Hopefully the problem with the two drives that went missing is only
the power splits, and that they don’t give any new problems. And also
that it will be a long, long time before the new hot spare is needed

Thank God for raid and hot spares, I do not even want to think about
loosing the 12tb raid. I do have backups of the most important stuff,
but backing up all of the data is quite impossible at home with such
amounts. Starting from scratch with all of my ripped movies and music
and so on would be a nightmare.




%d bloggers like this: