Sunday, March 29, 2015

Using ant to build Android sample code

It used to be so easy to build Android's code, now with Android Studio and gradle it become so complicated.

Let me put it down how to use ant to build before Google swipe everything away.  and this is the only way to build their sample code now since many sample codes are not migrated to Android Studio and gradle/gradlew yet.

  • go to sample code root directory.  android-21 is the target API, the command will generate build.xml for build process
    $ android update project --target android-21 --path .
  • build the debug apk
    $ ant debug
  • use find . -name *.apk to locate the apk file.  use adb to install apk to your phone
    $ adb install ./bin/NewsReaderActivity-debug.apk

Summary:
  1. $ android update project --target android-21 --path .
  2. $ ant debug
  3. $ adb install ./bin/NewsReaderActivity-debug.apk
Simple as that!

Monday, May 19, 2014

Typing Chinese in English Ubuntu 14.04


  1. Open Terminal

  2. aptitude install scim scim-tables-zh  (and dependencies)
  3. Logout or restart
  4. right-click input area and select "Input Methods", change from "X input Method" to "SCIM Input Method".

  5. Ctrl-spacebar should give you a scim toolbar

**

Update:

scim seems to be a soon obsoleted input method and it crashed on Chrome while I was running in 14.04.  Now I tried ibus and it seems to work pretty well (yet).  

  • In "Language Support", select "IBus" in Keyboard input methold system.
  • Install / Remove Languages... select traditional Chinese
  • In "Text Entry", click "+" to add Input sources (Chinese (cangjie3)
  • In "Input Method", choose IBus
  • change the keyboard shortcut, my own preference is Ctrl+Space
  • make sure to check the box "Show current input source in the menu bar"
You probably need to logout/login to take IBus in effect

Saturday, March 01, 2014

screen and nohup

Not long ago, I introduced nohup to let a program continue executing after you exit or logout from your ssh session..

then not long after that, I introduced screen for UART/COM/serial communication

then I found out, using "screen" is a much wiser choice.
Simply flow are as follow:

  1. create a screen
  2. execute whatever you want to run, probably something like a server
  3. detect a screen (ctrl-a, d)
There you go. Server will continue to listen after you log off your ssh session.

In case you want to go back to that screen, just re-attach it
  1. list screen (screen -ls)
  2. re-attached the screen (screen -r [screen name])
  3. there, ctrl -c to quite your program or server or whatever, then type exit to exit the screen

Monday, February 10, 2014

Displaying remote X clients

This will allow you to ssh to a server and prompt x windows:
$ export DISPLAY=:0.0

and

$ ssh -Y username@remove_server_ip

Remember the -Y option, it enables trusted X11 forwarding.



Wednesday, January 29, 2014

OSX UART serial terminal




In OSX, turn on the terminal, plug in your FTDI USB-serial dongle, you should see a new usbserial device created under /dev.  Use "screen" to start the session, remember to state the baudrate at the end of the command:
$ screen /dev/cu.usbserial-FTVLVQ6M 115200
To detach:
Ctrl-a d
To re-attach:
$ screen -r
To kill the screen:
Ctrl-a k

Tuesday, September 17, 2013

difference between insmod and modprobe

Time to refresh memory:

modprobe reads the modules and its dependencies from /lib/modules/$(uname -r)/modules.dep or modules.dep.bin.  modprobe is a smarter tool which will also load the dependent modules.

modprobe accepts the name of a .ko file in /lib/modules/$(uname -r) and aliases (modules.alias.bin).

insmod takes file name or the exact paths to files. The module does not have to reside in /lib/modules/$(uname -r), but dependencies are not automatically loaded. This is the lower program used by modprobe to load modules.

rmmod removes a kernel name based on the name from /proc/modules. This name does not necessarily have to be the same as the one passed to modprobe (for the nvidia-current file, this is nvidia for example).

modinfo accepts a filename, or the filename without .ko suffix in /lib/modules/$(uname -r).

Monday, August 19, 2013

guake - a cool top down terminal for Gnome

http://guake.org/

It's just cool....
try it:
# sudo aptitude install guake

Sunday, August 18, 2013

nohup - run a command immune to hangups (terminal close)

Say you're on business trip, ssh to a remote server, run a command to compile some huge source code which take hours, or process date which takes days, but then you need to close your laptop and run the next site.  Closing the terminal will also kill all the process you started.  What should you do?

nohup is is there to help you.:
NAME
       nohup - run a command immune to hangups, with output to a non-tty

SYNOPSIS
       nohup COMMAND [ARG]...
       nohup OPTION

DESCRIPTION
       Run COMMAND, ignoring hangup signals.

Take an example of compiling a fresh configured buildroot, depends on the packages selected it takes hours/days to download the sources and compile:
EXAMPLE
       $ nohup make buildroot &

Then the buildroot compilation will continue after you close your terminal/laptop.

Saturday, August 17, 2013

Audacious Headless and Keyboard Shortucts

Audacious is an open source audio player, a descendant of XMMS, light-weighted and very similar to MS Windows winamp.

However, by default it does not recognize keyboard shortcuts play/pause/prev/next.

In Audacious preferences (right click on the the right lower corner "a" logo, in the pop-up menu choose preference), -->plugins  --> general tab --> check the "Global Hotkey" plugin, then it would recognize those shortcut keys.  I would prefer Audacious to enable this by default..

Saturday, July 13, 2013

Gaming mouse too fast (sensitive) under Ubuntu Linux

I've got a set of RAPOO keyboard and mouse.  I bought it just because it's a set of really compact and quiet keyboard and mouse, but after I got it I figured it's for gaming so the speed is crazily fast when I use it under Linux.  I went to the "Mouse and Touchpad" to turn Acceleration and Sensitivity to the minimum value but it doesn't work.  Finally I've done the following to slow it down.

gideon@gideon-desktop-i5:~$ xinput --list --short
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ RAPOO RAPOO 5G Wireless Device           id=9 [slave  pointer  (2)]
⎜   ↳ MemsArt MA144 RF Controller              id=11 [slave  pointer  (2)]
⎜   ↳ MemsArt MA144 RF Controller              id=12 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                             id=6 [slave  keyboard (3)]
    ↳ Power Button                             id=7 [slave  keyboard (3)]
    ↳ RAPOO RAPOO 5G Wireless Device           id=8 [slave  keyboard (3)]
    ↳ MemsArt MA144 RF Controller              id=10 [slave  keyboard (3)]
    ↳ MemsArt MA144 RF Controller              id=13 [slave  keyboard (3)]
gideon@gideon-desktop-i5:~$ xinput --set-prop 9 "Device Accel Velocity Scaling" 1
gideon@gideon-desktop-i5:~$ xinput --set-prop 9 "Device Accel Constant Deceleration" 2

For your mouse, the last 2 commands you may need to play around with the numbers to find the optimum value.