12/06/2010

How to Solve iPad Slow YouTube issue.

Add an ip address 8.8.8.8 as your wifi's first DNS server.

Reboot and enjoy youtube.

10/10/2010

Building Android Source Code on Snow Leopard Server

1. Install XCode with 10.4 support.

2. Follow "Get Android Source Code" page to setup the environment, install MacPorts and all required packages.

3. Follow this page to install Java 1.5 and set it as the default java compiler.

4. Link gcc to version 4.0
  • sudo rm /usr/bin/gcc
  • sudo ln -s /usr/bin/gcc-4.0 /usr/bin/gcc
5. Link missing include files to 10.6 gcc
  • cd /Developer/SDKs/MacOSX10.4u.sdk/usr/include
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/emmintrin.h emmintrin.h
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/float.h float.h
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mm_malloc.h mm_malloc.h
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mmintrin.h mmintrin.h
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/xmmintrin.h xmmintrin.h
  • sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h stdarg.h
6. Export environment variables for gcc and g++
  • export CC=gcc-4.0
  • export CXX=g++-4.0
7. install e2fsprogs
  • sudo port install e2fsprogs
8. Build it!

9/28/2010

Snow Leopard Server: Booting Up With 32 or 64 Bit Kernel

Snow Leopard Server (SLS) has built in 32-bit and 64-bit kernel. You can choose to boot up with 32 or 64 bit kernel by using the following two methods.

Method 1:
  • Booting up your Mac and holding "6" and "4" key, the server will boot up with 64-bit kernel.
  • Booting up your Mac and holding "3" and "2" key, the server will boot up with 32-bit kernel.
Your Mac will revert to the default kernel (32-bit) next time you boot up.

Method 2:
  • The following command will change the default kernel to 64-bit.
sudo systemsetup -setkernelbootarchitecture x86_64
  • The following command will change the default kernel to 32-bit.
sudo systemsetup -setkernelbootarchitecture i386

This method will change the default boot kernel and will take effect every time when start up.

9/23/2010

Printing Java Call Stack

The following function could be use to print current java call stack.


Arrays.toString(new Throwable().getStackTrace()).replace(',', '\n')

12/18/2009

How to Remap Input Devices Button on Ubuntu - Using Kensington Expert Mouse as Example

Using Kensington Expert Mouse in Ubuntu

The default button mapping is hard to use, but there is no driver or utility to configure it. We can use xinput to change the button mapping.

First we have to find the device name of the mouse.
[list all plugged input devices]
$ xinput list

You will find the device named "Kensington Kensington Expert Mouse"(Notes, there is 6 blank characters between those two Kensington). That's the device we want to configure. Then try to get the button map of the device.
[get button map - print out all button id]
$ xinput get-button-map "Kensington Kensington Expert Mouse"

The result shows it has 12 buttons mapped, but we don't know the mapping to actual buttons. You can click on a button then use the following command to check whick id was in down state.
[query device state - print out button up or down]
$ xinput query-state "Kensington Kensington Expert Mouse"

Now we can remap the button mapping. In this case I want to set the right-upper button to be the "right button" of a regular mouse. so I use the following command.
[Set button map - setting button mapping]
$ xinput set-button-map "Kensington Kensington Expert Mouse" 1 2 3 4 5 6 7 3 9 10 11 12

Btw, If you want to know the vendor id or product id, use the following command.
vendor_id and product_id
$ cat /proc/bus/input/devices

12/14/2009

My last comment for Facebook when deactivatng my account

Facebook change the privacy policy last week, so I decide to deactivate my account and leave the following comments.

I am not agree with the new privacy policy about the friend list. Why should I let someone I don't know to browse my friends? It totally violated me and my friends. I know Facebook is the world leading social network provider and it is so popular around the world, but please don't forget the basis that make people use it.

12/12/2009

invalid conversion error in Android 1.6

Android 1.6 source code will build fail in emulator with gcc 4.4.1

It was caused by invalid conversion from const_char* to char*

To solve this issue, we have to cast const_char* to char*.

The break will issued in emulator/qtools/dmtrace.cpp and emulator/qtools/trace_reader.cpp

We have to fix those invalid conversion to make the build pass.

in emulator/qtools/dmtrace.cpp
line 166: char *paren = strchr(name, '('); => char *paren = (char *) strchr(name, '(');
line 183: char *dot = strrchr(name, '.'); => char *dot = (char *) strrchr(name, '.');

in emulator/qtools/trace_reader.cpp
line 1012: char *end = rindex(mmap_path, '@'); => const char *end = rindex(mmap_path, '@');
line 1015: char *start = rindex(mmap_path, '/'); => const char *start = rindex(mmap_path, '/');

11/08/2009

How to make Cisco AnyConnect vpn works on Ubuntu 9.10 64-bit

You have to install some .so files to make the vpn works on Ubuntu 9.10 64-bit version
Follow the following steps:

1. sudo apt-get install ia32-libs lib32nss-mdns
2. Download firefox from www.mozilla.com, we need so lib in the package.
3. Copy the following .so files to /opt/cisco/vpn/lib
# cd firefox
# sudo cp libnssutil3.so /opt/cisco/vpn/lib/
# sudo cp libplc4.so /opt/cisco/vpn/lib/
# sudo cp libplds4.so /opt/cisco/vpn/lib/
# sudo cp libnspr4.so /opt/cisco/vpn/lib/
# sudo cp libsqlite3.so /opt/cisco/vpn/lib/
# sudo cp libnssdbm3.so /opt/cisco/vpn/lib/
# sudo cp libfreebl3.so /opt/cisco/vpn/lib/
4. Lastly, copy entire folder of firefox to /usr/local/

Try vpn connect again.

11/05/2009

Forget Ubunto login password

What to do when you forget the login password in Ubuntu

Root privilege is required to reset the password. But in generally, Ubuntu not allow you to login as a root. You can use recovery boot to get the root privilege using the following steps.

1. Reboot the computer.
2. In Grub boot menu, press "e" key. If the menu was not show defaultly, press "ESC" when booting will go to Grub boot menu if your system is pre 9.10 or hold "SHIFT" key when booting will invoke the menu if the system is 9.10 or after.
3. In boot menu, select recovery mode.
4. After boot up, it will show some options, select "root prompt"
5. Now you will get a shell with root privilege, use passwd "username" to reset the password.

11/04/2009

Adjust Eclipse java heap size

Enlarge the java heap size to improve the performance of Eclipse.
Edit the file eclipse.ini under the folder of Eclipse.

Modify:

-XX:PermSize=256M
-XX:MaxPermSize=256M

to:

-XX:PermSize=256M
-XX:MaxPermSize=512M

Enable New Lenovo ThinkPad USB Keyboard with Trackpoint on Ubuntu 9.10

How to enable the middle key scrolling function of Lenovo ThinkPad USB Keyboard with Trackpoint on Ubuntu 9.10?

Add a file named mouse-wheel.fdi at /etc/hal/fdi/policy/ with the following content.


<match key="info.product" string="Lite-On Technology Corp. ThinkPad USB Keyboard>
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>
<merge key="input.x11_options.YAxisMapping" type="string">4 5</merge>
<merge key="input.x11_options.XAxisMapping" type="string">6 7</merge>
<merge key="input.x11_options.Emulate3Buttons" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelTimeout" type="string">200</merge>
</match>


Restart the computer!

8/17/2009

Java reference type

以下連結針對Java soft reference及weak reference有很棒的解說

http://blog.centuryminds.com/2007/11/weak-and-soft-references-in-java/

7/21/2009

Android 1.5 source code build error in Ubuntu 9.04

Issue:
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/sockets.o] Error 1

Solution:
Modify "external/qemu/Makefile.android"
Original:
# this is needed to build the emulator on 64-bit Linux systems
ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
MY_CFLAGS += -Wa,--32
endif

Modified:
# this is needed to build the emulator on 64-bit Linux systems
ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
MY_CFLAGS += -Wa,--32 -D_GNU_SOURCE
endif