29 January 2008

Load testing a Rails application with Tsung

First, RTFM :-) http://tsung.erlang-projects.org/user_manual.html

Installing erland and Tsung

Tsung is written in erlang and uses perl libraries to generate graphics.
sudo apt-get install -Y erlang
sudo apt-get install gnuplot-nox
sudo apt-get install libtemplate-perl libhtml-template-perl libhtml-template-expr-perl

wget http://www.process-one.net/downloads/tsung/1.2.1/tsung-1.2.1.tar.gz
tar xvf tsung-1.2.1.tar.gz && rm tsung-1.2.1.tar.gz
rm -R tsung-1.2.1.tar.gz && rm tsung-1.2.1.tar.gz
cd tsung-1.2.1
sudo make install

Set up Tsung

Check out the examples in /usr/share/doc/tsung/examples

Here is my
~/.tsung/tsung.xml to let your start

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21
Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Run tsung with:
tsung start

Starting the Tsung recorder

Configure your browser
If you use your machine as tsung client and also for the webserver, don't forget to remove "localhost" from the "No proxy For" textfield otherwise all requests to your web application will bypass the proxy server used by the tsung recorder!

tsung recorder
tsung stop_recorder

Then you just have to copy the xml file generated the recoreder in ~/.tsung/

Generating the html report

(make sure you have perl installed with the Template Toolkit is used for HTML reports (see http://template-toolkit.org/ . For ubuntu gutsy, there is package available

cd to the log directory of your test (say ~/.tsung/log/20040325-16:33/) and use the script tsung_stats.pl:


(use –help to view all available options)

Update rubygems to the latest version

sudo gem update --system

With Ubuntu (my version is Gutsy at the time of this writing), you will run with the problem

“uninitialized constant Gem::GemRunner (NameError)”

Take a look at http://www.nickpeters.net/2007/12/31/fix-for-uninitialized-constant-gemgemrunner-nameerror/ for the solution. I did a
sudo cp /usr/bin/gem1.8 /usr/bin/gem

You'll need the latest version of rubygems for Rails 2.0.

25 January 2008

Dual screen on Ubuntu Gutsy with Toshiba laptop Intel 945

I have been learning a lot since I started using linux ubuntu:

  • to install Dreamweaver with wine
  • to connect a network preinter with avahi and cups
  • and now I have finally managed to set up a "Dual screen" so I can be more productive
I found most of the information in the xorg xrandr wiki, it took me 1 hour but the actual set up is very simple:

  1. plug the external monitor before you swich on yout laptop and change the resolution with the GUI
  2. back up yr /etc/X11/xorg.conf and generate a fresh one with
    sudo dpkg-reconfigure -phigh xserver-xorg     
  3. Run xrandr --output LVDS --auto --left-of VGA to see the size of the virtual screen you need, it will return an error message saying your current max size and the one you need
  4. edit the /etc/X11/xorg.conf and add the magic line with virtual (don't use mine!)

Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
Monitor "Acer AL2251W"
DefaultDepth 24
SubSection "Display"
Modes "1680x1680" "1680x1050" "1600x1200" "1440x1440" "1280x1024" "1152x864" "1024x768" "832x624" "800x600" "720x400" "640x480"
Virtual 2880 1200

log out, run xrandr --output LVDS --auto --left-of VGA
and that's it! You can also put the laptop screen on the right with the option --right-of


The image “http://www.ubuntu.com/files/u1/710_displayconfig1.jpg” cannot be displayed, because it contains errors.

It doesn't work! and will break your xorg.conf :-(

Dealing with files whose status is !

subversion can be a pain in the a** !!!

If you have some files whose status is :

ghost_file.txt ! Resource is missing or incomplete (removed by another tool than Subversion) You won't be able to commit them.
The easiest hack to deal with it is to create the missing file and add it again to subversion.

pico ghost_file.txt
svn add ghost_file.txt

Time to move to git or mercurial!

21 croissants daily post 01/25/2008

Trick: Update gmail to the new interface

tags: 21croissantsblog, gmail

  • It turns out that changing gmail language from English(UK) to English(US) activated the new interface !!! Google is the champion of communication!!! I was waiting like a pinguin ...
     - post by jeanmichelg

21 January 2008

Connect a network Samsung printer connected to an airport router

1. Find the printer IP

avahi-browse --all --resolve

The output will be something like:

= eth1 IPv4 Samsung ML-2010 PDL Printer local
hostname = [Linqia.local]
address = []
port = [9100]
txt = ["ty=Samsung ML-2010" "usb_STATUS=BUSY" "usb_CLS=PRINTER" "usb_MDL=ML-2010" "usb_CMD=GDI" "usb_MFG=Samsung" "priority=5" "pdl=U" "product=(Samsung ML-2010)" "note=Linqia" "qtotal=1" "txtvers=1"]

2. Add the printer using the "Administration Printing" GUI.
Select a APPSocket / HP Jet Direct and enter the ip address in the hostname field.

3. Footomatik should already have the driver for your printer, you just have to select the model
In my case: Samsung ML-2010

09 January 2008

Learning PL/pgSQL - SQL Procedural Language

I am working on my first project with Postgres and there are a couple of stuff I wanted to document:

To install PL/pgSQL which is not installed by default (!), execute the SQL command on your db:

Otherwise you will get the error message: "ERROR: language "plpgsql" does not exist" ...

Another surprising missing feature is the inability to connect to other databases. It's not included by default in Postgres but seats in the postgres/contrib project within the funcion dblink.

To install it on ubuntu:

sudo apt-get -y install postgresql-8.2 postgresql-contrib

That's not finished! You have to run the script manually to install it.

psql -U postgres your_database_name < /usr/share/postgresql/8.2/contrib/dblink.sql

02 January 2008

Import / Export a postgres db

postgres is the database user. On ubuntu, you should run this command as the user "postgres": su postgres (password by default is 'password' !)

Dump a database into a sql script:

pg_dump database_name -Upostgres -W > ~/dump_script.sql

Restore the database from sql script:

psql -U postgres database_name -f - < dump_script.sql

01 January 2008

21 croissants daily post 01/01/2008

Ruby on Rails: Testing without the database

  • Unit Test = to test our code, not the class under test dependencies. Testing without the DB is also a good way of accelerating tests