Wednesday, March 23, 2011

simple rsync

How to use rsync logic to copy only modified/new files and not have to run any service on the other host.

basically you will have the same result/security/convenience as running scp
scp -r sourcefiles/* destination.host.com:/destination/

but with the added rsync logic:
rsync -r -v -e ssh sourcefiles/* destination.host.com:/destination/

Tuesday, December 14, 2010

simulate a distant host in localhost

simulate 200ms pings. (100ms each leg)
tc qdisc add dev lo root handle 1:0 netem delay 100msec


Restore it back to normal again with:

tc qdisc del dev lo root


TODO: script to set that every second to a random value from 10 to 100

also:
iprelay -b30000 8000:localhost:80


references
  • from http://daniel.haxx.se/blog/2010/12/14/add-latency-to-localhost/
  • also in http://news.ycombinator.com/item?id=2004790
  • docs in http://www.linuxfoundation.org/collaborate/workgroups/networking/netem

usable tackaball

got a logitec usb trackman from ergo last week. really liked the middle style trackball, but missed scroll. the solution:

wrotenote-lx$ cat logitec_usb_trackball.sh 
#!/bin/sh
# 1 2 3 4 5 6 7 8 9
#xinput set-button-map "Logitech USB Trackball" 8 9 2 4 5 6 7 1 3
xinput set-button-map "Logitech USB Trackball" 1 9 2 4 5 6 7 1 3
# LF rt lf RT
# LF = big left button
# RT = big right button
# lf = small left button
# rt = small right button

# liga emulacao do whell por movimento do mouse
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation" 8 1
# diz q par de botoes o movimento no eixo X "clica"
#xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation X Axis" 8 6
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Axes" 4 5 6 7

# apertar o botao 1 ativa emulacao acima
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Button" 8 1



the buttons now do:
  • Big left button:

    • click for Button 1 (left click)
    • Hold for scroll on the trackball moviment (all four directions)

  • small left button: always button 1 (so i can drag things and select text)
  • small right button: Button 3 (right click) my least used button
  • Big Right button: middle click. I used that button a lot, to paste and thown windows to the bottom of my desktop zindex.

usable tackaball

got a logitec usb trackman from ergo last week. really liked the middle style trackball, but missed scroll. the solution:

wrotenote-lx$ cat logitec_usb_trackball.sh 
#!/bin/sh
# 1 2 3 4 5 6 7 8 9
#xinput set-button-map "Logitech USB Trackball" 8 9 2 4 5 6 7 1 3
xinput set-button-map "Logitech USB Trackball" 1 9 2 4 5 6 7 1 3
# LF rt lf RT
# LF = big left button
# RT = big right button
# lf = small left button
# rt = small right button

# liga emulacao do whell por movimento do mouse
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation" 8 1
# diz q par de botoes o movimento no eixo X "clica"
#xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation X Axis" 8 6
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Axes" 4 5 6 7

# apertar o botao 1 ativa emulacao acima
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Button" 8 1



the buttons now do:
  • Big left button:

    • click for Button 1 (left click)
    • Hold for scroll on the trackball moviment (all four directions)

  • small left button: always button 1 (so i can drag things and select text)
  • small right button: Button 3 (right click) my least used button
  • Big Right button: middle click. I used that button a lot, to paste and thown windows to the bottom of my desktop zindex.

Sunday, October 24, 2010

android tool box

Emulator:
emulator -cpu-delay 0 -no-boot-anim -cache ./cache  -avd froyo


adb log view:
adb -e logcat

(-d if device, -s xxxx if multiple emulators/devices)

and for the code:
import android.util.Log;
[...]
Log.d(TAG, sb.toString());


controling the emulator (will never understand why it's not implemented in the shell...)
telnet localhost 5554
# gsm call 5555
# sms...

android build on device and emulator

`ant install` will freak out and die if you have more then one device in `adb devices`

but it has an option in its rules called adb.device.arg, which is not really an adb device arg, but more like an adb arg. so you can pass any argument to adb there.

in my case since i only have one emulator and one device simply passing "-d" for device or "-e" for emulator solves it. you can also pass "-s id_of_device_or_emulator"

since i'm clueless to ant i will use the easiest solution and pass that as an argument every single time:

ant install -Dadb.device.arg="-d"


if you are clever than me, pls comment on how i create a simple `ant installdevice` rule that simply sets that var and then run the install target, please.

Android USB debugging in linux

get the device vendor string:
$ lsusb
...
Bus 001 Device 005: ID 18d1:4e12 Google Inc. Nexus One Phone (Debug)
...


add a rule to udev to allow read/write

# cat SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666" > 
/etc/udev/rules.d/51-android.rules


disconnect and reconnect the usb cable. done.