Saturday, February 28, 2009

Sunday, February 22, 2009

LaCie NAS Drive

I recently purchased a NAS ethernet drive from LaCie. They are pretty cheap these days - about a hundred quid. I'm sick of finding out that I downloaded a particular file to my laptop rather than my desktop or whatever and this seemed like a good solution. It works flawlessly on the MacBook through the LaCie provided software. Less so, with the openSuSe.

I ended up installing everything in yast2 that even tangentically mentioned samba or netbios. I then opened up my firewall to the fullest extent possible, sacrificed two virgins, restarted netbios and samba a couple of times and lo and behold it worked. I then switched the firewall back on with samba and netbios selected as allowed services for the external zone and it seems happy enough with that. No real lesson learned here, just black magic. This is really just a note for other to let them know that it could in theory work.

Saturday, February 14, 2009

Mirroring a mediawiki to another server

There are lots of good guides on the interwebs on how to do this but I wanted to get a few notes down so I remember my preferred/installed method. These instructions are for Debian/Ubuntu and assume the target server doesn't have an existing mediawiki or mysql installation. All this needs to be done as root.


1. Install mediawiki on the target server, install the same version.


2. Delete /var/lib/mediawiki1.7 on the target server.


3. Dump the mysql permissions database on the source server:



mysqldump -u root -pYOURPASSWORD --opt mysql > ~/mysql.sql


4. Copy that file over to the target file. Import it using the following command.



mysql -pYOURPASSWORD -h 127.0.0.1 mysql < ~/mysql.sql


5. Setup a cron job on the source host to dump the mediawiki sql database every night. Type crontab -e to edit the crontab and add the following line:



0 0 * * * mysqldump -u root -pYOURPASSWORD --opt wikidb > ~/wikidb.sql


6. On the target host, add cron jobs to copy across the database dump, the mediawiki config/uploaded files and to import the mediawiki database. Again do crontab -e and add the following:



0 5 * * *  rsync -oglpvtr root@SOURCEHOST:/var/lib/mediawiki1.7 /var/lib > ~/backups/SOURCEHOST_mediawiki.log
0 5 * * * rsync -vtr root@SOURCEHOST:/root/wikidb.sql ~/wikidb.sql
0 6 * * * mysql -pYOURPASSWORD -h 127.0.0.1 wikidb < ~/wikidb.sql



Protip: you'll need your ssh keys setup so you can do passwordless authentication.

The Viterbi algorithm

For your viewing pleasure I present an implementation of the Viterbi algorithm. I implemented this to help me understand the algorithm as presented in "Biological Sequence Analysis" by Durbin et al. The code solves the "occasionally dishonest casino, part 2". The example displays the output as copied from the book as well as it's own calculation so you can verify the results.


Code here

Wednesday, February 4, 2009

tkz-graph example (A latex graph drawing package)

This blog post has moved here

PGF and tkz-graph installation in Ubuntu

Ubuntu likes to keep it's texlive packages at least a year out of date, so if you want to install tkz-graph you need to install it and pgf manually. Create a directory called texmf in your home directory (mkdir ~/texmf). Create a subdirectory called tex (mkdir ~/texmf/tex). Create subdirectories of this called generic and latex. From the pgf tarball copy pgf-2.00/generic into the generic subdirectory. Copy pgf-2.00/latex to the latex subdirectory (you now have ~/texmf/generic/pgf and ~/texmf/latex/pgf. Download the tkz-graph style (tkz-graph.sty) and copy it to ~/texmf/latex. I copied it to ~/texmf/latex/prof I don't think that matters... Next "sudo texhash". That should do it.

Tuesday, February 3, 2009

Download a bunch of papers from a journal

Say you want to download a bunch of pdf files from a webpage. You want to do this remotely over ssh so those cool firefox extensions are our of the question. Use wget. For example:

tsocks wget -r -l1 -t1 -N -A.pdf -erobots=off http://www.springerlink.com/content/x49g43t85772/ 


Does the job.

Openmoko freerunner with vodafone DE sim card

Just a note to mention for anyone curious that I managed to get a 3G german vodafone sim working with OM 2008.12 by flashing the gsm firmware to moko10. Whilst the wiki advises using shr I found it didn't make any difference. Still have to test this with 3 cards from the UK but hopefully some of them will work now too.

Silc client won~t accept the / (backslash) key

I use silc as a replacement for things like irc. Most of the time I think its great. It provides secure and simple encryption and allows me to waste time instead of actually working. Well that last bit is a tad unfair as I learn a lot of things on there.

Anyways, for the last while, it has been impossible for me to enter the backslash character in a session. This is regardless of the keyboard layout on the client computer, the OS and was a seemingly random error. Today I erased the .silc/silc.conf file and restarted the silc client. Success - I am now able to connect to the server once again. The most infuriating aspect of this is that the error occured during a running session. When I copied urls into that session none of the slash characters would be displayed on the screen. Which was funny at first but very annoying once I restarted silc only to discover that I couldn't now type /connect. Which was funny for about 30 seconds. So there you go. If you are ever in the situation where you can't enter the slash key in a silc client just remove the configuration file.

Replacing a string in vim to fix an dxf file

I have an DXF file that has entries that look like this:

LCD.1
70
64
62
150
6
CONTINUOUS
0
LAYER
2
LCDMOUNT.1
70
64
62
252
6


Autocad doesn't like this file... I have no idea what created it. After much screwing around I've discovered that it doesn't like the "."s in the entity (or whatever they're called) names. Load the file in vim and use the following regexp to get rid of the dots.

%s/\([A-Z]\)\.\([0-9]\+\)/\1\2/g


Fixed file looks like this:

LCD1
70
64
62
150
6
CONTINUOUS
0
LAYER
2
LCDMOUNT1
70
64
62
252
6


FYI, the \( \) are delimiters in the search sequence. \1 and \2 reference back to these.

Addition: The file in question was produced by a program called "Camera 3D" or "3D Camera" or something... Just in case anyone else has the same problem with this code.