The last week in Hong Kong

The last week in Hong Kong has started. It feels sad to leave this place just as the summer finally hits Hong Kong after a very moist and cloudy spring. It’s been a terrific year abroad and I don’t really see how I will adapt to the Swedish life again. The food, climate, beautiful surroundings, and one of the biggest, most alive, mega-cities on this planet. Returning to small Gothenburg will be interesting to put it gently.

The campus and environment surrounding the school is one of a kind and to have such a place next to Hong Kong is incredible.

Putting Chrome’s cache in the ram

The Chrome web browser is changing the way we browse with it’s speed and focus on content. But, it’s killing my laptop’s battery and hard drive with its constant reading and writing to disk.

Luckily, Linux has a folder mounted in the ram, which means that reads and writes to this folder don’t affect the harddisk (it’s also about two orders of magnitude faster than my notebook disk). The downside is that the data disappears when the power goes out. That folder is most often called /dev/shm/ and I wanted to put Chrome’s cache in this folder, to avoid the constant writing to disk. But I wasn’t prepared to lose all my preferences, extensions, and saved data when the computer was powered down. So I wrote this script that copies the folder from /dev/shm/ mounted in the ram to the disk and this script runs whenever I exit Chrome.

This is how I put Chrome’s cache in the ram

mkdir /dev/shm/.personal_synced # The folder in ram

mkdir ~/.personal_synced # The mirrored folder on disk

I wrote this simple script that fires once every hour (I’m pretty sure it can be written in a simpler way, but I’m certainly a bash-newbie):

#!/bin/bash
# Sync the ramdisk to harddrive

foldername=”.personal_synced”
ramdisk=”/dev/shm/”$foldername
harddisk_copy=”/home/anders/”
backup=”/home/anders/”$foldername”.old”

# Remove the old backup
echo “removing $backup”
rm -fr “$backup”
# Make a copy of the old one
echo “Copies the latest backup $harddisk_copy$foldername”
mv -f “$harddisk_copy$foldername” “$backup”
# Copy from ram
echo “Copies $ramdisk to harddrive, $harddisk_copy”
cp -R “$ramdisk” “$harddisk_copy”

I want to make this sync-script fire when I exit Chrome. At first I tried to make it fire on shutdown but that proved harder than I thought. The following script synchronizes the ram-disk when Chrome exits, and I just replace the symbolic link in /usr/bin/google-chrome with this script.

#!/bin/bash
# Start Chrome with cache in the ram

/opt/google/chrome/google-chrome -user-data-dir=”/dev/shm/.personal_synced/google-chrome” “$@” && /home/anders/Scripts/syncRamdisk

All that is missing is a script that copies the disk-folder to ram when we boot our computer.

# The synced folder
cp -R /home/anders/.personal_synced /dev/shm/
chown -R anders /dev/shm/.personal_synced

# The chrome cache. I don’t want to sync this so it’s placed outside .personal_synced
mkdir /dev/shm/google-chrome
chown anders /dev/shm/google-chrome

I simply added the script to my Startup Applications, under System->Preferences.

Moving Chrome’s cache to our automatically synced folder

By moving the .config/google-chrome-folder to the synced folder, and replacing it with a symlinks, the work will be complete (I also move the cache to the ramdisk, but not to the synced folder. I see no point in spending time and space on keeping the cache):

mv ~/.cache/google-chrome /dev/shm/google-chrome
ln -s /dev/shm/google-chrome ~/.cache/google-chrome

mv ~/.config/google-chrome /dev/shm/.personal_synced/
ln -s /dev/shm/.personal_synced/google-chrome ~/.config/google-chrome

Notes:

/dev/shm/ is readable by anyone, it’s not very secure to put stuff in that folder.

Update: I adjusted the scripts, I had problems with root owning the folders which caused some problems.

Matlab and Ubuntu 10.04

Matlab 2009bWhen I started Matlab 2009b on my new install of Ubuntu Lucid Lynx (10.04) I had the problem that some keys weren’t working. Most notably, the [] didn’t work which is quite bad when writing Matlab-code. Also, the terminal outputs this message:

Warning: X does not support locale en_HK.utf8

The problem is that the locale is set to utf8 (small caps) while Matlab requires UTF-8. By specifying the locale before we start Matlab we solve the problem.

Remove the symbolic link to matlab in /usr/local/bin/matlab with

sudo rm /usr/local/bin/matlab

and create a script in its place:

sudo gedit /usr/local/bin/matlab:

and paste this as it’s content:

#!/bin/bash
# Start Matlab with the right encoding
echo “Starting Matlab with en_HK.UTF-8 coding”
LC_CTYPE=”en_HK.UTF-8″ /usr/local/Matlab2009b/bin/matlab

where you change en_HK to something that seems appropriate and is part of the list produced by locale -a. My Matlab is installed in /usr/local/Matlab2009b/.


The Korea trip

Last week we spent in (south) Korea, and although it was more expensive than the other trips we’ve made it turned out pretty good. The climate, temperatures, and general colours were very much those of Sweden during fall which wasn’t that exciting but it was very nice to get rid of the creeping moist in Hong Kong for a few days.

From the Seoul tower we had views of the mega city Seoul in all directions. Seoul is the worlds second largest metropolitan area after Tokyo and it was a mighty view at night with the lights extending to the horizons.

Seoul_view2Seoul_view1

We bicycled along the Han river and got some nice views of Seoul:
Seoul_riverSeoul_flowerSeoul_temple

We’ve had so much good food like bibimbap, Korean barbecue, and some special mix between Italian and Korean cuisine. We also tried live octopus (chewy as hell), silkworms (I don’t recommend it), and dog (I didn’t try the dog).
Seoul_food

When being a westerner in Asia and maybe even as tall as Richard or blond like me you usually attract some hidden or not-so-hidden looks from the people you meet. But in Korea we almost felt ignored had it not been for a group of girls:
Seoul_girls

Thoughts on different travel agencies

After a few trips (Sweden-Hong Kong round-trip, Sweden-New York, New York-Chicago, Chicago-Hong Kong and several trips in Asia) and much researching for the cheapest trips (I am but a student) some patterns begins to emerge.

Basically there are a few travel agencies that stand out:

  • Kilroytravels (for students)
  • STATravel (for students)
  • Orbitz
  • Ctrip

Kilroytravels have a very nice interface and searching is fast and easy. I especially like the auto-suggestion of airports or cities that all other search engines seem to lack. The engine seems to handle very diverse airlines and for many of them, Kilroy can sell you special student tickets that are cheaper and versatile in their re-booking rules. The prices are often very competitive but I recommend doing the same search over a few hours or days since they vary for some reason. This travel agent has been my choice for all of my inter-continental travels.

Orbitz is not unusual in any particular way, it searches for tickets all over the world as far as I’ve seen. The interface is acceptable but the way the airport search is built is uncomfortable *cough* Look at Kilroy’s implementation *cough*. For international travel, the prices are not bad at all but the tickets are normal tickets and for most of the time set in stone. No student versions. I did use Orbitz for domestic flights in the States, where it seems to excel. Kilroy did not handle those searches very well.

Ctrip is the de-facto standard for travels inside Asia. We have used it a lot and it is a very popular choice here. Prices and website are good, but no student tickets.  It might pay off however to visit the local travel agencies in Asia since they often have very competitive prices.

STATravels is another travel agency for students. I’ve heard of other people using it, but my experience with them is non-existent. At this moment their search function doesn’t seem to work (tried both Chrome and FF) so I can’t really say anything about them.

Conclusion

  • For inter-continental travel, Kilroy have been the given choice for me, and there’s no change in sight.
  • For flights in Asia, Ctrip or the local dealer.
  • Other flights, look around in different search agents and dates.