Android emulator cheatsheet

Lately, I’ve been testing some mobile web apps using the android emulator.  It’s a piece of software that I use infrequently enough that I can’t remember some needed commands.

Launching the emulator

$PATH_TO_ADT_BUNDLE/sdk/tools/emulator -avd $AVD_NAME

~/local/adt-bundle-linux-x86-20130729/sdk/tools/emulator -avd AVD_for_Galaxy_Nexus_by_Google

Note: AVDs are stored in ~/.android/avd

Launching the Android Virtual Device (AVD) manager

$PATH_TO_ADT_BUNDLE/sdk/tools/android avd

Switching screen orientation

Switch to previous layout orientation (for example, portrait, landscape): KEYPAD_7, Ctrl-F11

Switch to next layout orientation (for example, portrait, landscape): KEYPAD_9, Ctrl-F12


Accessing servers running on localhost



Debugging JavaScript in the Android Browser

console.log() will output to the log stream viewable with the adb logcat command.

You can filter the logs to only see the browser messages by using

adb logcat browser:* *:S


vim cheatsheet

Extracting from a vimball


Users of a vimball archive simply need to

:vim something.vba
:so %

and the contents of the vimball will be extracted and placed into the proper directories, no matter where the user opened up the vimball. Furthermore, the helptags command will be automatically and transparently used to make any doc/*.txt files’ contents available by the Vim help system.

Getting the filename of the currently edited file


:!echo %:p                        : full path & file name
:!echo %:p:h                      : full path only
:!echo %:t                        : filename only

Removing empty lines

From Vim Tip 72:


Converting select text to lowercase

In visual mode, select text.  Then type the u key.

ssh cheatsheat

Port forwarding


$ ssh -f -L sleep 10

Backing up files over SSH

$ ssh remote_host "tar -zc -C /path/to/parent/directory -f - some_directory" | cat > some_directory-`datestr`.tar.gz

Backing up a postgres database over SSH

$ ssh remote_host "pg_dump --username=db_user db_name" | gzip  > db_name-`datestr`.sql.gz