12/09/2008

you and i both

演唱:jason mraz

Was it you who spoke the words that things would happen but not to me?
All things are gonna happen naturally
Oh, taking your advice and I'm looking on the bright side
And balancing the whole thing.

Oh, but at often times those words get tangled up in a lines
And the bright light turns to night
Oh, until the dawn it brings
Another day to sing about the magic that was you and me

Cause you and I both loved
What you and I spoke of
And others just read of
Others only read of, of the love
Of the love that I loved

lova lova!

See I'm all about them words
Over numbers, unencumbered numbered words;
Hundreds of pages, pages, pages for words.
More words than I had ever heard, and I feel so alive.

Cause you and I both loved
What you and I spoke of
And others just read of
And if you could see me now
Oh, love love
You and I, You and I
Not so little you and I anymore

And with this silence brings a moral story
More importantly evolving is the glory of a boy

Cause you and I both loved
What you and I spoke of (of, of)
And others just read of
And if you could see me now
Well, then I'm almost finally out of
I'm finally out of
Finally deedeedeedeedeedee
Well I'm almost finally, finally
Well I am free
Oh, I'm free

And it's okay if you had to go away
Oh, just remember that telephones
Well, they work out of both ways
But if I never ever hear them ring
If nothing else I'll think the bells inside
Have finally found you someone else and that's okay
Cause I'll remember everything you sang

Cause you and I both loved
What you and I spoke of (of,)
And others just read of
and if you could see me now
Well, then I'm almost finally out of
I'm finally out of
Finally deedeedeedeedeede
Well I'm almost finally, finally
Out of words

11/15/2008

Apache+MySQL+PHP+OpenSSL in Ubuntu

SSL介紹 SSL(Secure Socket Layer)是Netscape所提出來的資料保密協定,採用了RC4、MD5,以及RSA等加密演算法。

網路上需要確定網站真的是那個網站,所以SSL也具備認證的機能。SSL是以金字塔的結構 組成,最下層的是一般的伺服器,它們經由向上跟CA申請取得SSL的憑證,CA會在SSL相關檔案上簽名,CA是具有公信力和認證能力的機構,CA必須向上跟RootCA(如政府機構等)申請。當使用者連結具SSL的服務時,伺服器會傳送憑證給使用者,使用端的程式接收到憑證後會向CA確認憑證,若CA確認這個憑是它們簽發的則會回傳給使用端正確的訊息。 具有SSL功能的網站可以向 世界少數幾個發證機構(例如目前最大的VeriSign或第二大的Thawte兩家認證公司)申請,經過嚴格的文件證明確認後,才能取得國際認可(較新版 的MSIE或Netscape瀏覽軟體會自動認得)的電子認證。

所有 SSL憑證都是發給公司或是法人,典型的 SSL 憑證將包括您的網域名稱(domain name)、您的公司名稱(company name)、您的住址(address)、您的所在城市(city)、您的省份(state)和您的國家(country),它也包含了憑證的到期日和負責核發此憑證的發證中心詳細資料。當一個瀏覽器連結到一個安全網站時,它將收到這個網站的SSL憑證並且檢驗它是否過期、它是否是已經被瀏覽器信任的發證中心所核發的,以及它是否如核發時 所登記的內容被該網站使用,假如有任何一項檢查不通過,瀏覽器將顯示一個警告訊息給使用者。

在Ubuntu上安裝 apache+mysql+php+openssl
sudo tasksel install lamp-server
安裝 lamp (apache mysql php)

sudo apt-get install mysql-admin mysql-gui-tools-common mysql-query-browser
安裝mysql的管理介面

sudo apt-get install -y php5-gd
安裝GD庫

sudo apt-get install -y openssl
安裝Openssl

sudo apt-get install -y ssl-cert
安裝簽署憑證的工具

sudo a2enmod ssl
安裝ssl模組

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
sudo ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl
複製一份預設擋供ssl用,並且用ln建立連結(捷徑)至sites-enabled/ssl

sudo vim /etc/apache2/sites-enabled/ssl
在以下位置後面加入紅色的設定值

NameVirtualHost *:443


sudo vim /etc/apache2/sites-enabled/default
在以下位置後面加入紅色的設定值

NameVirtualHost *:80
SSLEngine On
SSLCerficationFile /etc/apache2/etc/apache.pem


sudo vim /usr/sbin/make-ssl-cert
將"-keyout $output"改成"-keyout $output -days 3650"即可將憑證有效時間改成10年

sudo mkdir /etc/apache2/ssl
建立ssl憑證所擺放目錄

sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/etc/apache.pem
make-ssl-cert is a wrapper of OpenSSL
依照指示輸入憑證相關訊息,即可產生自簽的電子證書!

sudo /etc/init.d/apache2 force-reload
重新載入配置

sudo /etc/init.d/apache2 restart
重新啟動Apache2
產生自簽的CA 產生自簽的CA的意義是,自己架設一個CA,並為自己的伺服器的憑證簽名。則使用端收到憑證時,會向CA確定,這時就用自己架的CA去確認說憑證是有效的。當然這樣是沒有公信力的,而且把自己架的伺服器登記為CA需要手動加入,一般這樣做都是為了測試用。

參考以下連結
http://wiki.ubuntu.org.cn/OpenSSL 主要做兩件事情
第一件是架CA:Creating the Certificate Authority
第二件是架server:Creating a Self-Signed Server Certificate
並使用自己的CA為它簽名

11/09/2008

Reverse Engineering Tools

Microsoft Windows

Three tools pervade the warchest of the contemporary analyst on the Windows platform: IDA, SoftICE, and PE Tools. IDA is the Interactive Disassembler from Data Rescue. IDA is used to examine the executable on-disk. IDA provides useful features such as call graphs for analyzing program flow and automatic library detection.

SoftICE is a Ring 0 debugger from Compuware. Though SoftICE is no longer an offering from Compuware, it's use is still very common. While the author now uses WinDbg in place of SoftICE, some analysts have turned to OllyDbg. It is presumed that once Compuware decides to sell SoftICE, the debugger will regain it's previous popularity.

PE Tools is used to dump either a partial (region) or full in-memory image of an executable. It also includes the ability to automatically remove "Anti Dump Protection", and find the original OEP (AddressOfEntryPoint value of the IMAGE_OPTIONAL_HEADER structure). This tool would be used with a packed or encrypted executable. After the decompression or decryption occurs, PE Tools would be used to copy the image from memory for further analysis.

IDA is used to perform a static analysis on-disk, while a debugger is used to interrogate the executing program while in-memory. Based on the tools, this leads to the observation that a Protection Scheme must be functional in two environments - on-disk and in-memory. In the virus research community, challenging disassembly occurs in the anti-disassembly layer, while the implementation deterring dynamic analysis is known as a anti-debug layer.

Unix and Linux

For Unix and Linux, objdump (with it's PERL based wrapper dasm) and gdb are two available tools. gdb supports debugging of C, C++, Java, Fortran and Assembly among other languages. In addition, gdb is designed to work closely with the GNU Compiler Collection (GCC). objdump and dasm collectively act as full disassembler. Alternately, one can run Windows applications such as IDA on Linux using Wine, which acts as a compatibility layer for running Windows programs on Linux. Kris Kaspersky introduces additional tools and details procedures specific to the ELF file format in Hacker Disassembling Uncovered.

11/06/2008

人生第一筆薪水

就在今天
我拿到人生第一筆薪水了
真是莫名的感動

因為八九十月沒收入 債台高築
償還債務後也剩不下來
但我還是要好好記念今天 哈

11/03/2008

struct的特別用法

#include 

typedef struct A {
    int up : 1;
    int down : 1;
    int left : 1;
    int right : 1;
}Cell;

int main(void) {
    Cell c;

    c.up = c.down = c.left = c.right = 0;
    c.down = 1;
    printf("%d %d\n", sizeof(Cell), sizeof c);
    printf("%d %d %d %d\n", c.up & 1, c.down & 1, c.left & 1, c.right & 1);
    printf("%d %d %d %d\n", c.up, c.down, c.left, c.right);
    return 0;
}
結果:
4 4
0 1 0 0
0 -1 0 0

宣告的變數會變成bit-field struct因padding大小是4個byte.
裡面的變數都是bit 只能做bit operator 否則結果不是你想要的.

10/27/2008

Bizarre Love Triangle

Every time I think of you
I get a shot right through into a bolt of blue
It's no problem of mine but it's a problem I find
Living a life that I can't leave behind
There's no sense in telling me
The wisdom of a fool won't set you free
But that's the way that it goes
And its what nobody knows
And every day my confusion grows
Every time I see you falling
I get down on my knees and pray
I'm waiting for that final moment
You'll say the words that I can't say

I feel fine and I feel good
I feel like I never should
Whenever I get this way, I just don't know what to say
Why cant we be ourselves like we were yesterday
I'm not sure what this could mean
I don't think youre what you seem
I do admit to myself
That if I hurt someone else
Then wed never see just what were meant to be
Every time I see you falling
I get down on my knees and pray
I'm waiting for that final moment
You'll say the words that I cant say

10/17/2008

Symbian S60 5th Edition

Symbian的第五版在10/3 released
這版中主要加強的部份是多媒體、網路、可靠度和觸控介面

第五版中優化攝影機的codec(宽螢幕影相儲存能力)。使用者設定參數來調控照片的balance, color and sharpness。次外,第五版包含照片和影片的編攝功能,讓使用者直接在mobile上修改並分享。

隨著寬螢幕 nHD的支援,現在可以使用寬螢幕模式來看照片或影片,支援的影片格式包括MP3, AAC, H.264, Windows Media, Flash Video等。

內建瀏覽器和支援Flash Lite,加上寬螢幕和觸控介面的支援可以令瀏覽網頁更方便。

10/04/2008

英名一世?

沒想到現在這麼囧

一直都是學最新的東西

現在居然要學MFC MFC MFC MFC MFC MFC MFC

10/01/2008

default constructor

C++中預設建構子就是沒有參數的建構子

一般大多數人都有以下錯誤觀念:
1.class沒有定義預設建構子 compiler就會自動產生一個
2.compiler產生出來的預設建構子中 會為member data設預設值

在C++ standard(ISO/IEC 14882)中說明:
"The implementation will implicitly declare these member functions for a class type when the program does not explicitly declare them, except as noted in 12.1. The implementation will implicitly define them if they are used"

當compiler有需要而又沒有時才會產生出來 所以沒需要時就不會產生

那甚麼時候需要呢! 文件中說明:
"If there is no user-declared constructor for class X, a default constructor is implicitly declared. An implicitly-declared default constructor is an inline public member of its class. A constructor is trivial if it is an implicitly-declared default constructor and if: — its class has no virtual functions (10.3) and no virtual base classes (10.1), and — all the direct base classes of its class have trivial constructors, and — for all the nonstatic data members of its class that are of class type (or array thereof), each such class has a trivial constructor. Otherwise, the constructor is non-trivial."

所以說需要的定義取決於 1.virtual functions, 2.virtual inherited, 3.base class and 4.data members.

1.virtual functions
當一個類別定義virtual functions後,每一個物件都必須有一個virtual function table記錄virtual function的位址,因此compiler會自動擴張物件的data member,產生這個table並且加入一個指標指向這個table。

2.virtual inherited
(待補)

3.base class
當一個class沒有任何預設建構子而它的base class有預設建構子時,那麼必須需呼叫base class的預設建構子,所以compiler自動擴張一個預設建構子,其中呼叫bass class的建構子。

如果存在建構子的話,compiler會擴張建構子做上述事情而不擴張一個預設建構子。文件的解析是由於使用者定義的建構子存在下就不會隱含產生預設建構子。

4.data members
同理。當data member中,存在至少一個物件有預設建構子時。

18

記念一下

我將是公司的第18位RD

9/26/2008

創業成功的必要條件

規則#1:擁有一個具爭議性的策略。尋找反直覺的構想,然後執行。如果你照規矩來,你只會流於一般。區別才是關鍵。困難的是,你必須判斷正確。

規則#2:打破商業陳規,但不可用詐騙、說謊或偷竊的方式。這麼做,你將落得眾叛親離,失去忠誠員工對你的信賴。

規則#3:想辦法籌得一些錢,但不要太多。小數目的創業資本會迫使你錙銖必較、節省支出、追求效率,並且努力尋找新的生產途徑。

規則#4:具備一個理想。McNealy說:「人類大都是金錢驅動的,但他們也喜歡有一點精神上的收入。」例如,昇陽創造的開放原始碼學科維基Curriki,就解決了McNealy和他兒子作小學報告所碰到的問題。

規則#5:放手去作,但慎選伴侶。投入你全副的心力和靈魂去開創事業,但請在結婚之前。McNealy直到39歲才結婚,但婚後四個兒子接連出生。他建議:「你一生中最重要的決定就是和誰結婚生子。挑選一個配偶或重要的另一半,或任何你喜歡的伴侶。只要確定你挑了一個好人。這是一個創業者給你的一些實在的技術性建議。」

9/25/2008

tricky skill (1) in C

struct rumble {
  char c[1];
};

struct rumble *p = (struct rumble*) malloc(sizeof(struct rumble) + 5);
在C裡 有一個技巧就是在struct最後宣告一個單一元素的陣列
於是在malloc時就能擁有可變大小的struct rumble了

當然這個技巧也能用在C++ 但這會與compiler有關
因為雖然宣告在最後 compile時可能會產生額外的資料在最尾端

9/24/2008

預設值和多型的陷阱

class A {
  virtual void f(int i = 10);
};

class B: public A {
  void f(int i = 20);
};

A* a = B();
a->f();
這題多型很簡單 a->f()會呼叫class B裡的f()
但問題是如果印i出來 值會是多少呢

答案是i = 10
原因是預設引數是在編譯時期根據a的型別確定了
所以i就被初始為10
最後印出來就是10了

9/10/2008

last order

演唱:陳奕迅
作曲:Eric Kwok, 編曲:Eric Kwok
監製:Eric Kwok, 填詞:黃偉文

沒關係 真的沒關係 我也許 早就該回去
再一杯 我告訴自己 到此為止 乾了不再續
麻煩你 加冰威士忌 對不起 來個DOUBLE的
喝到這裡 終於夠勇氣 說一個經歷

*那晚下雨 在這店裡 也放著這首曲
 有個男子 搭上一個女子 反正失戀 他當然不介意 有段艷遇
 只是回到 他的家裡 十幾坪 家徒四壁
 一聲不響 那女的 掉頭離去
 就像 三個小時前 未婚妻 初次到來 嫌棄的樣子
(就像 我的未婚妻 對不起 好像說成是我的樣子 我是沒關係)

沒關係 真的沒關係 一晚上 就失戀兩次
那男子 還不懂懷疑 到底自己是否沒出息
不客氣 別給我ICE TEA 客人們不是我嚇跑的
別看著我 這個不過是 我朋友的經歷

Repeat #()

9/07/2008

誰才是主人呀

我的貓每天都跟我爭椅子座
有沒有搗錯

每次一從電腦前離開
牠馬上坐上去 趕也不走
分明是要爭主人位咩

9/01/2008

弱雞

前天被說是弱雞
我卻一點都不能反駁
唉...

我的右手呀
自從五月一場籃球比賽受傷後
超過一公斤的東西都不太能拿
拿了就受傷了
搬東西也不行

幹~~~

8/28/2008

多型的陷阱

class A {...};
class B {...};
class C: public A, private B {...};

A a = new C();
B b = new C();
在C++中,繼承有public, protected and private
如果使用private的話 第6行編譯是不會過的 因為privated下是看不到的
如果是protected 則在可視scope下才能用

這點是java或其他OO語言沒有的

8/27/2008

差點被考到的程式碼

昨天面試 其中一個主管很在意coding能力
我也跟他說我coding很好
他就要考考我
考了兩題後 他發現太無趣了 就從一堆題目中找了一題出來
說這題過去沒幾個人講的出來
#define fun(A, b) (int)(&(((A *)0)->b))

typedef struct {
  char str[40];
  int type;
  int maxLen;
} intf;
問題是fun(intf, maxLen)的值為多少

看到第一眼時 先假裝鎮定 但不解 A * 的作用
因為腦殘沒看到typedef 想說A替換後只是變數不是型別
所以就靠推理的方式理解成強制轉型為pointer 並以此位置為0
所以b的位置就是 sizeof(char) * 40 + sizeof(int)
答案是對的 還告訴我它叫offset 差點被他唬到

回家查了一下
原來這個code是在stddef.h裡
目的是做出泛型計算變數在struct的offset

8/01/2008

100種生活

詞 鍾成虎 曲 盧廣仲
*
整個世界 停止 不轉動 很寂寞
走在海邊 數著 螢火蟲 好困惑
想要的生活怎麼有一百種
不想掉進這深深 漩渦

整個海浪 擺動 柔軟地 舉起我
孤獨給我 自由 猶豫得 好感動
想要的生活怎麼有一百種
該怎麼走 誰來告訴我 wow

每當我背對星空
抱著地球
發現自己其實脆弱 不敢說
當我背對星空 不段摸索
愛情漸漸萎縮 我猜不透
無邊的宇宙 哪裡有我想要的生活

repeat *

原來一百種 要在很久很久
以後才會懂 我的一百種生活

7/26/2008

google code jam第三題

google code jam今天早上比了第一場
看了一下第三題
問題是 3 + 5^0.5 取n次方後 求整數前三位數字

看起來很簡單 但一看就知道是誤差問題
看到解出來的人的解答 真的突然覺得自己數學變好差
早知道平常應該繼續唸的

這題n取很大時會有誤差 所以不能硬幹
使用數學方法 設:
3 + 5^0.5 = x
5 = x^2 - 6x + 9
0 = x^2 - 6x + 4
根據n對公式取次方
最後再解方程
這樣誤差就消失了

7/25/2008

內積與外積

內積、外積定義

內積:
物理學中求功的公式,數學上是v投影在u上的長度之積。

外積:
外積是求一個相關的向量,外積出來的向量垂直於原向量。
在幾何中,外積的大小等於兩向量所成的矩形的面積。

6/25/2008

Ten Rules for Web Startups

#1: Be Narrow Focus on the smallest possible problem you could solve that would potentially be useful. Most companies start out trying to do too many things, which makes life difficult and turns you into a me-too. Focusing on a small niche has so many advantages: With much less work, you can be the best at what you do. Small things, like a microscopic world, almost always turn out to be bigger than you think when you zoom in. You can much more easily position and market yourself when more focused. And when it comes to partnering, or being acquired, there's less chance for conflict. This is all so logical and, yet, there's a resistance to focusing. I think it comes from a fear of being trivial. Just remember: If you get to be #1 in your category, but your category is too small, then you can broaden your scope—and you can do so with leverage. #2: Be Different Ideas are in the air. There are lots of people thinking about—and probably working on—the same thing you are. And one of them is Google. Deal with it. How? First of all, realize that no sufficiently interesting space will be limited to one player. In a sense, competition actually is good—especially to legitimize new markets. Second, see #1—the specialist will almost always kick the generalist's ass. Third, consider doing something that's not so cutting edge. Many highly successful companies—the aforementioned big G being one—have thrived by taking on areas that everyone thought were done and redoing them right. Also? Get a good, non-generic name. Easier said than done, granted. But the most common mistake in naming is trying to be too descriptive, which leads to lots of hard-to-distinguish names. How many blogging companies have "blog" in their name, RSS companies "feed," or podcasting companies "pod" or "cast"? Rarely are they the ones that stand out. #3: Be Casual We're moving into what I call the era of the "Casual Web" (and casual content creation). This is much bigger than the hobbyist web or the professional web. Why? Because people have lives. And now, people with lives also have broadband. If you want to hit the really big home runs, create services that fit in with—and, indeed, help—people's everyday lives without requiring lots of commitment or identity change. Flickr enables personal publishing among millions of folks who would never consider themselves personal publishers—they're just sharing pictures with friends and family, a casual activity. Casual games are huge. Skype enables casual conversations. #4: Be Picky Another perennial business rule, and it applies to everything you do: features, employees, investors, partners, press opportunities. Startups are often too eager to accept people or ideas into their world. You can almost always afford to wait if something doesn't feel just right, and false negatives are usually better than false positives. One of Google's biggest strengths—and sources of frustration for outsiders—was their willingness to say no to opportunities, easy money, potential employees, and deals. #5: Be User-Centric User experience is everything. It always has been, but it's still undervalued and under-invested in. If you don't know user-centered design, study it. Hire people who know it. Obsess over it. Live and breathe it. Get your whole company on board. Better to iterate a hundred times to get the right feature right than to add a hundred more. The point of Ajax is that it can make a site more responsive, not that it's sexy. Tags can make things easier to find and classify, but maybe not in your application. The point of an API is so developers can add value for users, not to impress the geeks. Don't get sidetracked by technologies or the blog-worthiness of your next feature. Always focus on the user and all will be well. #6: Be Self-Centered Great products almost always come from someone scratching their own itch. Create something you want to exist in the world. Be a user of your own product. Hire people who are users of your product. Make it better based on your own desires. (But don't trick yourself into thinking you are your user, when it comes to usability.) Another aspect of this is to not get seduced into doing deals with big companies at the expense or your users or at the expense of making your product better. When you're small and they're big, it's hard to say no, but see #4. #7: Be Greedy It's always good to have options. One of the best ways to do that is to have income. While it's true that traffic is now again actually worth something, the give-everything-away-and-make-it-up-on-volume strategy stamps an expiration date on your company's ass. In other words, design something to charge for into your product and start taking money within 6 months (and do it with PayPal). Done right, charging money can actually accelerate growth, not impede it, because then you have something to fuel marketing costs with. More importantly, having money coming in the door puts you in a much more powerful position when it comes to your next round of funding or acquisition talks. In fact, consider whether you need to have a free version at all. The TypePad approach—taking the high-end position in the market—makes for a great business model in the right market. Less support. Less scalability concerns. Less abuse. And much higher margins. #8: Be Tiny It's standard web startup wisdom by now that with the substantially lower costs to starting something on the web, the difficulty of IPOs, and the willingness of the big guys to shell out for small teams doing innovative stuff, the most likely end game if you're successful is acquisition. Acquisitions are much easier if they're small. And small acquisitions are possible if valuations are kept low from the get go. And keeping valuations low is possible because it doesn't cost much to start something anymore (especially if you keep the scope narrow). Besides the obvious techniques, one way to do this is to use turnkey services to lower your overhead—Administaff, ServerBeach, web apps, maybe even Elance. #9: Be Agile You know that old saw about a plane flying from California to Hawaii being off course 99% of the time—but constantly correcting? The same is true of successful startups—except they may start out heading toward Alaska. Many dot-com bubble companies that died could have eventually been successful had they been able to adjust and change their plans instead of running as fast as they could until they burned out, based on their initial assumptions. Pyra was started to build a project-management app, not Blogger. Flickr's company was building a game. Ebay was going to sell auction software. Initial assumptions are almost always wrong. That's why the waterfall approach to building software is obsolete in favor agile techniques. The same philosophy should be applied to building a company. #10: Be Balanced What is a startup without bleary-eyed, junk-food-fueled, balls-to-the-wall days and sleepless, caffeine-fueled, relationship-stressing nights? Answer?: A lot more enjoyable place to work. Yes, high levels of commitment are crucial. And yes, crunch times come and sometimes require an inordinate, painful, apologies-to-the-SO amount of work. But it can't be all the time. Nature requires balance for health—as do the bodies and minds who work for you and, without which, your company will be worthless. There is no better way to maintain balance and lower your stress that I've found than David Allen's GTD process. Learn it. Live it. Make it a part of your company, and you'll have a secret weapon. #11 (bonus!): Be Wary Overgeneralized lists of business "rules" are not to be taken too literally. There are exceptions to everything. written by evan williams

6/20/2008

motion planning using probability roadmap

The probobility roadmap is widely used for autonomous mobile robot path planning. It focus on multi-qurey. Initially, build the roadmap in configuration space, after that we can search a path each query, in which we don't rebuild the roadmap.

below is demo:

6/17/2008

why use android

星期六去了google developer day
聽了四場演講
分別是Gears, GData, Android Introduce, Android VM

Gears跟GData算是比較冷門的
它們兩個可以說是很偏應用性的東西 可能知道一下 以後有需要再用就好了

下午的Android在比較大的會場上
Android Introduce對我來說沒甚麼
因為網頁上的文件都看過了 他講的東西文件中也講了 所以沒聽到甚麼
都在練英聽
Android VM 是我覺得很有趣的 但大部份人應該會覺得很無趣吧
因為它是在講compiler and virtual machine

之前問我為甚麼玩android 跟其他手機上寫程式差在那
其實不太知道 只覺得它有很多API而已
聽完這場演講我比較知道它的優勢在那
最主要是android它放棄了Java Standard VM 改用自己開發的Delvik VM
以前我都不相信java會比C慢很多
經過他說明後了解了 java比較慢不單是因為VM的存在
java's code編釋成bytecode的結果才是重點
java採用stack based的方式產生指令 所以任何變數必須push, pop到stack裡
所以往往一個儲取,迴圈就多了很多不必的指令

而Delvik VM則改用register based的方式 變數記錄在register裡 再作儲取
所以產生的指令就比較少了
單單這個改變就可以令速度快好幾倍了

6/16/2008

我完了

昨天打球 因為手腕還沒好 投球都歪歪的
只好一直切入
最近切入都很不錯 都抓到切入的點 身體也壓得下去
不錯不錯

但我膝蓋真的爛掉了
今天早上起來一直在痛
看來是又韌帶發炎了 T____T

6/09/2008

Android's notebook

convert Java into android.

android.app.Activity <--> javax.swing.JFrame
android.app.AlarmManager <--> javax.swing.Timer
android.app.Dialog <--> javax.swing.JDialog
android.app.AlertDialog
android.app.DatePickerDialog
android.app.ProgressDialog
android.app.TimePickerDialog
android.app.ZoomDialog
android.awt.AndroidGraphics2D <--> java.awt.Graphics2D
android.content.Intent <--> java.awt.ActionListener
package android.graphics <--> package java.awt.geom & java.awt
android.view.View <--> javax.swing.JPanel

6/07/2008

motion planning using potential fileds

The potential field method is widely used for autonomous mobile robot path planning. The most researches have been focused on solving the motion planning problem in a stationary environment where both targets and obstacles are stationary.(as same as our example)

in our example
the bitmap shows the potential field in left upper corner, dark region represents higher potential, light region represents lower potential.

below is demo:

6/06/2008

overview of android

android documentation in this web page, it overview the android platform, and support all information if you want.(but i think it's not enough ^^") install SDK is easy, just set up the path of OS.i think install SDK isn't problem, so let me see the API.

the API rough separate in three parts:
  1. java.*; and javax.*;
  2. android.*;
  3. com.apache.http.*;
the first part(java.*; and javax.*;) import from java SDK. so it's not new package, however, pay attention to these are not awt and swing package, because android platform exericse other UI Design, so we should use android package to do UI Design. after that, the third part import from com.apache for parsing html document.

6/05/2008

掙扎

最近我一直重複著一個動作
就是打開eclipse關掉它 又打開它關掉它 ...
寫程式對我來說並不難
但畢業的程式每看到它都不想寫 視窗不是馬上切換到kkman 就是切換到我想寫的程式
寫這種為畢業而寫的程式 寫完再也不會用的程式 真不知道寫來幹麻
看來
在解決研究題目前 要先解決寫程式的題目
我到底要for畢業還是for理想?

5/16/2008

舊傷好不了

昨天晚上跟系隊去打球
球技倒沒甚麼退步
但膝蓋跟背就真的是...
今天一整天膝蓋都酸酸的 背也帶一點點痛
吼 趕快好起來呀

5/14/2008

The best is yet to come

演唱: 林一峰
作曲: 林一峰, 編曲: 李端嫻@人山人海
監製: , 填詞: 林一峰

永遠有一個吻未嘗 有些燭光未燃亮
若愛太苦要落糖 結他斷線亦無恙
To hug someone To kiss someone
The best is yet to come
若要錯失永不能守 得到也不代表長久
假使快樂有盡頭 痛苦也未會不朽
寂寞半點假如不能承受
這生命註定過得不易
笑與淚 亦有時候
To hug someone To kiss someone
The best is yet to come
若你說不再聽情歌 不想再經歷這漩渦
假使抱住你拳頭 到底也沒法牽手
就是為了追求一時平靜
將感情隔離半點感動都扼殺 沒法承受
永遠有不妥協傷口 有些憾事不放手
若你太刻意淡忘 越會補不到缺口
Why don't you just hug someone
Just kiss someone
The best is yet to come
最好的尚未來臨

5/11/2008

editor and swing

最近要寫一個editor 是要給非資訊系的人用
基本文字編輯和一些跟XML相關的功能
需要簡單美觀彈性 總之就是要user friendly就是了
找了一下有沒有開放的package拿來改

eclipse的介面很好 但是看了一下要用eclipse api弄一個出來真是天殺的麻煩
而且它的功能是以寫程式導向的編輯器 我只需要純文字 有點大材小用

jEdit由一群人開發出來的編輯器 功能非常強大 在網頁中寫提供以下功能
  • Written in Java, so it runs on Mac OS X, OS/2, Unix, VMS and Windows.
  • Built-in macro language; extensible plugin architecture. Dozens of macros and plugins available.
  • Plugins can be downloaded and installed from within jEdit using the "plugin manager" feature.
  • Auto indent, and syntax highlighting for more than 130 languages.
  • Supports a large number of character encodings including UTF8 and Unicode.
  • Folding for selectively hiding regions of text.
  • Word wrap.
  • Highly configurable and customizable.
  • Every other feature, both basic and advanced, you would expect to find in a text editor. See the Features page for a full list.
只要了解一下 寫些plugin就可以了 但它功能太強大 給非資訊系的人用會不知道怎麼用 所以放棄了

ekit另一套開放且很好用的編輯器 可惜它是提供給HTML 能讓我更改的可能性很低

找不到下只好用java swing開發 java swing很強大 如果只是普普通通弄個介面 用netbeans很不錯有好用的視覺化介面 但它只能視覺化大部份"J"開頭的元件 如果要做的得更好更炫就必須轉到寫程式 swing上有很多大家都不知道 也不常用的package和class

如果想拖拉 可以參考java.awt.dnd 在how to use dnd中可以查到那些元件本身已提供拖拉功能 如果想要用的元件有提供dnd的話只要呼叫setDragEnabled(true)就有拖拉功能了 沒有的話就必須實作DragSource, DragTarger等class

如果想剪貼簿 可以參考javax.swing.text.DefaultEditorKit 它已經寫好Copy, Cut, Paste的action 只要在元件的建構子以action為參數加到元件裡就好了

如果想讓視窗沒有框框 就不要用JFrame 用JWindow

還有很多很多 其他有空再補...

5/08/2008

motion planning environment

I have a plan to arrange what i have leared in motion planning up to the present. I think i'll show some planning methods, like potential field, PRM and RRT. These methods are so common.

Before i show some demo, i think i should build a simple environment for all methods. So i had wrotten a environment which support to read Objects(Robot or Obstacle) in txt file, to show the objects in screen, to build BitMap and C-Space for planning.

Below is my environment demo. The red objects are robots and the blue are obstacles, you can click and drag each one, a event of left-click drag represents translating the click object, the event of right-click drag represents rotating the object, pay attention to the right-click event, because the robot is combined from several polygons, you can local or global rotation.


5/06/2008

Google Cloud Computing 教學計畫將在台,交大實施

全球搜尋引擎龍頭Google昨天宣布,將和台灣大學、交通大學合作推廣「雲端運算學術計畫」,幫助台灣學子學習這項網路開發主流技術。台灣是Google在美國本土外,第一個可望輸出快速運算模式的國家,有助台灣開發更多有創意的網路服務。

Google台灣工程研究所所長簡立峰說,網路資料日漸增多且龐雜,Google開發所謂「雲端運算」(cloud computing)的模式,可讓數百台、數千台電腦同時運作,這項運算概念充斥在日常生活各種網路服務中。

舉例來說,當網友登入Google的帳號及密碼,全球有數百台的電腦會同時運作,幾秒內即能確認。而且上千封郵件不是放在用戶的個人電腦裡,而是儲放在世界各地的伺服器中,這些伺服器就像一朵朵的雲,使用者不知道自己的郵件躲在哪朵雲中。

他表示,在Google搜尋關鍵字,可在不到一秒時間,搜尋出超過十億個網頁,這也和雲端運算有關,原理是將龐大運算作業拆成千百個較小的作業,在多部伺服器上同時動作。Google其他線上服務如Google Docs、Google Talk、iGoogle、Google Calendar都充分應用到這項技術。

他說,只要運算功能是在遠端、多部伺服器進行,本機只負責單純操作的技術,都可以稱為雲端運算。不只Google靠雲端運算起家,Yahoo!、Amazon、微軟也都採用這項技術提升網路服務功能。微軟創辦人比爾蓋茲曾說,未來是雲端運算的時代。

去年十月Google先在美國麻省理工學院、史丹佛、柏克萊加大、卡內基梅隆、馬里蘭和西雅圖華盛頓大學首度推廣,成效不錯。華盛頓大學學生甚至因此編寫出可掃描內容龐大的維基百科,以辨識垃圾條目程式,及根據地理位置編排全球新聞標題。

台灣是這項計畫的第二站,也是Google在美國本土以外的第一站。Google軟體工程師葉平說,Google將提供教材給台灣教授,並協助學校在現有運算資源上建置相關軟體系統,台灣Google還會派六名工程師到大學當學生的小師父。

目前Google已計畫和台大劉邦鋒教授開設的「平行運算」,以及交大教授彭文志和黃俊龍的「Web Services and Application」課程合作。

以上引用自http://mag.udn.com/mag/digital/storypage.jsp?f_MAIN_ID=319&f_SUB_ID=2941&f_ART_ID=108944

醜陋的程式

我真的對程式有潔癖

現在寫研究的程式 只要一直嘗試方法

沒甚麼架構可言 還一直改來改去

寫到我越來越討厭看到它

5/05/2008

暴走的廁所

林小藤你這個...
居然把廁所的蓮篷頭弄壞了

重要的是不管它放在那邊

吼 我們都要變成日本人洗澡了 開一盆水在那邊一杯杯倒在身上

氣死我了

你你你... 我不能用笨蛋來罵你 這樣太污辱了笨蛋了

4/28/2008

details of inheritance in Java

Everyone knows everything is object in Java. sometime if you inherit or create an object, you must keep the general contracts, else you may make bugs. equals(), hashCode(), clone(), finalize(). those are non-final methods, we will discuss below.
  1. Override equals() method is simple, but it will also make mistakes, the best solution is don't override it possibly. if you must override it must keep the below conditions.
    • Reflexive : for all x, x.equals(x) must true.
    • Symmetric : for all x, y, if x.equals(y) is true, then y.equals(x) is true.
    • Transitive : for all x, y, z, if x.equals(y) and y.equals(z) are true, then x.equals(z) is true.
    • Consistent : for all x, y, x.equals(y) == y.equals(x) is forever true.
    • Non nullity : x.equals(null) is false at all time.
  2. hashCode() be override coincide with equals(). if you don't do that, you violate the constracts and can't work normally with HashMap, HashSet, HashTable... If and only if x.equals(y) is true, then x.hashCode() must equal y.hashCode(). sample code: Map m = new HashMap(); m.put(new MyObject("hihi"), "lui"); m.get(new MyObject("hihi")); Usually you believe "m.get(new MyObject("hihi"))" will return the String "lui", but it also return null. it's because the two MyObject is the same in our opinion, but is not the same in program, it has different hashCode, so, for the same object must has the same hashCode.
  3. clone() method is like create a object, you must know clone() is not deep copy, so, it may share member data in two objects, but it isn't you want. So, one solution is don't support clone() method, others is make clone() as like as copy constructor in C++.

4/27/2008

Android

The Android platform is a software stack for mobile devices including an operating system, middleware and key applications. Developers can create applications for the platform using the Android SDK. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linux kernel.

android documentation

The core Android APIs will be available on every Android phone, but there are a few APIs which have special concerns: the "optional" APIs.

These APIs are "optional" for two reasons. First, they're optional in the sense that you don't need to use them. For example, you can't write an application without using the Activity and Intent APIs, but your application may not need to know where the user is, and so you may not need the Location-Based Services API. In this sense, the LBS API is optional where the Activity API is not.


  1. Location-Based Services
  2. Media APIs
  3. 3D Graphics with OpenGL
  4. Low-Level Hardware Access

Google APIs and Services in Android
  1. MapView
  2. P2P Services Using XMPP

4/24/2008

PageRank

google這麼好用大多是因為它準確率高
也就是PageRank這個方法

簡單講就是每個網頁都有自己的分數 網頁本身的每一個link都會將自己的分數影響別的網頁
所以網頁的排名就是自身的分數加上所有別人link到本網頁的分數
被link越多rank越高 被高rank的網頁link到rank升更快

一般一個新網頁出來 google大約兩個內會找到 然後建index
然後每隔一段時間更新一次

所以它的方法主要分兩個部份  一內容分析 二link分析

內容分析
google會看meta title來了解這是一個大概甚麼網頁 會看keyword的density  會看keyword在甚麼tag中 字型大小 顏色... 還有很多很多
所以說並不是keyword多就高分 google也一直修改它的判分方法 方向是以人為主
使用者想看到甚麼資料 所以meta tag或字型大小為0的內容影響極少

link分析
主要是每個網頁都有個PR值 值越高越重要 被PR值高的網頁連結到 本身增加的分數
就比較多 想法是認為PR值高的網頁認為你的網頁有用 就像被大人物推薦一樣
但是 這樣網頁管理者就會想瘋狂的相互連結來增加rank
google當然沒這麼笨
一個網址的向外連結會將分數share 一個PR值高的網頁只有一個link連結網頁A
和有100個link其中只有一個link連結網頁A是有差別的

以上都是對google的初步了解
google單單在07年 一年中更新了四百多次
現在的計算考慮到甚麼程式已經不知道了

4/22/2008

世界末日

回到家發現我的巧克力冰琪淋在冰箱裡溶掉了

幹 好傷心喔

溶掉的冰琪淋要怎麼吃呀

google了一下知道冰箱不冷很有可能是電風扇被冰住了

放電打開讓它掉冰就可了

可是 冰箱沒電我冰琪淋溶得更快呀

幹幹幹

4/20/2008

研究 moiton planning 的人

國外motion planning的幾位大人物

Jean-Claude Latombe
Mark Oversmars
Steven M. LaValle
Thierry Fraichard
James Kuffner

motion planning的問題目前可以走的方向大概有:
robot path planning --- environment
           multi-goal
           multi-robot
           visibility
           path quality
humaniod animation --- kinematic (inverse, forward)
           controller
           behavior planning
           composition motion
navigation
manipulation
collision detection

很明顯的 我比較知道第一二個領域 第三四五還不是很熟

4/19/2008

SBL 第五戰

幹 這場太high了
兩隊一直反超前 大家的三分球像不好錢的
公主鼎也進一顆
陳世念這個裕辣三分球100%
台啤輸了也好
這樣明天還有得看

終生學習

小時候大家都會說 讀大學讀完大學生活就很好了
過了沒多久就改為讀完碩士生活就很好了
電影據裡都會演某某某國外讀完回來就是某公司的高層。。。

這些都是長輩們的幻想

越往上爬越發現腳步停不下來
因為你就變成一部發動機 發動後可以一直往前走 只要你不停下來多遠都能走到
一旦停下來就再也不會移動了

不管在公司在學校或其他地方
一旦失去動力就會變得庸碌 只有不斷的進步 就會找到人生的意義