Monday, June 1, 2015

Truth in life

1、当你对某件事情抱着百分之一万的相信,它最后就会变成事实。


2、期望定律


期望定律告诉我们,

当我们怀着对某件事情非常强烈期

望的时候,我们所期望的事物就会出现。


3、情绪定律


情绪定律告诉我们,

人百分之百是情绪化的。

即使有人说某人很理性,其实当这个人很有"理性"地思考问题的时候,也是

受到他当时情绪状态的影响,"理性地思考"本身也是一种情绪状态。

所以人百分之百是情绪化的动物,

而且任何时候的决定都是情绪化的决定。


4、因果定律


任何事情的发生,都有其必然的原因。有因才有果。换句话说,当你看到任何现象的时
候,你不用觉得不可理解或者奇怪,因为任何事情的发生都必有其原因。你今天的现状
结果是你过去种下的因导致的结果。


5、吸引定律


当你的思想专注在某一领域的时候,跟这个领域相关的人、事、物就会被你吸引而来。


6、重复定律


任何的行为和思维,只要你不断的重复就会得到不断的加强。

在你的潜意识当中,只要你能够不断地重复一些人、事、物,它们都会在潜意识里变成
事实。

7、累积定律

很多年轻人都曾梦想做一番大事业,其实天下并没有什么大事可做,有的只是小事。一
件一件小事累积起来就形成了大事。任何大成就或者大灾难都是累积的结果。

8、辐射定律

当你做一件事情的时候,影响的并不只是这件事情的本身,它还会辐射到相关的其他领
域。任何事情都有辐射作用。


9、相关定律

相关定律告诉我们:这个世界上的每一件事情之间都有一定的联系,没有一件事情是完
全独立的。

要解决某个难题最好从其他相关的某个地方人手,而不只是专注在一个困难点上。


10、专精定律


专精定律告诉我们,只有专精在一个领域,这个领域才能有所发展。所以无论你做任何
的行业都要把做该行业的最顶尖为目标,

只有当你能够专精的时候,你所做的领域才会出类拔萃地成长。

11、替换定律

替换定律就是说,当我们有一项不想要的记忆或者是负面的习惯,我们是无法完全去除
掉,只能用一种新的记忆或新的习惯去替换他。

12、惯性定律

任何事情只要你能够持续不断去加强它,它终究会变成一种习惯。

13、显现定律

显现定律就是说,当我们持续寻找、追问答案的时候,它们最终都必将显现。


14、需求定律

任何人做任何事情都是带有一种需求。尊重并满足对方的需求,别人才会尊重我们的需求

Monday, June 27, 2011

how to mount flash drive in Redhat

error:
A security policy in place prevents this sender from sending this message to this recipient, see message bus configuration file (rejected message had interface “org.freedesktop.Hal.Device.Volume” member “Mount” error name “(unset)” destination “org.freedesktop.Hal”)

solution:
(1) gedit /etc/dbus-1/system.d/hal.conf
(2)
option 1:
  












option 2:
groupadd
usermod/useradd











(3) restart

Tuesday, April 5, 2011

How to print a word (two bytes) in assembly

assume the data that need to be printed are in DX register. CX(CL) is the counter to be used to shift the bit of DX. At the end of the code, ascii 13 + ascii 10 are equivalent to "\r\n"


test_word:
movb $16, %cl
test_word_loop:
subb $4, %cl
movw %dx, %ax
shr %cl, %ax
andw $0x000f, %ax
cmpb $10, %al
jl test_word_less
addb $7, %al #prepare for A,B,C...because 17+48=65(A)

test_word_less:
addb $48, %al
movb $0xe, %ah
movw $7, %bx
int $0x10
cmpb $0, %cl
jne test_word_loop
movb $13, %al
int $0x10
movb $10, %al
int $0x10
ret

Monday, April 4, 2011

How to print register value in assembly language

Here is the AT&T assembler function I came up with in order to print something during the Linux kernel debugging. Assuming the lower FOUR bits of CX (CL) are use as a value we want to print a HEX of, according to ascii table:

test_func:
andb $0x0f, %cl #mask the higher four bits
cmpb $10, %cl #see if we need 1,2,3,4...or A,B,C,D...
jl test_less #if the value is less than 10, jump
subb $10, %cl #if the value if larger or equal to 10, offset it
addb $17, %cl #prepare for A,B,C...17+48=65, can use addb %3, %cl as well

test_less:
addb $48, %cl #Then the result is stored in CL, call int 0x10 to print it
ret

Monday, March 28, 2011

How to debug new Linux kernel (2.6.38) using Eclipse Helios and Qemu

(1) Make sure you have the latest QEMU from its official website and install SDL (Simple Directmedia Layer) and Eclipse Helios CDT package from Eclipse website.
(2) refer to the post
http://issaris.blogspot.com/2007/12/download-linux-kernel-sourcecode-from.html
for basic setup.


Below are specific to Eclipse Helios (different from the post above):
(3) ON the menu "Run -> Debug configurations", double-click "C/C++ Application", on the right panel, make sure you got a name for this configuration. Then on the "Main" tab, click "Search project" and select "vmlinux", then NOTE: under the "vmlinux" subcategory, select the one that is NOT compressed, i.e., select "root_project_directory/vmlinux" NOT "root_project_directory/arch/x86/boot/compressed/vmlinux".

(4) Note that at the bottom of the "Main" tab, just above the "apply" and "revert" bottons, there is "Using GDB(DSF) create process launcher-select other..". We want to use another launcher because this GDB(DSF) one doesn't come with TCP connectivity. So click on "select other..", then tick "Use configuration specific setting" enabling the selection list below, then select "Standard create process launcher", then click "OK" to dismiss the "Select Preferred Launcher" dialog.

(5) Back to "Debug Configurations" dialog, click the "Debugger" tab, underneath it you will find the desired "Debugger" drawdown list, go with the post above and select "gdbserver", then pick your "Stop on startup at" (start_kernel in the post), click the "Connection", fill in "TCP", "1234", etc..then "Apply", "Close" the dialog.
(NOTE that here you have to disable the autobuild feature before debug of Eclipse. Else the debugger will NOT successfully stop execution at start_kernel(). The reason is: you first start Qemu to let the execution hang at the start point, then you turn to Eclipse to start the debugger. If you enable "autobuild", then when you try to start debugger, it will rebuild everything and the bzImage that you used to start Qemu will be replaced. That I guess will mess up the debugger. I notice this when Qemu seems to reload the kernel and flash the screen when the debugger is started)
(6) The rest steps are the same as the post. Enjoy, I know I'm thrilled..

Sunday, March 27, 2011

How to create a Linux Debian File System

(1) dd if=/dev/zero of=output.img bs=1M count=4096 //create 4G empty file
(2) mkfs -t ext4 output.img
(3) mount -o loop output.img /mnt/mount_point
(4) debootstrap sid /mnt/mount_point http://ftp.us.debian.org/debian/
(5) chroot /mnt/mount_point
(6) passwd root
(7) umount /mnt/mount_point

Using kernel and file system in QEMU

If prefer to using kernel and file system separately in QEMU, get an disk img ready and use:

qemu -hda disk.img -kernel your_kernel -append "root=/dev/sda"

work with QEMU Linux-0.2.img and 2.6.38.1 kernel

Saturday, March 26, 2011

AT&T T-Mobile Merger

This merger just reminds me of the Chinese market where China Mobile and Unicom are the only two companies that offer wireless services (later China Telecom struggled to blend in). And all Chinese customers pay ridiculously high fee for every wireless service. Cannot believe this kind of thing will ever happen in the USA.

Wednesday, March 23, 2011

How to add google code as Maven remote repository

onejar-maven-plugin.googlecode.com

http://onejar-maven-plugin.googlecode.com/svn/mavenrepo

Tuesday, March 8, 2011

Set environment variable for sudo in Ubuntu

(1) edit /etc/environment
(2) edit /etc/bash.bashrc
(3) use sudo -E to use the user's variables

Saturday, February 12, 2011

Blank page before the title page in Latex

If after compiling, there is a blank page before the title page, it's mostly likely that the "\thanks" part is outside of the "\author".

Monday, January 10, 2011

Destiny

Every creature has its own destiny to fulfill.
The path set for it is pre-determined by the universe.

Sometimes,
it will desperately strive to blend in the groups that are out of its league,
but in vain.

Destiny will sometimes let it try and have some experience from those groups.
But in the end,
inevitably,
it will be reset to its own league,
living back to its own world.

How marvellous!

You will know it when you get what it takes,
luck will never be your side, not even occasionally.

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原声碟

尽管Call of Duty Modern Warfare的背景音乐也不错,但是大师毕竟是大师,Hans Zimmer在Modern Warfare II中的作曲表现对该作品在英美游戏排行榜的影响应该是功不可没的。从动画片狮子王,特种作战大片石破天惊到现在的现代战争2,大师的每次背景音乐总能展现深厚,雄伟,旷大的气势。尽管不是反映历史沉重的题材,但军乐队,交响乐及电子合成交替的完美运用却隐约展现一种沉淀,以至于将作品衬托为史诗般的巨作,的确能够让人不惜滥美之词。本文针对现代战争2的原声碟发表一些个人对应观点,顺便For the Record


Safeguard
































Guerrilla Tactics














Deadline














Breach



























Ordinance













Code of Conduct













Protocol













Friday, August 27, 2010

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

(1) follow aclevername.com
(2) get the product id right in >>lsusb
(3) install usb-driver-HEAD.tar.gz

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"