Pimping the laptop with a Solid State Drive

Intel Solid State diskSome week ago my laptop complained while trying to save a file that there was some error writing to the disk. I had two choices – wait until the harddisk breaks, preferably when I am overloaded with work and a deadline is coming up (that is a law of nature). Or I could buy a new disk now and replace it before disaster happens. I choose the not so adventurous way and decided to do something about it now.

I’ve been glancing at the dropping prices of Solid State Drives as they are faster than mechanical and probably lasts longer. My choice fell on the Intel X25-M 2,5″ 80 GB SSD SATA/300 MLC 34 NM from the swedish supplier called Dustin. I must mention the super quick delivery Dustin (in assistance by the swedish post) had. I ordered the device late tuesday night in their web shop. Wednesday morning around 10 i got the delivery note by mail. At 13.00 the very same the delivery guy rang my doorbell. That is impressive!

The installation was easy. Just unscrew the drive bay, uninstall the old harddisk and replace it with the SSD. Be sure not to touch the connectors of the SSD disk as it is sensetive to electric discharge. I partitioned the disk with dualboot running Ubuntu 10.04 LTS in one and Windows 7 in the other. Boot time is impressive as you can see in the videos. My laptop has a new life!

Canon Powershot G9 user friendly translation for disabling sound

Canon Powershot G9 sound offThis translation train wreck has somehow slipped through Canon quality check. The menu is in Swedish and controls sound effects of the camera. Instead of just writing Sound (“Ljud” in Swedish) with the selection On or Off the translator wrote “Ljud av” which backtranslates to “Sound off”. In order to disable the sound you should set “Sound off” to on. Why make it easy? 🙂

mysqldump to multiple files

It is a good idea to run mysqldump by cron to regurlarly make backups of your MySQL databases. An easy way to do this is by adding the –all-databases parameter.  This way you will have a backup of all your databases – in one file though. If the amount of data and the number of databases is small this might be ok.

After the first session of restoring just one database or one table from your one-file-backup you realize that it would be nice to have the dumps split up in some convenient way. Like dumping each database to one file, one for each database.

This little shell script does the trick for you. It is really simple and has no error handling what so ever. It is released under GNU GPLv2 license. If you modifiy it or add features (like error handling or so), please do send me a copy or post it as a comment here.


#!/bin/sh
# mysqldump-multi.sh
# Copyright HelTech Communication, Stefan Helander 2010
# stefan@heltech.se, http://www.heltech.se
#
# Licensed under GNU GPLv2
#
# Dumps all MySQL databases. Each database stored in a single file.
#
# settings

DUMPDIR=/root/mysql-backup/backups
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASS=YOUR-PASSWORD-HERE
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump

# dump each db

for DB in `echo 'show databases' | $MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS --batch -N`
do
$MYSQLDUMP -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS --quote-names --create-options --force $DB > $DUMPDIR/$DB.sql
done

Prestashop 1.2.x not showing Categories box

Problem: In the front system (FS) Prestashop is not showing the Categories box. In the back system (BS), clicking on the Catalog tab shows just a blank page, or an error message saying the page is unavailible. The probable reason is that your Home category is missing or messed up. The problem is that you can’t get into the Catalog tab in the backend system to fix it. I ended up in this situation by trying to import categories as a CSV (comma/semi colon separated file) and I had a category in that file with ID = 1. Category ID number 1 is reserved for the Home category. Prestashop did not filter this or issue a warning during the import. So take it from me – do not try to import a category with ID = 1. Prestashop table ps_category in phpmyadminSolution: I opened my database with phpmyadmin and went to the ps_category table. The row for id_category 1 was messed up and by comparing it to a backup I set it to: id_category = 1, id_parent = 0, level_depth = 0, active = 1. The dates I left as they were. Then I went into the table ps_category_lang and made sure that there were entries for id_category 1 for all languages that I had installed (I had two in my system). Voila, back and front system now works. By adjusting the ID:s in my category import file (making sure no ID was 1) it worked like a charm to import it.

FON 2.0n router sharing 3G over Wifi

When you’re travelling as a professional nerd, you regularly needs to access the Internet. Internet cafés can be expensive and 3G… don’t think about using it abroad. It ususally costs a fortune.

I joined the FON network where you share your broadband connection at home to other FON-users and in return you are able to use the 1.5 million (and growing) FON hotsposts around the world for free.

In 2009 FON launched a new router, the FON 2.0n. It is packed with features (to read more about it, see FONs website), but most important is the USB port where it is possible to attach a 3G device. This enables you to share your 3G internet connection over the FON 2.0n wifi router. I usually bring this router on trips where I need to share my 3G internet connection to several computers over Wifi.

Read more

ASCII animated Star Wars movie

Star wars ASCII movie

To see it, you need a telnet client installed. In Linux and Microsoft Windows previous to Vista a telnet client is built in (obviously Microsoft figured no-one uses telnet anymore in Vista).

To see the movie, just do telnet towel.blinkenlights.nl

In Windows XP, click Start and then Run and type the line above in the run-command window. Then click OK.

Vivotek PT7137 network camera connection problems

Vivotek PT7137I use the Vivotek PT7137 network camera connected through wifi/wlan to my network. Even though it is located only 7 meters from my accesspoint (with a couple of walls in between) the camera lost connection once in a while. And it wouldn’t reconnect unless I rebooted the camera. Upgrading to the latest firmware (v2.6 2009-04-14) didn’t improve either.

At the time my accesspoint was a DLINK DI-624+ broadband router and before I had time to dig into the problem any further, the DLINK passed away permanently and I got myself a Linksys WRT54GL which I pimped with Tomato. Now I had much better control over the wireless environment. I could boost the output on my Linksys to 80 mW (from the original 42) and the wireless survey helped me select a good channel with as little interference with my neighbours as possible. This helped a bit – the loss of connection occured more seldom. But they did still occur.

External WLAN antennaFinally I bought a small external antenna for the Vivotek in my local computer store. It has a 5 dB gain and a magnetic mount so I could move it around without moving the camera. This finally solved my problems and my camera haven’t lost it’s connection in months.

I still haven’t found the reason to the loss of connection. 7 meters should be no problem in a wifi/wlan environment. All other gadgets I connect through the same wireless network works without any problems. Possibly my Vivoteks wireless is broken or something in Vivoteks implementation makes it really sensetive to interference? I don’t know and honestly, I will not spend more time on it unless it causes me a problem again.

PHP htmlspecialchars_decode doesn’t handle nordic/german characters like å, ä and ö

The PHP functions htmlspecialchars and it’s reverse htmlspecialchars_decode only handles the following characters:

  • ‘&’ (ampersand) becomes ‘&’
  • ‘”‘ (double quote) becomes ‘"’ when ENT_NOQUOTES is not set.
  • ”’ (single quote) becomes ‘'’ only when ENT_QUOTES is set.
  • ‘<‘ (less than) becomes ‘&lt;’
  • ‘>’ (greater than) becomes ‘&gt;’

If you want to output html text containing nordic/german characters like Å, Ä, Ö and Ü in dialog boxes (popups) these characters also needs to be converted. The following PHP function does this for you:

function unhtml( $string ) {
$string = str_replace ( '&amp;', '&', $string );
$string = str_replace ( '&#039;', '\'', $string );
$string = str_replace ( '&quot;', '"', $string );
$string = str_replace ( '&lt;', '<', $string );
$string = str_replace ( '&gt;', '>', $string );
$string = str_replace ( '&uuml;', 'ü', $string );
$string = str_replace ( '&Uuml;', 'Ü', $string );
$string = str_replace ( '&auml;', 'ä', $string );
$string = str_replace ( '&Auml;', 'Ä', $string );
$string = str_replace ( '&ouml;', 'ö', $string );
$string = str_replace ( '&Ouml;', 'Ö', $string );
$string = str_replace ( '&aring;', 'å', $string );
$string = str_replace ( '&Aring;', 'Å', $string );
return $string;
}

It is important that the code is saved in UTF-8 encoding (or the format your web page is using). Edit the code in for example Windows notedpad and use Save as. Now you can select UTF-8 encoding when saving the file.

Or if you are using UNIX / Linux you can use iconv to convert the file if it is not already in the correct format. First, to find out the current encoding for your file, use the file command:

$ file --mime-encoding unhtml.php
unhtml.php: iso-8859-1

Now, to convert it to UTF-8 using the iconv command:

iconv -f iso-8859-1 -t utf-8 unhtml.php > unhtml-utf-8.php

The reverse of unhtml is of course the html function:

/* Encodes specific characters for display as html */
function html($string) {
  $string = str_replace ( '&', '&amp;', $string );
  $string = str_replace ( '\'', '&#039;', $string );
  $string = str_replace ( '"', '&quot;', $string );
  $string = str_replace ( '<', '&lt;', $string );
  $string = str_replace ( '>', '&gt;', $string );
  $string = str_replace ( 'ü', '&uuml;', $string );
  $string = str_replace ( 'Ü', '&Uuml;', $string );
  $string = str_replace ( 'ä', '&auml;', $string );
  $string = str_replace ( 'Ä', '&Auml;', $string );
  $string = str_replace ( 'ö', '&ouml;', $string );
  $string = str_replace ( 'Ö', '&Ouml;', $string );
  $string = str_replace ( 'å', '&aring;', $string );
  $string = str_replace ( 'Å', '&Aring;', $string );
  return $string;
}
?>