August 7, 2012

enable hibernation in ubuntu 12.04

To enable hibernation in Ubuntu 12.04 (where it is disabled by default), add the following content to the file "/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla"
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

You may need to run update-grub and to reboot so that the hibernation option shows up in the Shutdown dialog box.

July 11, 2012

increase font size for Java

To increase the font size for Java applications, add a parameter such as "--fontsize 14" to the option list with which the application is started.

For ThinkingRock this is done by adding "--fontsize 14" to the variable called 'default_options' in the file 'tr.conf'.

July 3, 2012

printer default color mode

To change the default color mode used when printing in Linux by applications such as Firefox, run first the command "lpoptions -l | grep Color" to get the relevant options. Example output:

CNColorMode/Color Mode: *Auto color mono

To change the default color mode to 'Black & White' for ALL printers run then the following command (it can also be done on a per printer basis using the option '-p' of the command "lpoptions"):

lpoptions -o CNColorMode=mono

The color mode can be set to 'Color' when needed through the print options dialogue.

June 28, 2012

gpg file encryption

To encrypt files using gpg with symmetric cypher (i.e., password based):
gpg -c FILE_TO_ENCRYPT > ENCRYPTED_FILE

To decrypt the above file (output is stdout):
gpg -d ENCRYPTED_FILE

June 27, 2012

hibernation error in Ubuntu

Even though swap seemed to be configured properly, I experienced a hibernation error in Ubuntu:
PM: Not enuogh free memory
PM: Error -12 creating hibernation image

The solution was to execute "echo 0 > /sys/power/image_size", which instructs the OS to make the suspend image as small as possible.

June 26, 2012

exclude updates in yum

In order to prevent certain updates in yum, such as for kernels, you can add a line like this in "/etc/yum.conf":
exclude="kernel*"

By using the command "yum --disableexcludes=all update" it is possible to temporarily disable the excludes.

Note that such excludes will override those in "/etc/sysconfig/yum-autoupdate" (which is used when yum is called automatically from "/etc/cron.daily/yum-autoupdate"). IMPORTANT: This override happens even if commenting out the excludes in "/etc/yum.conf", because detection in "/etc/cron.daily/yum-autoupdate" is done based on simple grep!

June 22, 2012

add launcher to Ubuntu Unity dock

1) Create file "~/.local/share/applications/YOUR_NAME.desktop"

2) Add following entries to the file
[Desktop Entry]
Name=YOUR NAME
Comment=YOUR COMMENT
Exec=/PATH/TO/COMMAND
Icon=/PATH/TO/ICON
Terminal=false
Type=Application
StartupNotify=true

3) Drag the file to the dock (you may need to use Ctrl+H in Nautilus to show hidden files). Alternatively, log out and log in to restart Unity, but I found that this doesn't always work.

add new locale in Ubuntu

1) Check active locale with command "locale -a".

2) Add new locale for Japanese: in file "/var/lib/locales/supported.d/ja" add line "ja_JP.EUC-JP EUC-JP".

3) Regenerate locale information with command "sudo dpkg-reconfigure locales".

May 15, 2012

Speed up connection to ssh server

To speed up the connection to an ssh server, you can disable the reverse DNS lookup on the server. To do this add (edit) the following lines in "/etc/ssh/sshd_config", and restart the sshd service:
UseDNS no
GSSAPIAuthentication no

April 5, 2012

Show all log entries in svn

In order to show all log entries in svn, between the most recent commit (named HEAD), and the first revision use:
svn log -r HEAD:1

March 28, 2012

Use grep recursively but selectively

To use grep recursively in a directory structure (e.g, the current directory and all its sub-directories), but only on selected files (e.g., C source files) use the following syntax:
grep --include=*.c -r <TEXT_TO_SEARCH>

January 20, 2012

Change default print settings in Mac OS X

In order to change the default settings in Mac OS X (for example, duplex printing), it is recommended to use the CUPS web interface (since the changes seem to be impossible to save as a default via the normal print settings dialog).

You should access http://localhost:631, then the menus "Administration", "Manage Printers", then select your printer. From the pull-down list named "Administration", select "Set Default Options" and make the desired changes.

For instance, in the tab "General" set the Duplex option to"DuplexNoTumble", which is equivalent to Long-Side Binding setting in the normal print settings dialog.

UPDATE #1: On Mac OS X 10.9 the name for the duplex options has changed, and is now "Print Style" with the value "2-sided printing"

UPDATE #2: If you get as access error, you may need to enable the web interface by running the command:
> sudo cupsctl WebInterface=yes


January 12, 2012

Hide files not under revision control in svn

In order to display only the modifications of the files that are under revision control, and do not show that files that are not under revision control in svn, use the following command:
svn status -q