my emacs printing variables in linux

23 February 2010

added to .emacs

# this sets double side, two pages per sheet and header with the filename and page number and date

(setq ps-end-with-control-d nil)
(setq ps-font-size (quote (8 . 10)))
(setq ps-line-number t)
(setq ps-line-number-color 3)
(setq ps-lpr-command “lpr”)
(setq ps-lpr-switches (quote (“-oDuplex=DuplexNoTumble”)))
(setq ps-n-up-printing 2)
(setq ps-paper-type (quote a4))
(setq ps-print-header t)
(setq ps-print-header-frame nil)
(setq ps-printer-name “ricohcolour1”)

updating firefox to 3.6 on Jaunty (ubuntu 9.04)

19 February 2010

After downloading firefox 3.6 it has no instructions how to install it. When I google for it, the top pages tell you about installing through apt adding the ppa sources for firefox

But all this is not necessary, you can uncompress the firefox download in your home (for example in ~/home/bin/firefox3.6) and double click in firefox file. This is a shell script that run firefox from the current working dir (it invokes But be sure that you have quit your older firefox. If not when you double click on the firefox file, it will open a new window for your older firefox.

runlevels in ubuntu

3 February 2010

Ubunto has a different concept for runlevels than redhat (ubuntu always starts the Xs). Here there is a blog entry how to make ubuntu runlevels like redhat.

Sound with fluxbox in non-intel ibook and alsamixer

3 February 2010

I had no sound with fluxbox in the speakers. This was a good thing. This has given me the opportunity of rediscovering the text GUI for alsamixer.

Definitively I like text GUIs. They are clever and conceptually more challenging to create than the graphical GUI.

I think that an only-text environment is the final step in the evolution of GUI for power users. Screen multiplexer, emacs -nw, myriads of keybindings for the windowmanager. If I ever remember again how to copy paste between virtual displays I will start to use runlevel 3 again and achieve the nirvana ;-).

flymake for perl syntax checking on the fly in emacs

3 February 2010

If you are tired of M-! perl -wc myscript for syntax checking, there fancy minor mode: flymake for syntax checking on the fly while programming in emacs

Here is a video how it works:

and a warning from Merlin:

beware perl -c on unknown code

by merlyn (47) <> on 2006.11.07 22:43 (#51498)
( | Last Journal: 2007.09.21 11:04 )
All I have to do now is send you a perl script to “look at” that contains:

BEGIN { system 'rm -rf $HOME' }

and hope that you look at it in your editor. That flymake code will nicely execute that system operation. Oops!

  • Randal L. Schwartz
  • Stonehenge

Mysql cheatsheet

3 February 2010

– mysql cheat sheet

Selecting a database:

  mysql> USE database;

Listing databases:


Listing tables in a db:

  mysql> SHOW TABLES;

Describing the format of a table:

  mysql> DESCRIBE table;

Creating a database:

  mysql> CREATE DATABASE db_name;

Creating a table:

  mysql> CREATE TABLE table_name (field1_name TYPE(SIZE), field2_name TYPE(SIZE));
  Ex: mysql> CREATE TABLE pet (name VARCHAR(20), sex CHAR(1), birth DATE);

Load tab-delimited data into a table:

  mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table_name;

(Use \n for NULL)

Inserting one row at a time:

  mysql> INSERT INTO table_name VALUES ('MyName', 'MyOwner', '2002-08-31');

(Use NULL for NULL)

Retrieving information (general):

  mysql> SELECT from_columns FROM table WHERE conditions;
  All values: SELECT * FROM table;
  Some values: SELECT * FROM table WHERE rec_name = "value";
  Multiple critera: SELECT * FROM TABLE WHERE rec1 = "value1" AND rec2 = "value2";

Reloading a new data set into existing table:

  mysql> SET AUTOCOMMIT=1; # used for quick recreation of table
  mysql> DELETE FROM pet;
  mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table;

Fixing all records with a certain value:

  mysql> UPDATE table SET column_name = "new_value" WHERE record_name = "value";

Selecting specific columns:

  mysql> SELECT column_name FROM table;

Retrieving unique output records:

  mysql> SELECT DISTINCT column_name FROM table;


  mysql> SELECT col1, col2 FROM table ORDER BY col2;
  Backwards: SELECT col1, col2 FROM table ORDER BY col2 DESC;

Date calculations:

  mysql> SELECT CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(date_col)) AS time_diff [FROM table];
  MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day.

Pattern Matching:

  mysql> SELECT * FROM table WHERE rec LIKE "blah%";

(% is wildcard – arbitrary # of chars)
Find 5-char values: SELECT * FROM table WHERE rec like “_____”;
(_ is any single character)

Extended Regular Expression Matching:

  mysql> SELECT * FROM table WHERE rec RLIKE "^b$";

(. for char, […] for char class, * for 0 or more instances
^ for beginning, {n} for repeat n times, and $ for end)
To force case-sensitivity, use “REGEXP BINARY”

Counting Rows:

  mysql> SELECT COUNT(*) FROM table;

Grouping with Counting:

  mysql> SELECT owner, COUNT(*) FROM table GROUP BY owner;

(GROUP BY groups together all records for each ‘owner’)

Selecting from multiple tables:


  mysql> SELECT, comment FROM pet, event WHERE =;

(You can join a table to itself to compare by using ‘AS’)

Currently selected database:


Maximum value:

  mysql> SELECT MAX(col_name) AS label FROM table;

Auto-incrementing rows:

  mysql> INSERT INTO table (name) VALUES ("tom"),("dick"),("harry");

Adding a column to an already-created table:

  mysql> ALTER TABLE tbl ADD COLUMN [column_create syntax] AFTER col_name;

Removing a column:

  mysql> ALTER TABLE tbl DROP COLUMN col;

(Full ALTER TABLE syntax available at

Batch mode (feeding in a script):

  # mysql -u user -p <>

(Use -t for nice table layout and -vvv for command echoing.)
Alternatively: mysql> source batch_file;

Backing up a database with mysqldump:

  # mysqldump --opt -u username -p database > database_backup.sql

(Use ‘mysqldump –opt –all-databases > all_backup.sql’ to backup everything.)
(More info at MySQL’s docs.)

my CVS default options

3 January 2010

I have all my code now in svn or git, so, in order to remember my cvs defaults for projects that still use cvs (eg. EnsEMBL), these are my defaults:

cvs -z3
diff -Nu
update -Pd
checkout -P

This example says:

  • always use compression level 3 when talking to a remote server. This is a life-saver when working over a slow connection.
  • always use the -N (show added or removed files) and -u (unified diff format) options to diff(1).
  • always use the -P (prune empty directories) and -d (check out new directories) options when updating.
  • always use the -P (prune empty directories) option when checking out.

emacs and unicode links

3 January 2010

Xah Lee, 2006-07, …, 2009-08-12, 2009-12-06

This page gives some tips about using emacs and unicode. If you work in 2 languages, or type a lot math symbols, you’ll find this page useful.

Emacs manual for coding systems

MySQL alternatives from MySQL

3 January 2010

Monty Widenius, after the selling of MySQL AB to SUN started a company “Monty Program Ab”, and released a new MySQL engine: MariaDB (following his tradition of naming his programing childs after his biological ones)

One of the pourposes of MariaDB is t0 counteract the side effects of InnoDB being under the control of ORACLE, and provide a “crash-safe alternative to MyISAM” and for Maria2.0 “A fully transactional storage engine with at least all of InnoDB’s major features.”

Also there is an GPL2 alternative to InnoDB: percona-xtradb (from an independent company)

“Percona XtraDB is an enhanced version of the InnoDB storage engine, designed to better scale on modern hardware, and including a variety of other features useful in high performance environments. It is fully backwards compatible, and so can be used as a drop-in replacement for standard InnoDB.”

Oracle buying Sun, therefore adquiring MySQL!!!!!

3 January 2010

Oracle is buying SUN. But because SUN holds MySQL, there is a problem of competency and the European Commission is looking closely the acquisition to guaranty that the market diversity for databases is similar before and after the merging.

Monty (the creator of MySQL) thinks that Oracle will kill MySQL in the long run and also thinks that  this was its first motivation when buying SUN: get rid off an annoying competitor. Therefore he started a big campaign to show to the EC that Oracle’s movement is a thread to MySQL development:

Monty Widenius, in early Dicember 2009 asked for people using MySQL to write to EC in order to prevent oracle to acquire MySQL unconditionally. He ask for several points not addressed in the oracle ‘promises’:

Oracle has NOT promised (as far as I know and certainly not in a legally binding manner):

– To keep (all of) MySQL under an open source license.
– Not to add closed source parts, modules or required tools.
– To keep the code for MySQL enterprise edition and MySQL community edition the same.
– To not raise MySQL license or MySQL support prices.
– To release new MySQL versions in a regular and timely manner. (*)
– To continue with dual licensing and always provide affordable commercial licenses to MySQL to those who needs them (to storage vendors and application vendors) or provide MySQL under a more permissive license
– To develop MySQL as an Open Source project
– To actively work with the community
– Apply submitted patches in a timely manner
– To not discriminate patches that make MySQL compete more with Oracles other products
– To ensure that MySQL is improved also in manners that make it compete even more with Oracles’ main offering.

From looking at how Oracle handled the InnoDB acquisition, I don’t have high hopes that Oracle will do the above right if not required to do so:

For InnoDB:
– Bug fixes were done (but this was done under a contractual obligation)
– New features, like compression that was announced before acquisition, took 3 years to implement
– No time tables or insight into development
– The community where not allowed to participate in development
– Patches from users (like Google) that would have increased performance was not implemented/released until after Oracle announced it was acquiring Sun.
– Oracle started working on InnoDB+, a better ‘closed source’ version of InnoDB
– In the end Sun had to fork InnoDB, just to be able to improve performance.

Monty says that when he sold MySQL to Sun there was a trap clause that he didn’t fully understood  at that time:

About MySQL Workbench 7; I always wanted MySQL AB to only produce Open Source code. I had in my shareholder agreement a clause that ensured that the MySQL server should always be fully open source (no commercial modules) until MySQL AB would be sold. (Note that it’s impossible to get an agreement from investors that would protect the code after the company is sold). Unfortunately, the clause was written in such a way that it did not protect other programs (I did not understand this at the time I signed the contract). For a long time I manage to fight off any attempt from the management for closed source programs until they finally went over my head and created some of the new tools as closed source programs. I, and many other developers in MySQL AB, always thought that was a bad idea and we still think that way!

And a better Monty’s explanation of the process of MySQL being sold to SUN and how the agreement of MySQL being open source get jeopardized when it was sold to SUN could be found here. :

Q: Didn’t you sell MySQL to Sun? Do you want to have the cake and eat it too?

First a little background:

I started to work on a code that would later become MySQL in 1982. MySQL was released in 1995 under a dual licensing scheme that allowed David Axmark and me to very quickly work full time on developing MySQL.

I lost the rights to the MySQL copyright in 2001 when MySQL AB was created and we allowed investors to come in. We needed to bring in investors to be able to create a full-scale working company to satisfy big customers and to be able to hire more developers and take MySQL to the next stage. To ensure that MySQL would continue to be free, David and I stated in the shareholder agreement that MySQL AB would have to keep MySQL under an open source license. The problem with a shareholder agreement is that it is terminated when the company is sold. This is just how things works.

David and I however thought that this would not be a problem, as we would help ensure that MySQL would be bought by a good owner.

I continued to lead the MySQL project and have been one of the leaders and top contributors for the project since then.

When the sales process to Sun started, I was at the time not anymore in the MySQL Board (just a MySQL shareholder). I was just informed about the deal, after it was agreed to. I did get money for my shares, that is true, but it did not change in any way my dedication or involvement in the MySQL project.

Also another problem is that although MySQL is GPL the manuals aren not!!!. And not the name either nor the ‘defensive’ IPR filled.