Disappointing TEDx in Croatia

10/15/2013

This man was banned from going to all TEDx in Croatia after pointing out pseudo-science in a talk that was going to happen.

This is really not good for the fantastic TED brand…

http://svedic.org/skepticism/i-was-kicked-out-from-tedx-event-for-saying-water-fuelled-car-is-a-scam

Prime Numbers

10/15/2013

Another fantastic TED-talk about monster prime numbers and why science is cool!

Sleep

10/15/2013

Fantastic TED-talk about why sleep is important. Scary stuff. People need to sleep more.

Happiness

10/15/2013

Fantastic TED-talk about how to be more happy. Change the formula for happiness!

Imported from Posterous

05/09/2013

Since Posterous closed down, I just imported all my posts into WordPress.

Official address on wordpress is mortencb.wordpress.org, but the old addresses blog.mortencb.cx and posterous.mortencb.cx are being redirected here as well.

Hope everything works, please leave me a comment if you notice anything weird.

Fixing drive failure when using mdadm/raid1 on boot device (CentOS 5)

10/04/2012

Linux
Drive_crushed

I am using CentOS 5 for one of my servers, and use raid1 and md for
the mirroring between two drives.

Then one of the drives fail (which they eventually will), here is how
you fix it:

I have taken info from these pages for this blog post:
http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
http://blog.mydream.com.hk/howto/linux/howto-reinstall-grub-in-rescue-mode-wh…

In this example I have two hard drives, /dev/sda and /dev/sdb, with
the partitions /dev/sda1 and /dev/sda2 as well as /dev/sdb1 and
/dev/sdb2.
/dev/sda1 and /dev/sdb1 make up the RAID1 array /dev/md0.
/dev/sda2 and /dev/sdb2 make up the RAID1 array /dev/md1.
/dev/sda1 + /dev/sdb1 = /dev/md0
/dev/sda2 + /dev/sdb2 = /dev/md1
/dev/sdb has failed, and we want to replace it.

First of all: ‘cat /proc/mdstat’ is your friend – it will show you the
status of your raid during the whole process.

In the output from ‘cat /proc/mdstat’ you will see an (F) behind a
failed device, or it will be missing alltogether.

First, fail and remove the failed device(s):
mdadm –manage /dev/md0 –fail /dev/sdb1
mdadm –manage /dev/md0 –remove /dev/sdb1
Repeat for other MD-devices containing sdb-parts.
Now the output from ‘cat /proc/mdstat’ should only contain parts from sda.

Power down, change the drive, and turn it back on.

To make the same partitions on sdb as you have on sda, do this:
sfdisk -d /dev/sda | sfdisk /dev/sdb

‘fdisk -l’ should now show the same partitions on sda and sdb.

Next, add the proper parts from sdb to the relevant md-device. So if
md0 contains sda1, do this:
mdadm –manage /dev/md0 –add /dev/sdb1
Repeat for all md-devices so you have the same parts from sda and sdb
in all of them.
Check with ‘cat /proc/mdstat’.

Let is sync back up (check with ‘watch -n 10 cat /proc/mdstat’ until
it finishes).

Now, fix grub:
grub
grub>root (hd0,0)
grub>setup (hd0)

If you’re unlucky and can’t’ boot because the wrong device is first
(trying to boot from the clean/new hard drive), follow these steps:

First boot into a live cd with your os.
Then activate the RAID:
1) mkdir /etc/mdadm
2) mdadm –examine –scan > /etc/mdadm/mdadm.conf
3) mdadm -A –scan

Then reinstall grub. In this example, you have /boot on md0 and / on md1:
1) mkdir /mnt/sysimage
2) mount /dev/md1 /mnt/sysimage
3) mount -o bind /dev /mnt/sysimage/dev
4) mount -o bind /proc /mnt/sysimage/proc
5) chroot /mnt/sysimage /bin/bash
6) mount /dev/md0 /boot
Then fix grub (same as above):
grub
grub>root (hd0,0)
grub>setup (hd0)

Voila, you have a working raid again with grub managing to boot your system 🙂

hw.no/panda/adblock

08/05/2012
Panda

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

Jeg skjønner at hardware.no 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å hardware.no og medfølgende tekst borte vekk…

http://userscripts.org/scripts/show/131494

Android 4 and Calendar crash

04/19/2012

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

01/20/2012

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:
http://askubuntu.com/a/71551/42842

1) Make a volumetoggle.sh 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 volumetoggle.sh

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

Voila.

 

Cutting bits from avi-file with ffmpeg/mencoder

01/14/2012

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
least).

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


%d bloggers like this: