Archive for December, 2007

Ralink RT61 Wireless PCI and Kubuntu

December 30, 2007

It has always been a pain in the ass to get the wireless card with a Ralink RT61 chipset to work with Linux. Here’s how it worked for me.

  1. Edit /etc/modprobe.d/blacklist
    and add
    “blacklist rt61pci”
    “blacklist rt2x00pci”
    “blacklist rt2x00lib”
  2. Download and install ndiswrapper
  3. Download the Windows driver (you need the rt61.inf)
  4. “ndiswrapper -i rt61.inf”
  5. “ndiswrapper -l” checks the status
  6. “modprobe ndiswrapper”
  7. Configure your interface in /etc/network/interface
  8. If you want to start ndiswrapper at boot time add “ndiswrapper” in a line to /etc/modules

That’s it.

Data Loss after Copying to USB Stick

December 30, 2007

Sometimes, after I copied files to my USB stick with Kubuntu Linux, the data was corrupted. Furthermore, the copying process seemed far to quick for USB 1.0. In order to make sure that all your data gets copied, change to the directory where to USB stick is mounted, e.g. /mnt/stick/ and use the “sync” command. sync will flush the file system buffers. After sync has finished, you can unmount the stick and all the data should be on it.

Gutsy Upgrade: No More DVD Playback in Kaffeine

December 27, 2007

I could not play DVDs anymore after installing Kubuntu Gutsy Gibbon (7.10). I always got a message “xine: couldn’t find demux for >dvd:///dev/scd0<“. In this forum I found people with the same problem. Apparently, installing the “libxine1-ffmpeg” library does the trick. This can be done easily: “aptitude install libxine1-ffmpeg“.

Can I restart a thread in Python?

December 20, 2007

Have you ever got something like: 

File “threading.py”, line 410, in start

    assert not self.__started, “thread already started”

AssertionError: thread already started
?
 
It means that Python is complaining because you are trying to call the start() method on a thread more than once. This is not possible, so each time you want a thread object to start, you have to recreate the object. 
 
From the Python documentation:
start()
Start the thread’s activity.
This must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control. 

capture an audio stream

December 19, 2007

mplayer -playlist <stream> -ao pcm:file=mystream.wav -vc dummy -vo null

i.e.

mplayer -playlist http://www.bbc.co.uk/radio4/realplayer/media/fmg2.ram -ao pcm:file=mystream.wav -vc dummy -vo null

python: copy by reference, copy by value, shit it depends on what you copy!

December 19, 2007
class MyClass:                                                                  
    def __init__(self):                                                         
        self.__data = []                                                        
        self.doSomething()                                                      
    def doSomething(self):                                                      
        #[self.__buckets.append([1,2,i] ) for i in range (0,4)]                 
        [self.__data.append(i ) for i in range (0,4)]                           
    def getData(self):                                                          
        return self.__data                                                      
    def modBucket(self):                                                        
        h = self.__data[2]                                                      
        h = 5                                                                   
    def modBucket2(self):                                                       
        h = self.__data                                                         
        h[2] = 5                                                                

c = MyClass()                                                                   
print "init:", c.getData()                                                      
c.modBucket()                                                                   
print "mod1:", c.getData()                                                      
c.modBucket2()                                                                  
print "mod2:", c.getData()                                                      
print "-------------------------"                                                                               

The output of running this code is:

init: [0, 1, 2, 3]
mod1: [0, 1, 2, 3]
mod2: [0, 1, 5, 3]
------------------------ 

Notice the problem, if you ask for the whole object, you get if by reference, if you ask for a part of it, you get a copy!!!!
Haven’t yet found the logic for this, any directions welcome.

Translator bots

December 19, 2007

Google has just announced that you can add some (hopefully) useful translation bots to your gtalk contacts. The format is “[from language]2[to language]@bot.talk.google.com”, and the supported language pairs are: ar2en, bg2en, de2en, de2fr, el2en, en2ar, en2de, en2el, en2es, en2fr, en2it, en2ja, en2ko, en2nl, en2ru, en2zh, es2en, fi2en, fr2de, fr2en, hi2en, hr2en, it2en, ja2en, ko2en, nl2en, ru2en, uk2en, ur2en, zh2en. So, for French to German translation, talk to fr2de@bot.talk.google.com.Western languages are working quite well, but according to Panxueni an expert of Chinese Languages at the University College of London the Chinese translation kind of… sucks 🙂 Well, it’s still an excuse to have a laugh with your Chinese friends 🙂 

Public Key Authentication from OpenSSH to SSH

December 19, 2007

I set up public key authentication from my machine to a couple of other machines. This is quite handy since you only need to provide your passphrase once and then the ssh agent does the authentication for you. However, I could not figure out why my key was not working with a particular server until I found out that there are differences between OpenSSH and SSH. To use your OpenSSH key with an SSH server, you need to convert it first and then put it in a specific place. Here a step by step tutorial, that I found here.

  1. Change to your local .ssh directory
    cd ~/.ssh
  2. Convert your public key
    ssh-keygen -e -f id_dsa.pub > id_dsa_secsh.pub
  3. Copy this new key to the remote machine into the .ssh2 directory
    scp ~/.ssh/id_dsa_secsh.pub chris@remotemachine:~/.ssh2/
  4. SSH into the remote machine
    ssh chris@remotemachine
  5. Append information to the .ssh2/authorization file
    echo Key id_dsa_secsh.pub >> .ssh2/authorization

That’s it! From now one, “ssh remotemachine" will be enough.

A simple SSH config file

December 17, 2007

You can provide ssh with a config file if you’re connecting to many different machines with different ports, user names etc.

Create a file called “config” in your .ssh directory on your machine. This file can contain entries such as

Host Home
User chris
Port 8888
HostName chrisonline.com

Host Office
User myseriousname
Port 22
HostName machine.atwork.com

What you can do then is just type “ssh Home”and ssh will automatically pick the right user name, machine and port. This is very convenient if you have different user names on different machines. I found this information here.

How to use GAIM with G-Talk

December 16, 2007

This quick tutorial is copied from www.tech-recipes.com.

1. Open GAIM
2. From the buddy list screen, click Tools
3. Then click Accounts
4. Click the Add button
5. Select Jabber as the protocol
6. Your screen name is your gmail login. (For example, login@gmail.com)
7. Server is gmail.com
8. Resource is Gaim
9. Your password is your gmail password.
10. Select as alias what you want to be called on your IM screen. If you leave this blank, it’ll use your whole gmail address which is way too big for your little IM screen. If nothing else, just put in Me in the alias box.
11. Click Show More Options
12. Select the Use TLS if available checkbox
13. As you connect server type: talk.google.com
14. Click Save