## Sunday, November 14, 2010

### Tape sort on 4k-by-4k matrix

Q: How to transpose row-major 4k-by-4k matrix stored on magnetic tape?

A: First prepend the column and row numbers to each element, then tape sort by column numbers then by row numbers, then remove the column and row numbers.
For example: there is a row-major matrix stored on the tape

3 2 1
4 5 7
6 2 3

So on the tape it will be like {3,2,1,4,5,7,6,2,3}

Prepend column and row numbers to each element:
[0,0]3 [1,0]2 [2,0]1
[0,1]4 [1,1]5 [2,1]7
[0,2]6 [1,2]2 [2,2]3

Sort by column number then by row number, on tape it will be like

{[0,0]3,[0,1]4,[0,2]6, [1,0]2,[1,1]5,[1,2]2, [2,0]1,[2,1]7,[2,2]3}

## Friday, October 1, 2010

### openssl soap_ssl_client_context() problems

On client side:

generate necessary pem files:

(1) private key/certificate pem file:

openssl pkcs12 -in in_file.p12 -clcerts -out key_out_file.pem

(2) generate CA certificate pem file (NOTE: Do NOT use -clcerts here, because the fifth parameter of soap_ssl_client_context requires a CA certificate):

openssl pkcs12 -in in_file.p12 -cacerts -out cert_out_file.pem

(3) use in soap_ssl_client_context()

if (soap_ssl_client_context( &soap,
SOAP_SSL_DEFAULT,
"key_out_file.pem",
"your_pw",
"cert_out_file.pem",
NULL,
NULL))
{ // print ... error }

## Monday, September 13, 2010

### GEnerate gsoap

gcc -o iplookup iplookup.c soapC.c soapClient.c -L/usr/local/lib - lgsoap -lm -lsocket -lnsl

gcc test.c soapC.c -lgsoap
works for me

## Thursday, September 9, 2010

### How to make Virtual keyboard and SCIM co-exist on N900

(1) Install MSCIM and whatever input methods you want
(2) Go to /etc/gtk-2.0/, create two files as follows

first file: vb (for Virtual Keyboard)

"/usr/lib/gtk-2.0/2.10.0/immodules/hildon-im-module.so"
"hildon-input-method" "Hildon Input Method" "hildon-input-method-framework" "/usr/share/locale" "*"

Second file: scim (for MSCIM)

"/usr/lib/gtk-2.0/2.10.0/immodules/im-scim.so"
"scim" "SCIM Input Method" "scim" "/usr/share/locale" "*"

(3) in the same directory, create another two files:

first file: vb.sh

cp /etc/gtk-2.0/vb /etc/gtk-2.0/gtk.immodules

second file: scim.sh

cp /etc/gtk-2.0/scim /etc/gtk-2.0/gtk.immodules

then chmod to these two files

>>root
>>chmod +x vb.sh scim.sh

(4) make two symbolic links in /usr/bin/

ln -s /etc/gtk-2.0/vb.sh /usr/bin/vb
ln -s /etc/gtk-2.0/scim.sh /usr/bin/scim

(5) if you want to use virtual keyboard, remember to retract the physical keyboard first, then type in

>>root
>>vb

if you want to use MSCIM:

>>root
>>scim

## Sunday, August 29, 2010

### Call of Duty Modern Warfare 2原声碟

Safeguard

Guerrilla Tactics

Breach

Ordinance

Code of Conduct

Protocol

## Friday, August 27, 2010

### How to get Xilinx XUP Virtex II PRO to work in Ubuntu 10.04

(2) get the product id right in >>lsusb

## Wednesday, July 28, 2010

### How to make a clone of Virtualbox image and run multiple Virtual machines at the same time

From http://forums.virtualbox.org/viewtopic.php?t=674

1) Shut down the virtual machine you would like to copy
2) In File > Virtualdiskmanager, select the virtual machine disk image you would like to copy, and press the Release button and DELETE it from the menu BUT keep the image on the harddrive.
3) In a terminal window, issue following command (see virtualbox user manual):
vboxmanage clonevdi /directory/image1.vdi /directory/image2.vdi
4) In File > Virtualdiskmanager, add the new disk image you've created in step 3.
5) In the main virtualbox window, press the New button to create a new virtual machine, and link it to the new disk image you've created.

## Saturday, July 24, 2010

### How to use wsdl file to generate c/c++ files

This setup is based on Debian/Ubuntu system and doesn't involve any installation of Apache/Axis

(1)Install Java (run-time package is enough, but javac is a bonus, though I don't think I used javac in this setup). Note:install some new version, I used version 1.6.

(2)Download Axis C++ bin from Apache.org, decompress it. Note that there is a lib/axisjava folder and all the necessary Axis Java files used by Axis C++ are in there, so we don't have to download Axis Java anymore (however, if you try to use log4j you HAVE TO download Axis Java bin/src). And make sure in lib/axis there is already a wsdl2ws.jar in place, or you have to install ant and build the jar from source (which I didn't do)

(3)Edit CLASSPATH environment variable, here is my CLASSPATH variable

AXIS_C_HOME="type in your full directory path where Axis C++ bin is decompressed to"
AXIS_C_LIB=\$AXIS_C_HOME/lib/axisjava

CLASSPATH=\$AXIS_C_HOME/lib/axis/wsdl2ws.jar:
\$AXIS_C_LIB/axis.jar:
\$AXIS_C_LIB/wsdl4j.jar:
\$AXIS_C_LIB/commons-discovery.jar:
\$AXIS_C_LIB/commons-logging.jar:
\$AXIS_C_LIB/jaxrpc.jar:
\$AXIS_C_LIB/saaj.jar:
\$CLASSPATH

export CLASSPATH

Note: if you want to use log4j, it should be located in \$/lib/log4j-version.jar
you will need to include this path to CLASSPATH also.

Also note: if you want to set this varibale permanent, put the above stuff in .profile in your home directory, logout, and login again to take effect. To make sure: printenv \$CLASSPATH

(4)Now we're ready to generate some c/c++ files using wsdl templete, here are some examples to generate client side wrapper:

c++:
java org.apache.axis.wsdl.wsdl2ws.WSDL2Ws -sclient -lc++ "your wsdl file full path"

c:
java org.apache.axis.wsdl.wsdl2ws.WSDL2Ws -sclient -lc "your wsdl file full path"

if the above don't work (which shouldn't been the case...), try:

c++:
java -classpath \$CLASSPATH org.apache.axis.wsdl.wsdl2ws.WSDL2Ws -sclient -lc++ "your wsdl file full path"

c:
java -classpath \$CLASSPATH org.apache.axis.wsdl.wsdl2ws.WSDL2Ws -sclient -lc "your wsdl file full path"

## Friday, July 23, 2010

### how to create uml file system

this is the only way I found working on Ubuntu 10.04 32bit, the original link is:
http://web2.clarkson.edu/class/cs644/kernel/setup/uml/uml.html

Debian is suprisingly simple to install inside of user mode linux. To begin you must initialize the files using dd. This example assumes that your image files are /opt/uml/debian-root.

` `#`dd if=/dev/zero of=/opt/uml/debian-root bs=1024K count=1000`

Now we will initialize the filesystems inside of each of these files. We will be using ext3 as our root filesystem.

Example 6. Initializing the filesystems

` `#`mkfs.ext3 /opt/uml/debian-root`

Now we will need to mount the root filesystem before we run debootstrap.

Example 7. Mounting root

` `#`mkdir /mnt/debian `#`mount -o loop /opt/uml/debian-root /mnt/debian`

Now we will install debootstrap and bootstrap a base Debian installation. This is a barebones installation that is less than 200 megs.

Example 8. Debian Installation

` `#`apt-get install debootstrap `#`debootstrap --arch i386 sarge /mnt/debian http://ftp.us.debian.org/debian     or you may want to use the breezy installation.     `#`debootstrap --arch i386 breezy /mnt/debian http://archive.ubuntulinux.org/ubuntu`

At this point your system is an unconfigured base system. You will need to edit the following files in order to have your system in a valid configuration.

• /etc/fstab

• /etc/hostname

• /etc/hosts

• /etc/network/interfaces

• /etc/apt/sources.list

• /etc/securetty

• /etc/inittab

Example 9. FSTAB configuration

` /dev/ubd0 / ext3 defaults 0 1 proc  /proc proc defaults 0 0`

Example 10. Host configuration

You will need to make sure that /etc/hostname contains the following line or your nameing preference.

` uml-one`

You will need to make sure that /etc/hosts contains the following line.

` 127.0.0.1 localhost`

At this point you will need to setup your network interface configuration. This is done by editing the file /etc/network/interfaces. This guest will have a loopback network device. More information on configuring network devices under Debian can be found in the Debian Reference.

Example 11. The loopback network interface

` auto lo iface lo inet loopback`

The above should be in the file /etc/network/interfaces. You'll also need to add a mirror or cdrom image to /etc/apt/sources.list

Example 12. /etc/securetty Configuration

` `#`echo "tty0" >> /etc/securetty `#`echo "ttys/0" >> /etc/securetty`

Example 13. /mnt/debian/dev

In the breezy debootstrap example no node was created for me to mount the file system too, you can check this by,

` `#`cd /mnt/debian/dev `#`ls ubd*  If this does not return ubd0 then,  `#`mknod --mode=660 ubd0 b 98 0 `#`chown root:disk ubd0 `

Example 14. Edit /etc/inittab

This will allow you to login immediately after the boot messages

` Comment out the following lines:   2:23:respawn:/sbin/getty 38400 tty2   3:23:respawn:/sbin/getty 38400 tty3   4:23:respawn:/sbin/getty 38400 tty4   5:23:respawn:/sbin/getty 38400 tty5   6:23:respawn:/sbin/getty 38400 tty6    Now modify tty1 to say tty0, the result should look like this:   1:2345:respawn:/sbin/getty 38400 tty0   #2:23:respawn:/sbin/getty 38400 tty2   #3:23:respawn:/sbin/getty 38400 tty3   #4:23:respawn:/sbin/getty 38400 tty4   #5:23:respawn:/sbin/getty 38400 tty5   #6:23:respawn:/sbin/getty 38400 tty6 `

Example 15. Add user to the file system

Before you can log into the file system you must add a user to be ablet logi in with.

` `#`chroot /mnt/debian `#`adduser uml Aswer the following questions about the new user or press enter followed by a yes at the end`

Example 16. Run the kernel with UML

` `#`sudo umount /mnt/debian `#`sudo ./linux ubd0=/opt/uml/debian-root`

using

### Axis C++ WSDL2Ws Tool

monitor memory usage:top
monitor harddrive: df

## Tuesday, July 13, 2010

### How to resize uml file system

• Shut down the uml guest
UML# halt
• Make a backup of the file you want to resize.
• If you have any COW files which have the file you want to resize as a backing file then make a backup of the cow files, too.
• If you want to merge the cow file with uml_moo, do it now. Otherwise remove the cow file to avoid confusion.
• Make sure the filesystem is in a clean state.
host% e2fsck -f filename
• Resize the file.
`                  host%dd if=/dev/zero of=filename bs=1 count=1 seek=newsize conv=notrunc0+0 Records in0+0 Records out               `
newsize can be any size recognized by "dd", such as "256M", "4G", or "2T". The length of the file should have changed, but not the actual filesize as with "ls -ls".
• Resize the filesystem.
host% resize2fs -p filename
host% e2fsck -f filename
• Start the uml with the new filesystem

## Wednesday, July 7, 2010

### DRAGON Network user mode linux setup

This tutorial uses only p2p mode.
below from
http://dragon.maxgigapop.net/twiki/bin/view/DRAGON/UserModeLinux

(1)install Linux/Ubuntu

(2)install python, in Debian/Ubuntu, run apt-get install python

(3)install uml-utilities package. NOTE: uml_utilities relies on several dependencies. Run apt-get install libreadline5-dev and apt-get install libfuse-dev
in Debian/Ubuntu, run apt-get install uml-utilities
this is a rather old copy of this package, see below for a newer revision
alternatively, download & install the UML utilities package from the UML mini-HOWTOs page
or use locally cached copy at the above website
build using make all and make install DESTDIR=/

(4)install xterm
in Debian/Ubuntu, run apt-get install xterm. NOTE: in Debian, X11 forwarding will not work if the xauth application is missing
run apt-get install xorg to make sure xauth is properly installed

(5)install GNU screen
in Debian/Ubuntu, run apt-get install screen

(6)install Virtual Distributed Ethernet (vde) package
this package includes the vde_switch application, which is used for establishing network connectivity between UML instances
in Debian/Ubuntu, run apt-get install vde2

(7)install the pre-compiled UML kernel binary, or optionally compile your own UML kernel
install this file into a directory such as /a/uml/debian and run bzip2 -d to decompress

(8)install custom UML root filesystem
download Debian-4.0-x86-root_fs-2008Dec10.bz2 — Debian 4.0 x86 root filesystem + dragon-sw (144 MBytes) from the above website
install this file into a directory such /a/uml/debian and run bzip2 -d to decompress

(9)install VNE
download VNE-snapshot-2009Jan12.tar.bz2 from the above website: Virtual Network Experiments (VNE) snapshot as of 2009-Jan-12 (this version is patched to work with vde_switch)
decompress this file into a directory such as /home/dragon
install the dependency sudo apt-get python-setuptools, the link in the VNE package is invalid.
install: cd /home/dragon/VNE-snapshot-2009Jan12/src; python setup.py install

CONFIGURATIONS:
(1)This example assume the following structure:
everything is running as user "dragon"
location of root filesystem: /a/uml/debian/Debian-4.0-x86-root_fs
location of UML kernel binary: /a/uml/debian/uml_linux

(2)Create the file ~/.vnerc (in your home directory) that contains the following, changing any paths as needed for your system. The defaults are contained in a text file called VNEDefaults.cfg within the VNE distribution.

[DEFAULT]
kernel = /a/uml/debian/uml_linux
filesystem = /a/uml/debian/Debian-4.0-x86-root_fs
fstype = cow
xmllint = /usr/bin/xmllint
screen = /usr/bin/screen
xterm = /usr/bin/xterm
uml_switch = /usr/bin/vde_switch
memorysize = 64
logdir = /home/dragon/uml
removecow = True
tap_device = tap0

(3)Use which to find the location of the binaries on your system, e.g. which screen
default location for screen binary is /usr/bin on Debian/Ubuntu
default location for xterm binary is /usr/bin on Debian/Ubuntu
default location for vde_switch binary is /usr/bin/vde_switch on Debian/Ubuntu
vde_switch will be located at /usr/local/bin/vde_switch if you build/install vde2 from source (by default)

(4)If your system has a lot of memory, you can change memorysize to a higher number. This will allow you to perform development work, e.g. re-compiling the DRAGON software. We recommend setting memorysize to 256 or 512 for development work.

(5)Set UML kernel binary to be executable: chmod +x /a/uml/debian/uml_linux-2.6.27.8

(6)mkdir ~/uml
This is where the copy-on-write (COW) files will be placed, one for each UML instance
COW files contain changes/diffs to the read-only root filesystem (so they allow for a full read-write root partition in UML

Next is the steps I took to get it working:
(1)suppose the file system we use is /a/uml/Debian/Debian-4.0-x86-root_fs as mentioned above. Let's mount it and chroot it to make some changes to it.

(2)the first thing I found out is: Debian-4.0-x86-root_fs will not work out of the box. you have to rebuild and reinstall the DRAGON software suite contained in it. Let's do these:
cd /mnt
sudo mkdir Debian
sudo mount /a/uml/Debian/Debian-4.0-x86-root_fs /mnt/Debian -o loop
sudo chroot /mnt/Debian

Now we're root inside Debian-4.0-x86-root_fs. Let's rebuild and reinstall DRAGON:

sudo mount -t proc proc /proc (mount this or there will be error when building DRAGON)
cd /home/dragon/snapshot.current/dragon-sw
sudo ./do_build.sh vlsr-linux
when CLI prompt comes out, type: shell (NOTE: IMPORTANT!!! because the default is none)
then click enter twice to ignore user name and psword.
after the building:
sudo ./do_install.sh
cd /home/dragon/snapshot.current/narb-sw
sudo ./do_build.sh
sudo ./do_install.sh

Now let's make some changes to the configurations files

(I)
cd /home/dragon
sudo vi .bashrc

add this line at the end of .bashrc file and save it:
"tset -s"
so the narb will not crash when you click backspace.

(II)
then for p2p test xml file, we have to add another port for vlsr1 and vlsr2:
cd /usr/local/dragon/bin
sudo vi genDragonConfig.pl

locate the line:
"set local-id port 1"
add the line below under the above line:
"set local-id port 6"
and save it.

NOTE: you can use "brctl show" in vlsr1/vlsr2 to see the bridge after the bridge is setup and use "/dragon_installation_file_folder/dragon-sw/utils/show-linux-switch-ports.pl" to see the port/switch connection. Also the log files are in /var/log including RSVPD.log and etc. these log files could be great resources for debugging

Finally, to test p2p mode:
sudo VNE config-narb-intra-p2p-csa.xml
start all

open vlsr1, type in:
telnet localhost 2611
edit lsp test
set source ip 10.0.0.3 port 6 destination ip 10.0.0.4 port 6
set bandwidth eth100M swcap l2sc enc eth gpid eth
set vtag any
exit
commit lsp test

wait for a while then type in
show lsp

see if it is "IN service"

## Thursday, July 1, 2010

### Sony Ericsson W508 W518a compatible firmware

T707 can be flashed into W508/W518a with a little bit more function like USB connectivity and language

## Wednesday, June 30, 2010

### satio, xperia X1, c905, w715, w995, c903, yari, hazel, elm, aino, aspen, xperia x10mini, vivaz, xperia x8 vivaz pro

satio(U1), xperia X1, c905, w715, w995, c903, yari (U100), hazel (G502, J20), elm(J10), aino (U10), aspen, xperia x10mini, vivaz, xperia x8 vivaz pro, TM506

### How to connect SE w518 w508 to internet using USB cable through PC

(1) Make sure your w5x8 is properly setup. Go to menu->setting->connectivity->USB and set the phone to "PHONE" mode and USB network to "via computer" (instead of using as MODEM). Also in Internet setting, make sure "allow local connection" is enable.
(2) On Windows XP, if now you connect your cellphone to the pc through USB cable, you should see that another ethernet is established but the IP address can not be obtained. That's okay because we're going to setup the local network so your phone can be tunneled through the PC.
(3) On Windows XP. in control panel-> network connection->setup a home or small office network, setup a local network by selecting "my computer is directly connected to the internet" then select the primary network which is the network that is connected to the Internet. Then select the Sony Ericsson network to tunnel the phone through the primary network connection.
(3) after you see the sony ericsson network icon in your system tray and check that it got an IP of "192.168.0.1" you are good to go to surf the net with your cellphone

## Saturday, June 19, 2010

### how to add a new user in backtrack and add it to sudoer

in root:

if not desired to add the new user to sudoer list, but sometimes need to "sudo" something. simply
su

## Friday, June 18, 2010

### How to scan and connect wireless networks in Backtrack 4

wireless key - security key
essid - network name
ifconfig - Enables your wireless device
iwlist - lists available access points
iwconfig - configuring wireless connection
dhclient - to get an ip address via DHCP

step 1 - Enable wireless device.
Enter the command:-ifconfig wlan0 up

Where 'wlan0' is the name of your wireless device - if your not sure what yours is key 'iwconfig' at the command prompt

step 2 - scan for networks
iwlist wlan0 scan

You will then be given a list of available networks in range

step 3 - configure connection iwconfig wlan0 essid (network name) key (wireless key)eg
iwconfig wlan0 o2wireless key 5405507cd1

Note this is for a HEX key for ascii you have to add 's:' after 'key' as in..iwconfig wlan0 essid key s: wireless key

Step 4 Request an ip address via DHCPdhclient wlan0

## Wednesday, June 2, 2010

### POI resources

http://www.poi-factory.com
http://gpstracklog.com/2006/03/custom_pois.html

### How to move windows using arrow keys in keyboard in Backtrack 4

The answer so far is no. In Ubuntu you can ( Alt + F7 or selfdefined then arrow keys). But somehow in Backtrack 4 when you type Alt + F7 then you can ONLY move windows by using mouse, which is annoying because we lose the keyboard controlability inherent in Linux.

## Tuesday, June 1, 2010

Albuquerque, NM Thrifty car rental phone number : (505) 842-8733. The (505) 842-8734 one is disconnected.

AAA membership discount code for New Mexico:
code: DDMM

## Monday, May 31, 2010

### Pecos New Mexico Trail Head Holy Ghost

Exit I-25 at exit 299 and head east to follow route 50 till you get to the junction with route 63 (35.740373 N,-105.677946 W) where you can see a orange-colored bridge. Turn left and follow Forest 122 (mostly single lane) to the end (35.778071 N,-105.704216 W).

### How to change Automatic transmission fluid in Volkswagon new beetle

For no apparent and good reason the beetle design team confused the DIY mechanics who want to change the transmission fluid themselves.
(1) the motor oil pan on the beetle looks like the transmission fluid pan on a conventional car. And the transmission fluid pan look like the oil pan..
(2) The beetle uses intensively weird-shaped Torx nuts, whose drivers may not necessarily exist in most mechanics' toolbox
(3) the so-called check plug is actually drain plug for part of the transmission fluid, and the level checking procedure is hard to grasp and make sense.
(4) No dipstick for the transmission fluid, i.e. no filler from the top of the engine. This is the last straw for weekend mechanics I guess...

So this is what I did.
(1) Get a funnel and a long filling tube ( long enough to reach from top of the engine to the bottom of the car) to hook up to the end of the funnel.
(2) Jack up the car, jack-stand it on both front sides, drain the transmission fluid ( use the drain plug near the left front tire, the one near the right front tire is the motor oil drain plug). Take out the metal cover that covers the front part of the fluid pan. (note, after this you can take off the fluid pan and drain all the fluid. But this time I guess it'd be too messy and maybe I need a new gasket to reinstall the fluid pan so I only drained part of the fluid.
(3) tight up the drain plug/check plug. from the front-bottom view you can see that the transmission fluid pan actually contains three filler-like plug. Most tutorials I found online use the red-cap protected plastic filler which requires some prying and no screwing. I chose the screw one that is nex to the plastic one (because I cannot get the plastic open) and unscrew the filler plug.
(4) connect the end of the filling tube to the filler and pour automatic transmission fluid to the funnel and see it dripping into the transmission fluid pan.
(5) Tight up the filler, lower the car, unscrew the check plug/drain plug and follow the instruction that "if none drips out, then it needs more fluid, if some drips out, then it's normal, if a lot streams out, then it's overfilled" ( Sorry..no better checking procedure yet..)

## Friday, May 28, 2010

### How to create maps for Garmin Nuvi

At the begining, i'm wondering if it is possible to download satellite image into my Garmin nuvi. Then finally I realized that is for those outdoor handsets...I can only use satellite image/map to create dots and lines. Here's what i did.
(1) install CGpsmapper, old version will work 0096 or something like that
(2) Use Google map to "save image" as JPEG
(3) Use OZIexplorer to calibrate it by using at least two points (get the coordinates from Google map). File-->Load and calibrate map image
(4) Use GPSMapedit to add roads, trees and etc. as you like, this is the fun part and Mapedit has a lot of icons to choose from.
(5) Edit map property by using Menu->File->map property. Choose "Garmin" at the first tab, Choose Level at the third tab ( we need at least TWO levels ).
(6) Edit the objects on the map (road, trees and etc) and choose level for them to show at different zoom level.
(7) Use GPSMapedit Menu File-> export to export the map as Garmin image/cgpsmapper
(8) Use Mapset toolkit to install the image for Mapsource (free from Garmin website) .