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.)