19 August 2011

$ cat file | grep ^[^#] to view file without comments

$ cat .bashrc

#source /etc/profile

extract () {   if [ -f $1 ] ; then      case $1 in...

$ cat .bashrc | grep ^[^#]

extract () {   if [ -f $1 ] ; then      case $1 in...


change your default editor with sudo update-alternatives --config-editor http://goo.gl/x6F1b

$ sudo update-alternatives --config editor

16 August 2011

locate an installation directory with whereis

quick crop images with shotwell photo viewer

my google-chrome extns: adblock plus, context menu search, plus minus and shareaholic

After removing a large number of Google Chrome extensions I really didn't need, I was left with the following 4 essentials. Each of them save me time and effort when browsing (and submitting the occasional web post).

Adblock Plus
If I see a sponsored link to something that sparks my interest I always click it, particularly if I have landed on the page and found something useful. I do however take exception to flash and other animated effects that distract me from reading or poorly marketed advertisements that have almost nothing to do with the page content. Generally these are on pages that will get few revisits from me in any case. Mostly I keep this extension around out of habit I guess.

Context Menu Search
I have been using some form of context search in Firefox and Chrome for nearly 10 years now. I have become very accustomed to defining words, locating online videos and so on, in this manner. My only requirement is that the menu remains refined and search functions can be added easily. The last extension I used Context Search (a different extension) achieved this but I was never comfortable with the user interface. So I am trying Context Menu Search instead which integrates properly with the existing browser context menu: as I think it should.

Plus Minus
I am still assessing this extension. It adds some features to Google Plus that I require: most importantly customizing my stream. There is also a feature to adjust the layout to make better use of view able space. So far it is proving to be worthwhile.

This extension is a time-saver when authoring weblog posts as it provides access to a url shortener, posting interface and sharing tools all from one drop-down menu. The dev team appear to be working to add support for google plus which will be helpful.

15 August 2011

generate passwords with pwgen

Install pwgen in ubuntu 11.04 with:
sudo apt-get install pwgen
excerpt from man pwgen - generate pronounceable passwords
pwgen [ OPTION ] [ pw_length ] [ num_pw ]

The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memorable passwords are never going to be as secure as completely completely random passwords.

The pwgen program is designed to be used both interactively, and in shell scripts.

Used interactively, pwgen will display a screenful of passwords, allowing the user to pick a single password, and then quickly erase the screen. This prevents someone from being able to "shoulder surf" the user's chosen password.

When standard output (stdout) is not a tty, pwgen will only generate one password, as this tends to be much more convenient for shell scripts, and in order to be compatible with previous versions of this program.


-0, --no-numerals Don't include numbers in the generated passwords.
-A, --no-capitalize Don't bother to include any capital letters in the generated passwords.
-B, --ambiguous Don't use characters that could be confused by the user when printed, such as 'l' and '1', or '0' or 'O'. This reduces the number of possible passwords significantly, and as such reduces the quality of the passwords. It may be useful for users who have bad vision, but in general use of this option is not recommended.
-c, --capitalize Include at least one capital letter in the password. This is the default if the standard output is a tty device.
-N, --num-passwords=num Generate num passwords. This defaults to a screenful if passwords are printed by columns, and one password.
-n, --numerals Include at least one number in the password. This is the default if the standard output is a tty device.
-s, --secure Generate completely random, hard-to-memorize passwords. These should only be used for machine passwords, since otherwise it's almost guaranteed that users will simply write the password on a piece of paper taped to the monitor...
-v, --no-vowels Generate random passwords that do not contain vowels or numbers that might be mistaken for vowels. It provides less secure passwords to allow system administrators to not have to worry with random passwords accidentally contain offensive substrings.
-y, --symbols Include at least one special character in the password.

try a command line screenshot app with sudo apt-get install scrot

Install scrot in ubuntu with:
sudo apt-get install scrot
Some scrot usage details. (To see the complete list see man scrot):


-b, --border When selecting a window, grab wm border too
-c, --count Display a countdown when used with delay.
-d, --delay NUM Wait NUM seconds before taking a shot.
-e, --exec APP Exec APP on the saved image.
-q, --quality NUM Image quality (1-100) high value means high size, low compression. Default: 75. (Effect differs depending on file format chosen).
-s, --select Interactively select a window or rectangle with the mouse.

Special Strings 

Both the --exec and filename parameters can take format  specifiers that are expanded by scrot when encountered. There are two types of format specifier. Characters preceded by a '%' are interpretted by strftime(2). See man strftime for examples. These options may be used to refer to the current date and time. The second kind are internal to scrot and are prefixed by '$' The following specifiers are recognised:

$f image path/filename (ignored when used in the filename)
$n image name (ignored when used in the filename)
$s image size (bytes) (ignored when used in the filename)
$p image pixel size
$w image width
$h image height
$t image format
$$ prints a literal '$'
\n prints a newline (ignored when used in the filename)

scrot '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/shots/'
This would create a file called something like 2000-10-30_2560x1024.png and move it to your ~/shots directory.

to show menus in ubuntu screenshots set a delay in 'applications' 'accessories' 'take a screenshot'

create transparent menus with compiz

  1. Install CompizConfig Settings Manager (I usually install the Compiz extra plugins as well). In a terminal:
  2. sudo apt-get install compizconfig-settings-manager compiz-plugins-extra
  3. Open CompizConfig Settings Manager from the "System" > "Preferences" menu.

  4. Open the Accessibility" section. Find the "Opacity Brightness and Saturation adjustments" selection.
  5. Under "Window specific settings", click new.
  6. In the "Windows" field enter:
  7. type=Tooltip | Menu | PopupMenu | DropdownMenu
  8. Set "Window values" slider to the desired transparency level. I use "89".

Make sure not to set the transparency level too low to begin with. If you make any error in the "Windows" field it is possible to make all of your desktop elements invisible (I speak from experience!) If this does happen you can undo your changes after killing compiz either with the run dialog (Alt+F2) or via another login console (Ctrl+Alt+F2).

change window control button order and position in gnome

This is an old tip. Customize the position and order of the gnome window control buttons in ubuntu:
  1. Select "Applications" > "System Tools" > "Configuration Editor". (Alternatively you can hit Alt+F2 to bring up the 'Run' dialog and type in "gconf-editor")
  2. Select "Apps" > "metacity" > "general".
  3. Edit the setting "button_layout". The allowed entries that I know of are "minimize" "maximize" "close" "menu" separated by a comma ",". A colon ":" indicates the middle of title bar: anything to the left will be on the left of title bar and vice versa.
If you know of any other settings please comment.

14 August 2011

get your ip address with curl http://ifconfig.me/

upgrade to gimp 2.7.3 in ubuntu 11.04

Try the gimp 2.7.3 in Natty Narwhal with:
sudo apt-get remove gimp
sudo add-apt-repository ppa:matthaeus123/mrw-gimp-svn
sudo apt-get update
sudo apt-get install gimp
This is a development version so don't expect everything to go perfectly (although it did for me).