2011年12月12日 星期一

andengine source

andengine library

andengine example

Getting start

教學文

apk


我當時事先把apk抓下來或是把andengine的example範例給架好(import到eclipse上再編譯到實體手機上,
but 我前幾個月再import他的source時,不確定是要多加那些套件,參考(http://eportfolio.lib.ksu.edu.tw/~4970E089/blog?node=000100019) 我認為參考網站上的步驟很麻煩,應該不需要這樣做,
在手機上玩玩他的範例在比對他的source code. 這樣應該會很快.

andengine上的gameActivity (onLoadScence,onLoadResource,etc)
我想主要跟activity不一樣的是有他自己的生命周期吧 (onCreate, OnStart,etc)

2011年12月4日 星期日

Thread-Safe的理解與分析

⓪著作: 蕭沖

 

何謂thread-safe? 這個問題我看過許多論壇都有討論過,都總讓人覺得不很滿意。在此,筆者想要用更logical的方式來把議題說清楚。首先,我們要了解它的定義! 定義若都不明白就難以判別安不安全了!

thread是什麼呢? 可能也有人不太了解。就從這裡開始… 當cpu處理一段(區塊)的程式碼時,從開始的第一行程式碼來跑就算是thead的開始,直到區塊的最後一行程式結束,就算是thread的結束。所謂的「主thread」,在dos (或dos like)程式裡,就是指main( )這個函式的開始到結束的一個thread。而主thread以外的一個子thread則是指程式人員自行在主thread裡再定義一個「程式區塊」,並請cpu同步的去執行那個區塊。

由上面的thread的定義來看,我們可以進而推論所謂的multithread這個字其實是有三種情形的,哪三種呢?
1/ 相同的一個程式區塊,請cpu"分出多身"來執行它! (一段code被new或說create成數個thread)
2/ 不同的程式區塊,請cpu各別分時的去執行每個區塊 (幾段code個別被new或說create成個別的thread)
3/ 混合以上二種情形

所以,當我們在討論多緒/多線程(multithread)的問題時,我們要先去了解問題是上面三類的哪一類。若是第一類,那就要注意若有使用全域變數,那就極有可能是不安全的。若是第二類,那也要考慮是否不同的thread code是否有共用某同一個全域變數。

我們再把「程式區塊」給解析一下。它可以是一個function,或是一個class(裡面有成員函式),或是上述二者的混合體。因為function或是class都會使用到變數,於是多緒時變數的共享就成了一個很大的問題。這就是為什麼會有thread-safe的這個議題了!

到此為止,我們可以想像若一個程序(process / 主thread)裡,有大於等於一個子thread在跑,就會產生thread-safe的問題。以最簡單的情形來說,mainthread+user自定的一個thread。假設Button元件按下後會刪除memo元件裡某個String,而同時間的一個thread則會取用memo裡的String。假想當thread在取用memo中某String做分析的時候,user不知情的按下button,那麼thread是否有可能會取到不正確的String?  若不經過特別的安全設定,肯定「取用」時時而會出問題!

因此,到底安全或不安全的根源就在那執行的區塊程式碼上了(以上例就是取用的過程)。我要補充一個重要的事,其實每一個thread都有自己的一個專屬stack,所以auto級(local)的變數是不會有共享的問題,因為它們都是存放在thread各自的記憶體空間內,彼此不甘擾。也就是說,若你的程式區塊中,所有使用到的變數都是local(auto)變數,那你這個區塊,或說這個thread,就算是thread-safe !! 相反的,若你的區塊中有用到全域的變數,那麼你的這個thread就有可能是不安全。請注意看,是有可能,並非一定是。

如何把含有全域變數的thread分析出安全或不安全? 其實這是很直覺的。比如說某全域變數int g被數個thread使用到,但每個thread裡只引用到一次,那算安全嗎?  答案是…還算安全(註:極度的嚴僅來說不100%,但98%不為過)。因為單一基本變數的一次存取cpu處理極快,不太會有衝突。又,若是某全域結構體變數 struct tag 被引用存取到一次,那算安全嗎?  答案是…不太安全,因為一個結構體的存取可能涉及到多個微指令。進一步的用上面的例子來說,若int g被「程式區塊」(thread code)引用到2次(含)以上,那就肯定不安全了。比如說第一次是把g設成k,第二次把g再設給某變數i,若thread1正在處理第二次引用,而thread2在處理第一次引用。那thread1可能會得到意外的答案!(g值非它第一次設成的k值,而是變成thread2裡的k值)

如何讓不安全的thread變成安全的?? 其實主要的方法有二類。


1/ 存取共用全域變數時加上lock的機制,而這lock的機制在windows上可以使用mutex、criticalsection、event、semaphore等物件配合WaitForSingleObject或WaitForMultipleObject二個api來控制。其原理就是當某thread在取用資料時,其他的通通都停止並等待,直到該thread取用完。


2/ 把存取全域變數的動作通通交給某一個thread全全處理。比如說你有thread1,thread2,thread3。當要存取全域的struct變數時,thread2就把工作交給thread1做,然後自己停住等thread1完成,thread3也把工作交給thread1做,並等待…  。這原理應該容易理解,因為不安全的工作全都交給"單一"的thread來處理時,那份工作就安全了呀! 當然,這也不禁讓我們覺得,這樣效能非常的差!通通都在等thread1。  不過還好的是,若少少的用還ok,若許多的工作都交給某一thread順序來處理,那就真的沒意義了! 而這種方式其實就是bcb或delphi裡的synchronize這個方法的處理方式! (請看最下面2011年我的補充說明)

 

後註: class 其實也像是一種function,所以class本身也是存在著安全與否的問題。倘若該class裡的menthod有用到全域的變數時,該class也算是不安全的! 而許多的VCL就是這類的class!

註2: 若什麼是auto變數、stack都還不清楚,請先自行google或查程式語言的書,這是很基本且重要但易被忽略的章節。

refer from:

2011年11月27日 星期日

NPC

"P"
為一組Problem的集合, 在此集合下的問題都有deterministic algorithm,其皆可在polynomial time下完成, 即 O(n^k).

"NP"
同上,but "deterministic" 換成 "non-deterministic"
(i,e 若對此問題給亦可能的解, 能在 O(n^k) 時間下去證明此解是否為正確)

"NP-hard"
一NP問題 is polynomial-time reducible to 另一個問題
(polynomial-time reducible是為了不改變問題的性質)

"NP-Complete"
存在一problem x
x 屬於  NP 且 x 屬於NP-hard
<=> x  屬於 NP-Complete
(i,e NPC中的問題在worst case下並沒有 O(n^k)的演算法可解)
(i,e worst case下需exponential time or even harder)

這幾類的目的, 是主要為了將problem依難度做分類.
(ha...有點導果為因= =...)

說實在的我最近也在研究有關NP-Comlete的相關issue, 但好抽象= =.....

refer from:
http://en.wikipedia.org/wiki/NP-complete
http://www.csie.ntnu.edu.tw/~u91029/noun.html
http://www.csie.ntnu.edu.tw/~u91029/NP.png

2011年11月6日 星期日

Android map api key 若是在產生MD5時變成SHA1

keytool -list -alias androiddebugkey -keystore C:\Users\Administrator\.android\debug.keystore -storepass android -keypass android

keytool -list -v -alias androiddebugkey -keystore C:\Users\Administrator\.android\debug.keystore -storepass android -keypass android

refer from:
http://www.moke.tw/wordpress/computer/advanced/261

http://blog.csdn.net/lxm247/article/details/6624005

lex 學習

Lex是個古老的工具
雖然是個老東西,但是還是挺好用的!
Lex的功用主要是對一個文件寫下rule
然後產生一個compiler去paser這種文件
安裝:
目前Lex / Flex在linux下皆可以安裝執行
Ubuntu為例,只要下指令
% apt-get install flex
即自動幫你安裝完成
接著只要輸入指令flex即可執行Lex程式了
執行Lex的順序:
Lex的input file,必須是*.l 的檔案 ( 副檔名為l ... 小寫的L )
接著只要輸入指令
% flex test.l
  然後Lex就會自動產生一個output file:lex.yy.c
接著只要compile這個lex.yy.c 就可以執行這個token parser了
% gcc lex.yy.c -ll
  而-ll是為了include lex的library
Lex的Input File架構:
*.l 主要分三個部分:definition & rules & user code
這三個部分以「%%」為分界

  definition
%%
rules
%%
user code


definition:使用者自己定義的變數,都放在這個地方
  rulesparser對token match的規則
user code:最後產生的lex.yy.c最底下會有一模一樣的code
Definition:
在Definition的區間裡,可以宣告一些在rule中的code要使用的變數(寫法跟c一模一樣)
而這些code必須用%{%} 將跨行的code包起來
因為在這個區間的code都會被完完整整、一字不漏地output至lex.yy.c檔中
所以在compile lex.yy.c檔時,才不會產生error!
Ex:
%{//要記錄parser的input file的總字數與行數
int num_char = 0;
int num_line = 0;
%}
%%
\n { num_line++; }
. { num_char++; }

也可以宣告一些「rule的變數」,讓rule的寫法更簡潔
寫法為:
name definition

Ex :
number [0-9]+
identifier [a-zA-Z_][a-zA-Z_0-9]*
%%
{number} printf("%s this token is a number\n", yytext);
{identifier} printf("%s this token is a identifier\n", yytext);

上面的意思其實就是...
{[0-9]+} printf("%s this token is a number\n", yytext);
{[a-zA-Z_][a-zA-Z_0-9]*} printf("%s this token is a identifier\n", yytext);

Rule:
要對input file切token的規則,全寫在這裡。
寫法的規則是:
pattern action

pattern可以輸入一些正規表示法,或是一些word,而正規表示法在此不再贅述
想了解的人,自己想辦法吧,筆者累了....Or2...
action則是當pattern match後,執行相對應的code(跟c一模一樣),因此這些code會原封不動地寫入output file中
若action的code太多,則可以用"{" "}"跨行將code包起來
Ex:
[0-9]+ ECHO;printf("this is a number!\n");
等同於...
[0-9]+ {
ECHO;
printf("this is a number!\n");
}

在這邊有一個特別的word可以用在action中
ECHO 可以印出yytext(match pattern的字串)中的內容至output中

Global Variable:
這個是lex的預設變數,在寫*.l檔的definition & rule時,可以直接使用這些變數
yyin 是lex的input來源,型態為FILE * ,初始預設為stdin
yytext 當rule中match一個pattern時,match的string就會存在yytext中,型態為char *
yyleng 記錄yytext的長度
yylineno 記錄目前的yyin讀到第幾行了


Example:
這是一個計算input file的總字數&行數的lex檔  

%{
int num_lines = 0, num_chars = 0;
%}

%%
\n   { ++num_lines; ++num_chars; }
.    { ++num_chars; }

%%
main()
{
yylex();
printf( "# of lines = %d, # of chars = %d\n",
num_lines, num_chars );
}
 
 
執行方式:
flex [filename].l
gcc lex.yy.c -ll
cat [filename] | ./a.out //把此文件與pipeline到執行檔產出
如:
file => 
---------------------------- 
1
23
4
5
6
7123adsf
sdf
--------------------------------
下:
flex file.l 
gcc lex.yy.c -ll 
cat file | ./a.out 
 
print => 
24 7 7     //24個字元 個字數 77行
 
解釋:
在這份定義文件內,我們看到在定義區塊裡面有一行C語言的變數宣告,宣告了三個整數變數,nchar、nword及nline,分別用來代表接下來我們要計算的字元數、字數以及行數。

接著在樣式區塊裡面定義了三個樣式,根據我們在上一節裡面學到的對於常規表示式的知識,我們可以知道這三條樣式所代表的意義。 \n   換行字元
 [^ \t\n]+  1個以上的非空白字元
 .   換行字元之外的所有字元我們現在要注意的是在樣式常規表示代的右邊以大括號括起來的程式碼,這就是前頭我們有提到過的動作程式碼。這是在字彙剖析器在分析字串樣式匹配時,若樣式符合且樣式有指定動作程式碼,也就是在樣式右側的程式碼,則這段程式碼就會被執行。

以\n
這條樣式來說明,如果樣式匹配,則程式碼{ nline++; nchar++; 
}會被執行。注意到這裡的大括號,假如動作程式碼只有一行的話,則大括號是可有可無的,像是第三條樣式。但我們一律還是都寫上大括號以免有所遺漏,同時也
要注意的是不管動作程式碼有幾條指令,全部都要寫在同一行裡面。

最後是程式碼區塊。這區塊裡有個main進入點,第一行指令呼叫了
yylex這個函式。在前面的介紹中,我們知道yylex是由lex自動幫我們產生的函式,這個函式的工作就是幫我們作字彙剖析,一直到結束後才會返回。
返回之後,我們再把計算的字元數、字數以及行數列印到畫面上。 
 
from:
http://falldog7.blogspot.com/2007/09/lex.html 
http://good-ed.blogspot.com/2010/04/lexyacc.html

2011年10月17日 星期一


3.1 Compiler vs. Interpreter

An interpreter translates some form of source code into a target representation that it can immediately execute and evaluate. The structure of the interpreter is similar to that of a compiler, but the amount of time it takes to produce the executable representation will vary as will the amount of optimization. The following diagram shows one representation of the differences.
graphic
Compiler characteristics:
  • spends a lot of time analyzing and processing the program
  • the resulting executable is some form of machine- specific binary code
  • the computer hardware interprets (executes) the resulting code
  • program execution is fast
Interpreter characteristics:
  • relatively little time is spent analyzing and processing the program
  • the resulting code is some sort of intermediate code
  • the resulting code is interpreted by another program
  • program execution is relatively slow
The above characteristics are typical. There are well-known cases that are somewhere in between, such as Java with it's JVM.

refer from:

2011年10月15日 星期六

Resource is not public

另外如果使用Theme.Dialog.Alert之類而出現
Error: Resource is not public. (at 'theme' with value '@android:style/Theme.Dialog.Alert')的錯誤,因為在frameworks/base/core /res/res/values/public.xml找不到這個資料

只要加個*改成
  '@*android:style/Theme.Dialog.Alert'
就可以使用了。



refer from:
http://slashgill.blogspot.com/2010/11/theme.html

2011年10月14日 星期五

Login Failed: invalid_key when Android Facebook app is installed


As Sean suggests in his second tack...
I fixed the issue by removing this line (which uses SSO):
    mFacebook.authorize(activity, mAppId, PERMS_NEEDED, new LoginDialogListener(r));
in favor of this line (which does not):
    mFacebook.authorize(
            activity, 
            PERMS_NEEDED,
            Facebook.FORCE_DIALOG_AUTH,   // avoids SSO
            new LoginDialogListener(r));
refer from:
https://github.com/facebook/facebook-android-sdk/issues/191

2011年10月7日 星期五

nVidia BSOD nvlddmkm.sys

I have found and fixed the problem today. This is what appears to happen.
during the installation of the most current drivers 100.65 Vista, an OLD file
nvlddmkm.sys is copied into windows/system32/drivers and not the current one
in the install. As a result the new drivers are attempting to access a file
dated 11/2006 instead of 2/2007 ver 7.15.11.0065 which is in the newest WHQL
driver ver 100.65 vista 32.

Fix: Go to windows/system32/drivers and rename nvlddmkm.sys to
nvlddmkm.sys.old. Go to the nvidia directory and find the file nvlddmkm.sy_
and copy it to windows/system32. Using the cmd window (DOS box) type
EXPAND.EXE nvlddmkm.sy_ nvlddmkm.sys. When the expansion is complete, copy
the new nvlddmkm.sys to windows/system32/drivers and restart the computer.

Your computer should now work properly.

You will notice that any uninstall and reinstall of nvidia drivers will not
remove the old nvlddmkm.sys file and will not overwrite it with the newer
version. You have to do it manually. I do not know why this happens but who
cares as long it is fixed.

Good luck...

"Hohen" wrote:






nvlddmkm.sys 這是NVIDIA的顯卡驅動的文件吧,你入安全模式找到他刪了他,看看能不能開機,要是入到正常模式的話就去下你顯卡最新的FOR win7的驅動吧裝上新的驅動我想應該沒事,
要是你不是一入系統的藍的話那你不用刪直接下最新的驅動裝上看看



refer from:
http://www.vistax64.com/vista-hardware-devices/41867-nvidia-bsod-nvlddmkm-sys.html

2011年10月6日 星期四

android另類結束Activity方法——主動拋出異常





這種方法在網上已經有了部分介紹,但是大部分人不知道怎麼取消Force Close的對話框。「通過重寫Android應用程序的Application基類自己實現 Thread.UncaughtExceptionHandler接口的uncaughtException方法是可以避免出現FC窗口的,用戶感覺直接退出了一樣」。這是網上能找到的說明,這段話讓人看了摸不著頭腦,大部分人不知道怎麼重寫Application基類並實現接口。廢話不多說,直接上代碼! 首先需要在onCreate中添加此句代碼:Thread.setDefaultUncaughtExceptionHandler(new AntrouApp());表明出現異常由自己來處理。 接下來重寫異常處理類 
public class AntrouApp extends Application implements Thread.UncaughtExceptionHandler { 
    @Override 
public void onCreate() { 
// TODO Auto-generated method stub 
super.onCreate(); 
} 
@Override 
    public void uncaughtException(Thread thread, Throwable ex) { 
        android.os.Process.killProcess(android.os.Process.myPid());  
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(thread, ex); 
//若沒有處理,則按照系統自己的處理方式處理 
    } 
} 

此方法會強制結束所有的Activity和service,當然也可以在service裡進行,達到後台強制結束任務的目的。在Activity結束後,系統會回到最近為onpause狀態的Activity。


refer from:
http://www.bangchui.org/simple/?t15896.html

2011年7月4日 星期一

證明 數學歸納法

數學歸納法(Mathematical Induction)立論的基礎是來自良序原理(Well-Ordering Property)。
Well-Ordering Property告訴我們:任何自然數的非空子集合會有一個最小的元素。(Every nonempty subset of the set of positive integers has a least element.)
首先我先以矛盾證法證明數學歸納法的合法性(Validity):
假設已知條件:P(1)為真,且對所有自然數k而言,敘述 P(k)→P(k+1)亦為真。

為證明P(n)對所有自然數n而言恆為真的話,假設存在一自然數n使得P(n)為假。
則根據Well-Ordering Property,讓P(n)為假的自然數集合S是自然數集合N的子集合,它是個非空集合,並存在一個最小的元素,我們稱此元素為m。
我們知道m不會是1,因為已知條件中已給出P(1)為真。
既然m不會是1,那它必定是個大於1的自然數,m-1也會是個自然數。
此外,因為m-1小於m,m已經是S集合中最小的元素了,所以m-1並不屬於S集合;因此知P(m-1)必為真。
所以我們得到了P(m-1)為真,P(m)為假的結論。
根據已知條件:P(k)→P(k+1) (P(k)為真,則P(k+1)亦為真),我們知道這個結論和已知條件矛盾,因此推得"存在一自然數n使P(n)為假"這個敘述是錯誤的!
也就是說,P(n)對任何自然數n恆為真。得證!



refer from:
http://tw.myblog.yahoo.com/jw!XToZojWTHRI2EfbctdR8ag--/article?mid=1628&prev=1629&l=f&fid=78

2011年4月28日 星期四

OS: Thrashing



在電腦的知識範疇中,談到thrashing前,必需先大略對虛擬記憶體有點瞭解。虛擬記憶體的概念,其實就是將硬碟割出一塊空間,這一部份我們叫他虛擬記憶體(Virtural Memory),而原先的記憶體稱之為實體記憶體(Physical Memory)。  


當程式要執行的部份,從虛擬記憶體(亦即硬碟)搬至實體記憶體再執行。由於硬碟的空間遠較實體記憶體為大,因此使用虛擬記憶體這種技術,可以讓程式不受實體記憶體容量的限制,此外由於行程(Process,指執行中的程式)只需將部份載入實體記憶體,因此可以讓更多行程同時存於實體記憶體,進而提高CPU的使用率。


  Thrashing這種現象指的是,欲使用的資料從虛擬記憶體搬至實體記憶體時,實體記憶體可能有一部份需要被置換,這些置換的資料再搬至虛擬記憶體中。然而被置換的部可能馬上又要使用,再從虛擬記憶體搬至實體記憶體,如此週而復始不斷進行搬運的動作,所有時間都花在這些無關緊要的置換搬運,導致CPU的使用率大幅降低。  
 
現在的電腦可以同時執行很多程式,如此CPU使用率大幅上升,達到最大的利用。然而執行的程式超過一定的數量時,很容易發生thrashing,CPU的使用率反而降低。


refer from:
http://blog.xuite.net/draz/draz/3826515

2011年3月2日 星期三

Win7: Login your computer directly

Open command application and key "netplwiz" to set the mode you want.

refer from:

Win7: Open admin

cmd (use admin's authority by right click)

then "net user administrator /active:yes"

if you want to close it,change yes to no.

2011年2月25日 星期五

Freerunner: The problem of enter in Terminal emulator

1. You need to change keyboard type in your freerunner that is ruKeyboard.apk from
http://android-on-freerunner.googlecode.com/issues/attachment?aid=4852331778978639661&name=ruKeyboard_v1.3.4.apk&token=2bf2f673c0b38748aa74d0894a6006a0

2. Use adb to instll this .apk.

refer from:
http://code.google.com/p/android-on-freerunner/issues/detail?id=55

Android: Install ADB in Linux

1. Download http://www.4shared.com/file/182574434/c1225b3d/AndTools.html then execute it.


2. Install Android SDK from http://developer.android.com/sdk/index.html.

3. Update Android SDK that need to include ADB.

4. You need to add environment variable so input "$gedit ~/.bashre".

5. Key in "export PATH=$PATH:/home/light/sdk/platform-tools/" in the end of the opened file. (depends on your path of ADB)

6. Key in "$adb" to check this instruction existed.

refer from:
http://developer.android.com/index.html

2011年2月24日 星期四

Android: Install .apk by ADB

After your google phone has already communicated with computer successfully,input " $adb install xxx.apk"

Android: Use ADB in Linux

1. Connect your google phone with your computer by USB.

2. Input " $ifconfig " to see the new Ethernet card.(eg. eth1 or usb0).

3. Input " $ifconfig eht1 192.168.0.200 netmask 255.255.255.0".

4. Input " $ADBHOST=192.168.0.202 adb devices"
    then you'll see something like this:
        List of devices attached
        emulator-5554 device
    if you don't see it,Input "$adb kill-server"," $ADBHOST=192.168.0.202 adb devices"

2011年2月9日 星期三

Ubuntu: pps

Install 輔助軟件:
Do:
sudo apt-get install libqt4-core libqt4-dbus libqt4-gui libqt4-network libqt4-webkit libqt4-xml libfuse2 mplayer
* QT庫, 4.4.0及以上版本
* libFuse庫, 2.7.2及以上版本
* Mplayer, 1.0rc2及以上版本
* MPlayer視頻解碼器: MPlayer Essential Codec Pack (http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2)


Install:

Download:
http://download.ppstream.com/ppstream_1.0.0-1_i386.deb
After you get ppstream_1.0.0-1_i386.deb,then deliver it to home folder

Do:
sudo dpkg -i ppstream_1.0.0-1_i386.deb

refer from:

Ubuntu: apt-get 套件管理

更新套件清單
sudo apt-get update

自動檢查需要更新的軟體並更新
sudo apt-get upgrade

查詢可用套件
apt-cache search <key>

僅從套件名稱搜尋
apt-catche -n search <key>

安裝軟體
sudo apt-get install <name>

重新安裝
sudo apt-get reinstall <name>

移除套件,留下設定檔
sudo apt-get remove <name>

完整移除套件
sudo apt-get --purge remove <name>

套件管理程式
System-> Administration-> Synaptic Package Manager

refer from:
http://www.cc.ncu.edu.tw/document/Ubuntu/96/Basic1_2.pdf

Ubuntu: wireless enable isn't worked.

I used my notebook HP dm3-1032TX to install Ubuntu 10.10.Below these steps I can surf the Internet by wifi.

light@light-HP:~$ cd /sys/devices
light@light-HP:/sys/devices$ iwconfig 
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=off
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
        
ppp0      no wireless extensions.
light@light-HP:/sys/devices$ rfkill list 
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: yes
2: hp-wifi: Wireless LAN
Soft blocked: yes
Hard blocked: no
3: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
light@light-HP:/sys/devices$ rfkill unblock 1
light@light-HP:/sys/devices$ rfkill list 
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: yes
2: hp-wifi: Wireless LAN
Soft blocked: yes
Hard blocked: no
3: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
light@light-HP:/sys/devices$ rfkill unblock 2
light@light-HP:/sys/devices$ rfkill list 
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
2: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: no
3: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
light@light-HP:/sys/devices$

refer from:
http://www.beautyorange.com/2011/01/how-to-enable-wireless-in-ubuntu-manually/