The Big Browser

M y    b r a i n    h u r t s  !                                           w e                 r e a l l y                 t h i n k                   w h a t                y o u             k n o w

Aug 16, 2012

Firebug Lite Bookmarklet for Internet Explorer

Firebug is what makes Firefox great, but how about other dysfunctional browsers like Internet Explorer? There is a way to use a stripped-down version of Firebug on IE, thanks to Firebug Lite.

To use it, just drag the bookmarklet above to the Internet Explorer Favorites bar.


NOTE: It might take some time to load the bookmarklet, i.e. ten, twenty seconds or even more.

Apr 14, 2012

Linux: How to export Google Chrome passwords to CSV file

Having spent some time googling for a way to export Chrome passwords to an external file to my surprise I could not find a straightforward solution that would work irregardless of the version of Chrome/Chromium. Finally I have found this page which provided the key to the solution.

Older versions of Chrome/Chromium for Linux stored unencrypted passwords in an SQLite database under:

    ### Google Chrome:
    ~/.config/google-chrome/Default/Login Data

    ### Chromium:
    ~/.config/chromium/Default/Login Data

In newer versions of Chrome this file is still present, but the passwords are not there anymore - they are stored using the encrypted password storage provided by the system, either Gnome Keyring or KWallet, which means that simply dumping the tables will not work.

The method below relies on forcing Chrome to use a temporary profile folder in combination with unencrypted password storage. This approach will not affect your current Chrome profile in any way.

So, to export your passwords to a human readable text file:

  1. Connect to your Google Account in Chrome Settings so that your passwords are synched with the Google cloud storage. Make sure that you have ticked Passwords in Advanced Sync Settings.
  2. Wait for a while until the data is synched, and then close all the Chrome windows.
  3. Start Chrome using one of the two command lines below. The easiest way to figure out whether you are using Google Chrome or Chromium is to look at the icon — Google Chrome has a green-red-yellow icon , while the Chromium icon is in shades of blue . To be absolutely sure, click the spanner icon in the top right corner and select About Chrome/Chromium.
        
    ### Google Chrome
        google-chrome --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    ### Chromium
        chromium --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    This will launch Chrome with a custom profile folder without affecting your current profile.
  4. Setup Google Synching for the new temporary profile and wait three or four minutes until everything is synced from the cloud, i.e. your bookmarks appear, extensions show up, the theme is applied, etc. Verify that the passwords are restored from the Google cloud by looking under Settings → Personal Stuff → Manage Saved Passwords. If they do not appear, then wait a couple of minutes more. Note: the fastest way to get to the stored passwords page in settings is to type password in the Search box in the top right.
  5. Exit Chrome.
  6. Next, open a terminal and change to the newly created Chrome profile
    cd /tmp/chrome-tmp/Default
    
  7. Now, open the Login Data SQLite database using the sqlite3 command line utility and dump the logins table. For this to work, you need to have sqlite3 installed on your system.
    sqlite3 'Login Data'
    
  8. Next, at the SQLite prompt enter the commands below. For help on available commands type .help at the prompt.
    .mode csv               # other options are `html', `tabs', etc.
    .headers on
    .separator ","
    .output chrome_passwords.csv
    select * from logins;
    .exit
    

Now you should have a file named chrome_passwords.csv containing all your Chrome passwords. To open it with LibreOffice, type:

libreoffice --calc chrome_passwords.csv

Jan 19, 2012

Bookmarklet for reading Android documentation in full screen

Who likes frames? Google does. At least on the Android documentation site. I am not saying that frames are necessarily evil. There are indeed cases when they are justified, especially when it comes to documentation. Nonetheless, while reading the Android development docs I wish I had the option to collapse the top and left navigation bars.

Luckily, the left navigation panel can be re-sized by dragging the vertical border separator, but there is no way to easily get rid of the top navigation bar.

The simplest solution that came to mind was to create a bookmarklet which will reformat the page in a single click.

To use the bookmarklet, click and drag the link below to the Bookmarks (Favorites) bar in your browser.


Now, whenever you are browsing a page at http://developer.android.com you can expand the documentation pane to take the full screen, by clicking the bookmark in your Bookmarks bar, or select the corresponding item in your Bookmarks/Favorites menu.

Comments and feedback are also welcome at https://gist.github.com/1640238

Jun 25, 2011

Bash: Run command on each line in a file

This script runs a user-defined command on each line in a text file. The filename should come as the first argument, everything following it will be interpreted as the command name with arguments, if any.

For example, if you have a list of file names saved to a file, and want to do something with them, e.g. see file details, you could run `foreach filelist.txt ls -alh`.

Long Version

#!/bin/bash

if [ "$#" == "0" ]; then
    echo -e "USAGE:\n    `basename $0` <filename.txt> <cmd args...>"
    exit 1
fi

list=$1

shift 1

args="$*"

while read -r line <&3
do
 echo $args $line
 eval $args $line 
done 3<"$list"

Shorter Version — the power of xargs

Things are much simplier with xargs - it will read a list of arguments from standard input and run a command on each argument. By default arguments are separated by space, but you can specify your own separator with the -d (delimiter) option.

If you work with file names you might want to use xargs -0 to specify that the parameters are delimited by the the null separator. This is useful for example when you need to correctly handle file names containing spaces or other wierd characters. To generate the parameters with the null separators you could use find -print0 to find the files matching your criteria.

Here is an example that finds all .avi files in the current folder and print detailed info using `file` utility.

find . -iname "*.avi" -print0 | xargs -0 file

But find by itself is pretty powerful and can handle this particular use case on its own without using xargs.

find . -iname "*.avi" -exec file "{}" \;
Note that there is an important difference between the two commands: the xargs-version will only run file once passing all the parameters in one go, while find -exec will run the file command multiple times for each argument, so if the program you are running takes a while to start the performance in the second case might be significantly worse.

Aug 31, 2010

Using Google Translate from console

If you have ever used Google Translate and wished you could do the same from console, here is a Python script that does just that.

The script will translate words and entire sentences between any language pair known to Google Translate. It will accept both text passed in as shell arguments, as well as data from standard input.

NOTE: This script stopped working after the translation API version 1 was discontinued on December 2011. See the updated script below for a working version.

NOTE: According to http://code.google.com/apis/language/translate/v1/reference.html
Important: Google Translate API v1 was officially deprecated on May 26, 2011; it was shut off completely on December 1, 2011. For text translations, you can use the Google Translate API v2, which is now available as a paid service. For website translations, we encourage you to use the Google Website Translator gadget.
#!/usr/bin/env python
from urllib2 import urlopen
from urllib import urlencode
import sys
import os

# The google translate API can be found here:
# http://code.google.com/apis/ajaxlanguage/documentation/#Examples

# Language codes are listed here:
#http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray

if len(sys.argv) < 3:
    name = os.path.basename(sys.argv[0])
    print '''
Usage:
    %s en es lovely spam
    %s es en < file.txt

Available language codes are listed here:
http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray
''' % (name,name)
    sys.exit(-1)

## hack to be able to display UTF-8 in Windows console
if sys.platform == "win32":
    ## set utf8 console
    if not sys.stdin.encoding == 'cp65001':
        os.system('chcp 65001 > nul')
    class UniStream(object):
        __slots__= "fileno", "softspace",
        def __init__(self, fileobject):
            self.fileno= fileobject.fileno()
            self.softspace = False
        def write(self, text):
            if isinstance(text, unicode):
                os.write(self.fileno, text.encode("utf_8"))
            else:
                os.write(self.fileno, text)
    sys.stdout= UniStream(sys.stdout)
    sys.stderr= UniStream(sys.stderr)

lang1=sys.argv[1]
lang2=sys.argv[2]
langpair='%s|%s'%(lang1,lang2)

if len(sys.argv) > 3:
    text=' '.join(sys.argv[3:])
else:
    text=sys.stdin.read()

base_url='http://ajax.googleapis.com/ajax/services/language/translate?'
params=urlencode( (('v',1.0),
('q',text),
('langpair',langpair),) )
url=base_url+params
content=urlopen(url).read()
start_idx=content.find('"translatedText":"')+18
translation=content[start_idx:]
end_idx=translation.find('"}, "')
translation=translation[:end_idx]
sys.stdout.write(translation + '\n')

This is the updated script that uses the web API. Should work after December 2011.

#!/usr/bin/env python
import sys
import os
import urllib2
from urllib import urlencode
import cookielib
import re

# The google translate API can be found here (***NOT OPERATIONAL SINCE DECEMBER 2011***):
# http://code.google.com/apis/ajaxlanguage/documentation/#Examples

# Language codes are listed here:
#http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray

if len(sys.argv) < 3:
    name = os.path.basename(sys.argv[0])
    print '''
Usage:
    %s en es lovely spam
    %s es en < file.txt

Available language codes are listed here:
http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray

''' % (name,name)
    sys.exit(-1)

## hack to be able to display UTF-8 in Windows console

def fix_win32_console():
    ## set utf8 console
    if not sys.stdin.encoding == 'cp65001':
        os.system('chcp 65001 > nul')
    class UniStream(object):
        __slots__= "fileno", "softspace",
        def __init__(self, fileobject):
            self.fileno= fileobject.fileno()
            self.softspace = False
        def write(self, text):
            if isinstance(text, unicode):
                os.write(self.fileno, text.encode("utf_8"))
            else:
                os.write(self.fileno, text)
    sys.stdout= UniStream(sys.stdout)
    sys.stderr= UniStream(sys.stderr)

if sys.platform == "win32":
    fix_win32_console()

lang1=sys.argv[1]
lang2=sys.argv[2]

if len(sys.argv) > 3:
    text=' '.join(sys.argv[3:])
else:
    text=sys.stdin.read()

base_url='http://translate.google.com.br/translate_a/t'
# sample browser request
#http://translate.google.com/translate_a/t?client=t&text=col&hl=en&sl=en&tl=es&multires=1&otf=2&ssel=4&tsel=0&sc=1
params=urlencode({'client':'t',
    'text':text,
    'hl':'en',
    'sl':lang1,
    'tl':lang2,
    'otf':2,
    'multires':1,
    'ssel':0,
    'tsel':0,
    'sc':1,
    })

url=base_url + '?' + params

cookiejar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1018.0 Safari/535.19'),
                    ('Referer', 'http://translate.google.com/')
]
response = opener.open(url)
translation=response.read()
matcher = re.search('\[\[\["(?P<human_readable_chunk>[^")]*)', translation)
sys.stdout.write(matcher.group('human_readable_chunk'))



Save the script to a file such as gtrans.py and run it as follows (assuming you have Python in your path):

    python gtrans.py en es Nobody expects the Spanish Inquisition

The first two parameters are the language codes. A list of codes known to google translate is available here: http://code.google.com/apis/ajaxlanguage/documentation/reference.html. For some reason, not all of the listed codes are actually accepted, for example, bo for Tibetan

To pipe a text file through the script:

    python gtrans.py en es < myfile.txt

It is also possible to enter multi-line text directly from the console. To do so, call the script with the language codes only, i.e:

    python gtrans.py en es

Enter your text and use the Enter key to start a new line. When you are done, press CTR+d (on Linux) or CTR+z followed by Enter (on Windows).

Note: On Windows input in other languages than English is not going to work. This is due to poor support of Unicode input in cmd.exe. On Linux international input works fine, provided that the console is UTF-8.

Keep in mind though that google has a limit on the size of text to be translated.

Console Google Translate — curl-based version

As an alternative, here is a bash script which uses curl and sed. Updated to work via Google Translate Web API.

#! /bin/bash

USAGE="Usage: 
       $0 en es Lovely spam!
Some codes: en|fr|de|ru|nl|it|es|ja|la|pl|bo
All language codes:
http://code.google.com/apis/ajaxlanguage/documentation/reference.html#LangNameArray"

if [ "$#" == "0" ]; then
    echo "$USAGE"
    exit 1
fi

FROM_LNG=$1
TO_LNG=$2

shift 2
QUERY=$*

UA="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803"
URL="http://translate.google.com.br/translate_a/t?client=t&hl=en&sl=$FROM_LNG&tl=$TO_LNG&otf=2&multires=1&ssel=0&tsel=0&sc=1"
curl  --data-urlencode "text=$QUERY" -A $UA -s -g -4 $URL | sed 's/","/\n/g' | sed 's/\]\|\[\|"//g' | sed 's/","/\n/g' | sed 's/,[0-9]*/ /g'

Aug 29, 2010

Linux console online dictionary lookup

I often need to lookup words in various online dictionaries, but in many cases I would prefer to get the results right in the console, instead of having to launch the browser, type in the URL and wait for the page to load.

For example, here is a bash oneliner that translates an English word to Spanish right in the console:

Wordreference English-Spanish: 
curl -j -s -A "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/458; U; en) Presto/2.2.0" "http://www.wordreference.com/es/translation.asp?tranword=`echo $* | sed 's/ /%20/g'`" | html2text -utf8 | less -R

Wordreference Spanish to English:
curl -j -s -A "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/458; U; en) Presto/2.2.0" "http://www.wordreference.com/es/en/translation.asp?spen=`echo $* | sed 's/ /%20/g'`" | html2text -utf8 | less -R

Merriam Webster Online English Dictionary: 
curl -j -s -A "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/458; U; en) Presto/2.2.0" "http://www.merriam-webster.com/dictionary/`echo $* | sed 's/ /%20/g'`" | html2text -utf8 | less -R

Wikipedia (EN):
curl -j -s -A "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/458; U; en) Presto/2.2.0" "http://en.wikipedia.org/wiki/`echo $* | sed 's/ /%20/g'`" | html2text -utf8 | less -R 


Usage: Save the required script to a file, make it executable (chmod +x webster), and then type the script name from the console with the word(s) you need translated as arguments.

Instead of creating a separate script for each dictionary it might be more practical to add the scriptlets as aliases in your .bashrc file, e.g:

alias webster="curl -j -s -A "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/458; U; en) Presto/2.2.0" "http://www.merriam-webster.com/dictionary/`echo $* | sed 's/ /%20/g'`" | html2text -utf8 | less -R"
Make sure you have curl, html2text , sed, and less installed.

A similar result can be achieved by using some console browser like lynx or w3m. Install w3m:

sudo apt-get install w3m # for Ubuntu
sudo pacman -S w3m       # Archlinux

Create a wrapper script which includes the URL:

echo 'w3m "http://www.wordreference.com/es/translation.asp?tranword=$*"' > ~/bin/en2es
chmod +x ~/bin/en2es

Now the script can be run like this:

en2es word of mouth

The advantage in this case is that you can use all the standard browser features, like clicking links, etc.

Apr 30, 2010

Bash oneliners or helpful aliases for your .bashrc

Useful bash oneliners that might or might not be worth including as aliases in your ~/.bashrc file.

Bash Oneliners
command
action
grep -v "^#" $* | grep -v "^$"
print file contents excluding comments starting with # and empty lines
netstat -tpauln
print open TCP connections *and* application names
find . -maxdepth 1  -type d  -exec du -sh {} \; | sort -hr
print sorted directory sizes starting with the biggest
find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 du -sh | sort -hr
same as above, but supposedly more efficient for lots of files
help test | less
does not do much work on itself but it is good reading
[ -n $SOMEVAR ] &&  echo "IS_NOT_EMPTY" || echo "IS_EMPTY"
execute first command on empty string, or execute second command otherwise (the Python way)
mkdir $(echo {01..22}spam)
create folders 01spam, 02spam, 03spam, etc.
cp filename{,.bak}
create backup of file
!!
rerun previous command
sudo !!
rerun previous command as root
python -m SimpleHTTPServer
run web server for current dir on port 8000 (Python 2.x version)
python -m http.server
run web server for current dir (Python 3 version)
:w !sudo tee %
write file in vim as root
ssh-copy-id remote-machine
copy rsa/dsa key to remote machine for public authentication
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
record current desktop to mpeg file
echo -e ${PATH//\:/\\n}
string replace with bash (the example replaces colon with end-of-line
curl -O http://rss.timegenie.com/forex.xml
download file to local file forex.xml
tr -dc ' -~' < /dev/urandom | head -c 20
generate random string
echo $(($RANDOM % 100))
generate random number in range
sudo find . -user root -exec chown spamneggs {} \;
find all files owned by root and change owner to spamneggs
function mcd {
  mkdir ${1} && cd ${1}  
}
a ~/.bashrc shortcut to make a directory and move into it.
function catw {
cat `which "${1}"`  
}
a ~/.bashrc shortcut for typing cat `which script`
function vimw {
vim `which "${1}"`  
}
a ~/.bashrc shortcut for typing vim `which script`; you get the idea...
See also:

Apr 15, 2010

Running a command recursively on all files in a directory tree

Windows solution
Here is a script which calls mplayer on every file in a directory including subfolders:

The script will work on dirs containing spaces and non-ascii characters since all file names are converted to short dos names (via the `~s` modifier).
  set mplayer=z:\path_to_mplayer\mplayer.exe
  for /f "delims=" %%f in ('dir /b /s "%cd%"') do (%mplayer% "%%~sf")
Linux bash solution
The bash shell solution is much easier to read than the windows one:
  #!/bin/sh
  cwd=`pwd`
  for f in `find $cwd -type f -iname "*.mp3" `; do
    mplayer $f
  done

A Better Solution

An alternative solution for both Windows and Linux would be to create a playlist file first, and then run a single mplayer instance with the -playlist switch:
Linux bash
  #!/bin/sh
  find $pwd -type f -iname "*.mp3" > /tmp/allfiles.m3u
  mplayer -playlist /tmp/allfiles.m3u
Windows Batch
  set mplayer=z:\path_to_mplayer\mplayer.exe
  set playlist=%TEMP%/mp3playlist.m3u
  dir /b /s "%cd%" | find /I ".mp3" > "%playlist%"
  %mplayer% -playlist "%playlist%"
Shortest solution
  mplayer $(find . -iname "*.mp3")

Nov 27, 2009

VIM usability: my .vimrc

My .vimrc compiled from various Internet sources. The goal was to make vim more user-friendly for someone who is familiar with popular shortcuts like Ctr+C for copy and Ctr+V for paste, but still retaining most classic vim shortcuts. Since Ctr+V cannot be used for vertical block selection it still can be done with Ctr+Q if your OS allows it.

Oct 28, 2009

Entering special characters in Linux

Occasionally there is a need to enter special characters which are not on the keyboard, for example, an M-dash, ("—") or and N-dash ("–").

This solution works on all recent xorg versions, so it should work on all modern Linux distros.

  1. Press Ctr+Shift+U.
  2. Release U while still holding Ctr+Shift.
  3. Enter the four digit character code, e.g. 2013 for an m-dash, or 2014 for a n-dash.
Some special characters:
Unicode character code (HEX)
Special Character
00a9
©
2013 – (en-dash)
2014
— (em-dash)
20ac

20a4


You can find a list of some character codes here:

Sep 30, 2009

WordReference.com Bookmarklet

This bookmarklet opens a Word Reference popup window for the currently selected word on a page. Works in the same way as the Google Translate bookmarklets.

Word Reference Es-En
05/2010: updated to work on pages with frames

 

Sep 21, 2009

Google Translate Popup Bookmarklet

These bookmarklets open a Google Translate popup for the currently selected text on a page. The only difference from the standard google translate bookmarklets is that these bookmarklets will also work on pages that use frames or inline frames, for example in gmail.

To use a bookmarklet drag the link (do not click) to you Favorites toolbar. Once you have added the icon to your toolbar, select some text (e.g. in Spanish) on a page and then click the bookmark icon.

To modify the language pair, edit the language code in the bookmarklet source from es|en to whatever language you want. Use auto to autodetect the source language.

Google Translate En-Es
Google Translate Es-En
Google Translate Any-En (autodetect)
Google Translate Any-Es (autodetect)

To see how this works select some text on this page and then click the link Google Translate En-Es to get a Spanish translation in a popup window.

To get more google translate buttons for more languages go to the google's own page at http://translate.google.com/translate_buttons.

 

May 28, 2009

M4AtoMP3: Convert M4A files to MP3

I wanted to convert some M4A files to MP3, and found some examples of how to do it: Convert iTunes M4A files to MP3 on Linux, and especially Howto:convert aac/mp4 to wav/mp3/ogg on Linux.

The second link was close to what I wanted, and the script almost worked, but I wanted something even simpler, so here is the simplest script that worked for me. It converts all .M4A files in the current directory to MP3.

#!/bin/bash
# Usage: run without arguments from the folder containing M4A files
# Uses faad and lame (sudo apt-get install faad lame)
shopt -s nocaseglob

for file in *.m4a ; do
  if [ -e "${file%%.*}.mp3" ]; then
    echo "file ${file%%.*}.mp3 already exists! skipping!" ;
    continue
  fi
  faad -o - $file | lame - "${file%%.*}.mp3" ;
done

May 22, 2009

Screen Quick Howto

What is screen?
man page: "Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells)." Here is a screen screen tutorial.
Screen quickref
Most of the data below has been taken from the screen quick reference.
Shortcuts
Action
Shortcut
Change to last-visited active window
C-a C-a (commonly used to flip-flop between two windows)
Change to window by number
C-a <number> (only for windows 0 to 9)
Change to window by number or name'
C-a <number or title>
Change to next window in list
C-a n or C-a <space>
Change to previous window in list
C-a p
Split current screen session into two regions
C-A S
Remove current region
C-a X
remove all regions but the current one
C-a Q
Switch between displayed regions
C-a TAB
Create new session in split region
C-a c
Return to a single region
C-a Q
Detach
C-a d
Detach and logout (quick exit)
C-a D D
Enter copy mode
C-a [ (also used for viewing scrollback buffer) and with C-]
Paste
C-a ]
Rename current window
C-a A (note the uppercase 'A'!)
Console commands
Detach attached session
screen -D
Detach attached screen session (possibly running in another terminal) and reattach in current terminal
screen -Dr
Detach specific screen session (when more than one sessions are running)
screen -D 14493.ssh2others

Apr 27, 2009

Python UnicodeDecodeError: 'ascii' codec can't decode byte

You use Python 2.x and keep getting the notorious Python UnicodeDecodeError, 'ascii' codec can't decode byte?

Here is a hack which is especially useful in cases when you need to work with HTML.

Instead of

    print nasty_unicode_string

use this:

    print nasty_unicode_string.encode('us-ascii','xmlcharrefreplace')

This code will replace all the exotic non-ascii characters with their HTML-escaped ascii representation, i.e. Sueño will be replaced with Sue&#241;o, which will display properly when rendered in HTML.

Bingo! No more UnicodeDecodeError!

Warning: In most cases the UnicodeDecodeError is caused by programmer's lack of understanding of how Unicode is handled by Python, and is a signal that the entire approach to string handling should be revised. The hack above is not the proper way to fix it, and should be used with care. On the other hand, this approach is totally justified in cases when you need to print something to the console and are not sure whether the terminal supports utf8 or other unicode-friendly encoding.

Feb 18, 2009

Mouse emulation with keyboard

In many applications you can get around by pressing the Tab and arrow keys and then pressing Enter or Space when the widget you need is under focus. Remembering common shortcuts is always useful, but there are things which are impossible to do without a mouse, for example, clicking a button in a Flash applet.

As you probably know, you can emulate most mouse actions with the keyboard. To enable this feature in Kubuntu 8.10/9.04

  1. Open System Settings:
       systemsettings
    
    or click the Application Launcher > System > System Settings.
  2. Under the General tab select Keyboard & Mouse. To do it with the keyboard use Tab/Shift+Tab and the arrow keys. Window tabs (or pages) can be switched with Control+Tab or with Alt + underlined letter.
  3. Next, select Mouse on the left, and then Alt+N for Mouse Navigation.
  4. Select the option Move pointer with keyboard (using the num pad). (Alt+M)
  5. Click Apply (Alt+Y).

Note: If this looks complicated, there is actually a single shortcut for enabling mouse keys: Alt+Shift+NumLock.

Now you should be able to move the mouse pointer with number pad keys: 1, 2, 3, 4, 6, 7, 8, 9. If it does not work try pressing the NumLock key.

The table below shows the correspondence between mouse actions and keys on the number pad.

mouse action keyboard equivalent
Left-click 5
Left double-click '+'
Right click '-' on the numpad and then 5
Middle-click '*' on the numpad and then 5
Switch back to left click '/' on the numpad and then 5

The '-', '*', and '/' on the number pad select which 'mouse button' will be clicked when you press '5', therefore after you do a right-click with '-' and 5, you will have to switch back to left-clicking mode by pressing '/', otherwise you next click will still be on the 'right mouse button'.

Selecting text, dragging with keyboard

For some strange reason I did not find any official documentation on how to emulate mouse dragging with keyboard.

I have not checked other distros but on Kubuntu 8.10 you can do it by consecutively pressing the Del and '0' (Ins) on the number pad. This enables drag mode and you can now use 1-4/6-9 keys to drag whatever you clicked on. To finish dragging click 5.

I suppose that these features have to do with the xorg server, and are not [K]Ununtu-specific, so this probably should work with most distros.

Most of these keys also work on a MS Windows machine with one exception: drag-mode on Windows is enabled with the '0' key alone.

Jan 3, 2009

Bookmarklet: GeoWhois for current page

Javascript bookmarklets: GeoIP, whois

Drag the link below (do not click) to you Favorites toolbar:

GeoIP

Whois (Firefox only, also works with selected text)

Whois (Firefox and IE)

Opera: Shift+drag the link to the toolbar

Firefox: Drag to Bookmarks panel (enable with View > Toolbars > Bookmarks)

Usage: To look up the domain of a page you are browsing simply click the bookmarklet in the Favorites toolbar. To lookup a URL that appears on a page, select the URL and click the bookmarklet in your Bookmarks bar (this only works with the Firefox-only bookmarklet).

In Firefox 3.x it is possible to drag the bookmarklet to any position you want, even to the menu bar. To do this, first add the bookmarklet to the Bookmarks bar, then right-click on the Firefox toolbar, select Customize, and drag the bookmarklet to wherever you want. After that you can disable the Bookmarks toolbar.

The Java Posse (Most Recent Podcasts)