2015年2月24日 星期二

make your own cluster computer from raspberry pi 2

http://www.tinkernut.com/2014/04/27/make-cluster-computer/

setting up bluetooth device at raspberry pi 2

http://d.hatena.ne.jp/yunoya/20140330/1396114048
http://www.correlatedcontent.com/blog/bluetooth-keyboard-on-the-raspberry-pi/

2014年7月22日 星期二

JUnit+Jenkins CI

設定環境參數
JAVA_HOME=`which java`
JUNIT_HOME=/path_to_junit/
CLASSPATH=/path_to_TaskRunner/:/path_to_junit/junit-4.10.jar

設定 jenkins plugins
https://wiki.jenkins-ci.org/display/JENKINS/SCM+Sync+configuration+plugin

2014年5月21日 星期三

開發環境設定檔&設定指令

0. install essential packages in ubuntu(lubuntu)

sudo apt-get update;apt-get upgrade;sudo apt-get -y install vim build-essential git-core subversion python openjdk-7-jdk autoconf libtool pkg-config libevent-dev libssl-dev


1. git

http://ihower.tw/blog/archives/5436

2. vim

3. shell& bash


2013年7月17日 星期三

Expert C Programming reading




1. Both operands are pointers to qualified or unqualified versions of compatible types, and the type pointed to by the left has all the qualifiers of the type pointed to by the right. 

char * cp;
const char *ccp;
ccp = cp;

cp = ccp; /* results in a compilation warning */

2.The one "l" NUL ends an ASCII string, The two "l" NULL points to no thing. 

2013年4月28日 星期日

arch linux on IBM X61

https://wiki.archlinux.org/index.php/IBM_ThinkPad_X60s


2013年1月23日 星期三

2012年11月14日 星期三

PHP web crawler&parser

談談以前寫過的一個小程式好了, 這是之前(2008)年在看股票的時候寫的, 那時候3G網路剛剛開始, 手邊也沒有智慧型手機, 有一個sont ericsson的feature phone, 裡面有web瀏覽器, 也可以安裝Opera mini, 於是我就想用這手機裡的瀏覽器來關心股價.
但遇到的一個問題就是, 我常看的奇摩股市一個頁面實在太大, 以前窮學生根本沒錢去辦個3G網路吃到飽, 於是想說我寫一個頁面只有顯示我要看的資訊就好, 廣告一律濾掉.
於是我就寫了一個頁面有這樣的功能:

  1. 根據使用者輸入的股號, 抓取相對應的奇摩的股市資料頁面
  2. 解析該頁面, 拆出成交價, 買進賣出, 漲跌幅
  3. 輸出結果
當時也只會php, 就拿了網路上的php parser library來作

過了一陣子開始當研替的時候, 辦了3G網路吃到飽, 於是就冷落了這個頁面, 直到最近又開始辦有限流量的網路方案才又想到這個頁面, 哈.

有時間的話也想用Google App Engine的架構來重新整理一下這個code...

2012年11月13日 星期二

UVa online judge 540 - Team Queue

寫了好幾天的題目, 終於AC了...Run Time 0.108
順便拿這題來練習 1. pointer 2. linked list組成的queue 3. malloc/free的檢查




2012年11月8日 星期四

UVa online judge 10055 - Hashmat the Brave Warrior

UVa online judge 10300 - Ecological Premium

題目要看懂就ok

UVa online judge 401 - Palindromes

簡單來說就是 1. 有一個 function(或者寫成 array也行)來判斷是否有mirror字元 2. 判斷是否有回文(palindrome) 最後, 輸出的時候要多一個'\n'...因為這個原因, 我多了三次WA...

2011年12月13日 星期二

SVN server on Ubuntu Desktop

http://blog.chinson.idv.tw/2009/12/subversion-server-on-ubuntu.html

第一步照做, 第二步創使用者權限的可以這樣

新增使用者資訊
$sudo htpasswd [-參數] /opt/svnroot/htpasswd username
依照指示輸入使用者密碼即可。
/opt/svnroot/htpasswd 這個可以自己改成想要的路徑與檔名
參數:
-c:表示是否要新建檔案,舊有檔案內容會完全刪除,適用於第一次建立檔案時
-m:密碼以 MD5 進行編碼

2011年8月23日 星期二

於ubuntu 10.04下安裝Java JDK 1.5 續

由於前一篇文章的apt source site現在已經找不到sun的JDK package, 所以目前只能去oracle網站下載JDK還有JRE所需要的軟體.

安裝所需要的軟體如下
JDK http://www.oracle.com/technetwork/java/javase/install-139487.html
JRE http://www.oracle.com/technetwork/java/javase/install-138789.html

這兩個檔案其實就是自解檔, 下載之後加個執行屬性,執行之後就會解開來.
把自己的/etc/profile裡面加個PATH, 指到 [path to JDK]/bin 以及 [path to JDK]/jre/bin 即可

2011年4月13日 星期三

於ubuntu 10.04下安裝java jdk 1.5

因為Android source 必須使用java5才可以編譯,但是Unbuntu10.04 已經沒有再提供java5的版本

所以才會有此文教學如何在Unbuntu 10.04下安裝java5版本,並且將java版本降至java5才能編譯Android source

方法如下:

1、在/etc/apt/sources.list中加入java5 deb連結

sudo gedit /etc/apt/sources.list

於此檔案最後面加上如下文字:

deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

2、更新apt-get連結

sudo apt-get update

3、安裝java5 jdk

sudo apt-get install sun-java5-jdk

4、將java版本降為java5

sudo update-java-alternatives -s java-1.5.0-sun

若想改為其他java版本可以使用

sudo update-java-alternatives -l

來查看所有安裝java的版本

ex:

java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk

5、檢查java版本

java -version

如果出現

java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02)
Java HotSpot(TM) Server VM (build 1.5.0_19-b02, mixed mode)
就代表成功了!

6、設定環境變數

在bashrc檔案中加入安裝的java路徑

sudo gedit ~/.bashrc (bashrc)

export JAVAHOME=/usr/lib/jvm/java-1.5.0-sun(jdk安裝路徑)
export PATH=$PATH:$JAVAHOME/bin:$JAVAHOME/jre/bin:$JAVAHOME/bin/lib
export CLASSPATH=.:$JAVAHOME/jre/bin:$JAVA_HOME/lib

2010年11月22日 星期一

ADB driver in Ubuntu

1. lsusb

at first, we need to know how your computer recognize your android device. Just type "lsusb" and all the usb devices that connect to your computer will be listed. see what you got at the output. in my case, i have a Motorola Milestone, and this is my output:

Bus 001 Device 059: ID 22b8:41db Motorola PCS

remember this and let proceed to second step...

2. sudo vim /etc/udev/rules.d/51-android.rules
and add this line:
SUBSYSTEM=="usb", SYSFS{"Motorola PCS"}=="22b8", MODE="0666"

this helps your computer to know what is this USB device, and hence recognizable

3.
sudo chmod a+rx /etc/udev/rules.d/51-android.rules
service udev restart

restart the USB device service


and your device should be listed as an ADB device by now :)



2010年9月1日 星期三

Java NIO DatagramChannel

Steps of using DatagramChannel

1.initializing DatagramChannel and bind it to specific port number, and connect it to the destination so that we can perform read and write later through this channel

DatagramChannel channel = DatagramChannel.open();
channel.socket().bind(new InetSocketAddress(9999));
channel.connect(new InetSocketAddress("wallyjue.blogspot", 80));


2. prepare the buffering space for receiving data, note that if the received packet contains more data than the Buffer can contain, the remaining data is discarded silently.
ByteBuffer buf = ByteBuffer.allocate(48);
buf.clear();

channel.receive(buf);


reference:
1. http://tutorials.jenkov.com/java-nio/index.html
2. http://onjava.com/pub/a/onjava/2002/09/04/nio.html
3. http://openjdk.java.net/projects/nio/javadoc/java/nio/channels/DatagramChannel.html

2008年12月16日 星期二

ssh tunnel for secure MSN connection

MSN 連線其實是很容易偷聽到的,一個簡單的抓封包程式就可以把msn對話內容抓起來。
相信很多公司的網管也是這樣來偷聽員工的msn對話XD
一個很簡單的方法就是用ssh連線來加密

需要的東西就是一個可以提供SSH連線的機器,還有你的電腦上要裝Putty

1.建立ssh tunnel (using Putty)
執行Putty的時候,到Connection -> SSH -> Tunnels 把 Source Port 填上你
要的Port,假設是 7777 好了,Destination在下面點選 Dynamic,之後按Add,就會在上面
看到一個D7777的entry,然後再到Session 那邊輸入Host Name,並且連線。
要注意的是,你在用msn的時候,這個Putty視窗是不能關掉的,因為他是在幫你傳msn資料。

2.改變msn連線方式
在msn連線的進階選項中,可以選擇 SOCKS 或者 SOCK5 的方式來作連線,位址輸入 localhost:7777
,7777就是剛剛Putty裡面使用的forwarding port,然後通常會要你輸入使用者名稱以及密碼,
這時就把你SSH登入時使用的帳號密碼輸入即可。
通常改變連線方式之後,需要你重新執行程式,這樣才會改成功。一個簡單的確認方式是用Wireshark
來抓你丟出去的封包,應該可以看到你的機器上有用SSH加密過的封包丟到提供SSH連線的機器。


此方法僅供參考XD,我是覺得一山還有一山高,不該亂說的話,還是不要亂說....XD

2008年8月15日 星期五

Ubuntu 下安裝Qt4

今天想裝個Qt4來玩玩,依照以前在Windows下裝的方法來裝卻發現make 的時候有error
後來又看到可以用Synaptic套件管理的方式來裝,裝好了卻又發現不能編譯,可能有一些套件我沒有抓到吧,最後看到有人談到用apt-get的方式安裝,發現這樣真是又快又不佔空間

$ sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig

這樣就可以了,大概只需要10分鐘不到的時間吧,之前在Windows下大概搞了快四小時吧@@

趕快抓Qt4裏面的tutorial來編譯看看.

#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.show();
return app.exec();
}

然後依序執行以下指令,Makefile會自動產生

$ qmake -project
$ qmake
$ make

執行檔就跑出來囉

2008年8月10日 星期日

解決ssh連線時 unprotected private key file 問題

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for private key file are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.

Just execute this and I solved my problem.

chmod 0600 [private key file]




The reason of this issue might be the file property. Just change to 600 would probably solve this issue. Remember to add sudo if you are not root to your machine.


這是我ssh連線時遇到的問題,原因是我把private key跟public key搬來搬去
檔案性質可能有被改到吧, I'm not sure for that.
anyway,就修改回來吧
"chmod 0600 [private key file]"
就可以了