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

Source

Accessing servers running on localhost

Use 10.0.2.2

Source

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

Source

vim cheatsheet

Extracting from a vimball

From http://vim.sourceforge.net/scripts/script.php?script_id=1502

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

From http://rayninfo.co.uk/vimtips.html:

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

Removing empty lines

From Vim Tip 72:

 :g/^$/d

Converting select text to lowercase

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


ssh cheatsheat

Port forwarding

from http://www.openssh.com/faq.html#2.11

$ ssh -f -L 1234:server.example.com:6667 server.example.com 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