# Run ifconfig by manual for changing HW MAC
rmmod forcedeth
sleep 3
modprobe forcedeth
sleep 30
ifconfig eth0 hw ether 00:40:63:DD:89:9E
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up
route add default gw 192.168.1.1
2009年2月20日 星期五
2009年2月8日 星期日
Google latitude service
Recently, Google announce my location service can be shared to friends you want to him/her to know your location. This is very great service to bi-direct GPS add-on service.
Detail info, see http://m.google.com/latitude
Detail info, see http://m.google.com/latitude
Labels:
Google
2009年1月20日 星期二
The difference of "==" and "equals" in Java language
Here is an example of == and equals
在Java裡,equals和==常令程式設計師困惑,這裡簡單說明如下:
1. ==
測試物件參考時,唯有當兩個參考指向同一物件時,==運算子的結果才為true,同樣的,唯有當兩個參考指向不同物件時,!=運算子的結果才為true,這兩個運算子的處理與物件的內容無關。需要特別注意的是,在String中使用==,因為Java為節省記憶體,會在某一輪調區中維護唯一的String物件,所以如果在類別裡使用同一字串,Java只會建立一個唯一的字串而已。
2. equals
另一種測試的做法是equals,equals在類別為Java原先就存在時,是比較兩個物件是否為相同類型的類別後再比較其內容值是否相同,是就傳回true,否就傳回false。當要測試的類別是自定類別時,要依自定類別所提供的equals來決定如何比較,如果自定類別沒有覆蓋Object的equals類別的話,就以Object的equals來比較,Object的equals的比較方式如同==。
public class myEquals {
public myEquals() {
//字串型別
String sA = "ABC";
String sB = "ABC";
String sC = new String("ABC");
//==的比較
if (sA == sB)
System.out.println("sA == sB");
else
System.out.println("sA != sB");
if (sA == sC)
System.out.println("sA == sC");
else
System.out.println("sA != sC");
//equals的比較
if (sA.equals(sB))
System.out.println("sA.equals(sB) = true");
else
System.out.println("sA.equals(sB) = false");
if (sA.equals(sC))
System.out.println("sA.equals(sC) = true");
else
System.out.println("sA.equals(sC) = false");
//Java原有的型別
Long lngA = new Long(100);
Long lngB = new Long(100);
Long lngC = new Long("100");
//==的比較
if (lngA == lngB)
System.out.println("lngA == lngB");
else
System.out.println("lngA != lngB");
if (lngA == lngC)
System.out.println("lngA == lngC");
else
System.out.println("lngA != lngC");
//equals的比較
if (lngA.equals(lngB))
System.out.println("lngA.equals(lngB) = true");
else
System.out.println("lngA.equals(lngB) = false");
if (lngA.equals(lngC))
System.out.println("lngA.equals(lngC) = true");
else
System.out.println("lngA.equals(lngC) = false");
//自定型別
myObject1 m1A = new myObject1();
myObject1 m1B = new myObject1();
myObject2 m2A = new myObject2();
myObject2 m2B = new myObject2();
//==的比較
if (m1A == m1B)
System.out.println("m1A == m1B");
else
System.out.println("m1A != m1B");
if (m2A == m2B)
System.out.println("m2A == m2B");
else
System.out.println("m2A != m2B");
//equals的比較
if (m1A.equals(m1B))
System.out.println("m1A.equals(m1B) = true");
else
System.out.println("m1A.equals(m1B) = false");
if (m2A.equals(m2B))
System.out.println("m2A.equals(m2B) = true");
else
System.out.println("m2A.equals(m2B) = false");
}
public static void main(String[] args) {
myEquals myEquals1 = new myEquals();
}
}
執行結果
sA == sB
sA != sC
sA.equals(sB) = true
sA.equals(sC) = true
lngA != lngB
lngA != lngC
lngA.equals(lngB) = true
lngA.equals(lngC) = true
m1A != m1B
m2A != m2B
m1A.equals(m1B) = false
m2A.equals(m2B) = true
在Java裡,equals和==常令程式設計師困惑,這裡簡單說明如下:
1. ==
測試物件參考時,唯有當兩個參考指向同一物件時,==運算子的結果才為true,同樣的,唯有當兩個參考指向不同物件時,!=運算子的結果才為true,這兩個運算子的處理與物件的內容無關。需要特別注意的是,在String中使用==,因為Java為節省記憶體,會在某一輪調區中維護唯一的String物件,所以如果在類別裡使用同一字串,Java只會建立一個唯一的字串而已。
2. equals
另一種測試的做法是equals,equals在類別為Java原先就存在時,是比較兩個物件是否為相同類型的類別後再比較其內容值是否相同,是就傳回true,否就傳回false。當要測試的類別是自定類別時,要依自定類別所提供的equals來決定如何比較,如果自定類別沒有覆蓋Object的equals類別的話,就以Object的equals來比較,Object的equals的比較方式如同==。
public class myEquals {
public myEquals() {
//字串型別
String sA = "ABC";
String sB = "ABC";
String sC = new String("ABC");
//==的比較
if (sA == sB)
System.out.println("sA == sB");
else
System.out.println("sA != sB");
if (sA == sC)
System.out.println("sA == sC");
else
System.out.println("sA != sC");
//equals的比較
if (sA.equals(sB))
System.out.println("sA.equals(sB) = true");
else
System.out.println("sA.equals(sB) = false");
if (sA.equals(sC))
System.out.println("sA.equals(sC) = true");
else
System.out.println("sA.equals(sC) = false");
//Java原有的型別
Long lngA = new Long(100);
Long lngB = new Long(100);
Long lngC = new Long("100");
//==的比較
if (lngA == lngB)
System.out.println("lngA == lngB");
else
System.out.println("lngA != lngB");
if (lngA == lngC)
System.out.println("lngA == lngC");
else
System.out.println("lngA != lngC");
//equals的比較
if (lngA.equals(lngB))
System.out.println("lngA.equals(lngB) = true");
else
System.out.println("lngA.equals(lngB) = false");
if (lngA.equals(lngC))
System.out.println("lngA.equals(lngC) = true");
else
System.out.println("lngA.equals(lngC) = false");
//自定型別
myObject1 m1A = new myObject1();
myObject1 m1B = new myObject1();
myObject2 m2A = new myObject2();
myObject2 m2B = new myObject2();
//==的比較
if (m1A == m1B)
System.out.println("m1A == m1B");
else
System.out.println("m1A != m1B");
if (m2A == m2B)
System.out.println("m2A == m2B");
else
System.out.println("m2A != m2B");
//equals的比較
if (m1A.equals(m1B))
System.out.println("m1A.equals(m1B) = true");
else
System.out.println("m1A.equals(m1B) = false");
if (m2A.equals(m2B))
System.out.println("m2A.equals(m2B) = true");
else
System.out.println("m2A.equals(m2B) = false");
}
public static void main(String[] args) {
myEquals myEquals1 = new myEquals();
}
}
執行結果
sA == sB
sA != sC
sA.equals(sB) = true
sA.equals(sC) = true
lngA != lngB
lngA != lngC
lngA.equals(lngB) = true
lngA.equals(lngC) = true
m1A != m1B
m2A != m2B
m1A.equals(m1B) = false
m2A.equals(m2B) = true
Labels:
Java
2009年1月7日 星期三
What is qemu?
http://en.wikipedia.org/wiki/QEMUToday I can't use my embedded board, because I don't have serial console line on hand today. So I try to find a simulator tool to run my ARM based software without HW.
Here is the qemu download url -
http://www.jk2410.org/release/host/qemu/qemu-jk2410-20080809.tar.bz2
Installation step is very easy, I did the follows
$tar jxvf qemu-jk2410-20080809.tar.bz2
$sudo apt-get install gcc-3.4
$sudo apt-get install libsdl-dev
$cd qemu-jk2410-20080809
$./configure --cc=/usr/bin/gcc-3.4 --target-list=arm-softmmu
$make
$sudo make install
Labels:
Embedded Linux
2009年1月5日 星期一
How to check CPU endian on Embedded Linux
Sometimes you don't know what type of CPU endian on your ARM platform. Here you can write a very simple program to test
/* Test CPU Endian */
#include
#include
int main() {
if (htons(1) == 1) puts("big endian");
else puts("little endian");
return 0;
}
/* End */
Labels:
Embedded Linux
2008年5月10日 星期六
Breeze to Connect .. not easy road
I am responsible to manage the Macromedia Breeze and HomeMeeting Joinnet Video Conferencing Server. Yesterday, I upgraded Breeze to Adobe Connect Enterprise Server. It was not a easy job to complete, but I did.
I need to backup MS SQL 2000 Database, Breeze original files to a safe place. Then uninstall SQL 2000. Because It recommend SQL 2005 would be better, so I must use its embedded MSDE SQL 2005 since I don't have licensing SQL 2005 on hand.
When all of database issue was solved, I would be allowed to run setup program.
After files copied was completed, It also need to migrate the Database contents and configuration files. Do you think it finish? Not yet, I must try if the service is working by accessing the web.
It is so luck and Adobe have many support tips can help me to solve issue step by step.
All of thing is running normally now.
I need to backup MS SQL 2000 Database, Breeze original files to a safe place. Then uninstall SQL 2000. Because It recommend SQL 2005 would be better, so I must use its embedded MSDE SQL 2005 since I don't have licensing SQL 2005 on hand.
When all of database issue was solved, I would be allowed to run setup program.
After files copied was completed, It also need to migrate the Database contents and configuration files. Do you think it finish? Not yet, I must try if the service is working by accessing the web.
It is so luck and Adobe have many support tips can help me to solve issue step by step.
All of thing is running normally now.
Labels:
Jobs
2008年5月8日 星期四
How to synchronize FTP contents by light way
Our company have many contents from Partner's ftp sites need to keep synchronizing in time, and send notification email to guys who need to know latest updates.
I used following method to let this work by automatic. It only get changed files when remote FTP contents were changed.
1) Get a perl script(ftpsync.pl) writted by Christoph Lechleitner ( ftpsync at ibcl.at )
http://ftpsync.sourceforge.net/
2) Add some output information to a file which will be used to send information
3) Install esmtp package into Linux System
4) Add a script into cron job at AM 2:00(Taiwan timezone)
I used following method to let this work by automatic. It only get changed files when remote FTP contents were changed.
1) Get a perl script(ftpsync.pl) writted by Christoph Lechleitner ( ftpsync at ibcl.at )
http://ftpsync.sourceforge.net/
2) Add some output information to a file which will be used to send information
3) Install esmtp package into Linux System
4) Add a script into cron job at AM 2:00(Taiwan timezone)
#!/bin/bash
/root/ftpsync.pl -g ftpserver=xx ftpuser=xx ftppasswd=xx ftpdir="/" /root/ftp
sleep 10
mount -t cifs -o username=xx,password=xx,codepage=cp950 //xx/SEShare /root/seshare
sleep 10
rsync -a /root/ftp/. "/root/seshare/"
sleep 10
cd /
umount /root/seshare
#Send notification email to cbu group
cd /root
domail=`cat /root/ttt.txt wc -c`
to='To: abc@c.d.e.f'
from='From: xyz@c.d.e.f'
subject='Subject: [News - xx] New update file in BulletinBoard'
echo $to > /root/mail.txt
echo $from >> /root/mail.txt
echo $subject >> /root/mail.txt
echo >> /root/mail.txt
cat /root/ttt.txt >> /root/mail.txt
if [ "$domail" = "0" ]; then echo "Don't send email if empty update"
else
cat /root/mail.txt | esmtp abc@c.d.e.f -f xyz@c.d.e.f
fi
訂閱:
文章 (Atom)