2007年8月23日 星期四

FON+ AP 爛死了~ >"<

我買了兩台上禮拜五就到手了
剛剛裝起來發現無線網路超級不穩
完全不能使用... 可以退貨嗎!?
第一代的 FON AP 還比較穩勒~ >"<

2007年8月22日 星期三

C/C++ Programming on Linux

網路上其實有不少 C/C++ Programming on Linux 的入門資料~
只是大部分都是英文的~ 所以想當然爾~
想要學習 C/C++ Programming on Linux 基本的英文閱讀能力是必要的~
我會建議初學者先去看
http://www.advancedlinuxprogramming.com/http://tldp.org/LDP/lpg/ 瞭解系統底層的架構
在學習的過程中參考 http://www.gnu.org/manual/manual.html 來當輔助
等到有一些瞭解之後再來學習 C/C++ GUI Programming on Linux
目前兩大主流是 GTK/C http://www.gtk.org/documentation.html 跟 Qt/C++ http://doc.trolltech.com/
學習的過程中最好能夠學會使用 Vim 或是 Emacs 或是 Eclipse
還有熟悉 Makefile 的語法跟一個版本控管系統 (cvs/svn/svk/git/bzr/hg)
熟悉使用 wiki 系統來做筆記能夠幫助學習
還有最好也把 Linux 系統當作平日的桌面使用環境
這樣才能夠事半功倍地學習 C/C++ Programming on Linux

2007年7月24日 星期二

Beta Radio v0.1.0 debian package

可以在這邊下載 http://code.google.com/p/betaradio/downloads/list
有問題可以回報到 http://code.google.com/p/betaradio/issues/list
ubuntu 應該也可以裝吧~ @.@a
感謝 kanru 的大力幫忙~~~ ^o^

2007年7月14日 星期六

喵的勒... 被 ubuntu 的 /bin/dash 錶到了... >"<

原本用 bash 的 /bin/sh 可以跑的 script 在 dash 的 /bin/sh 就不能跑了~ 會出現 "Syntax error: redirection unexpected" 的錯誤訊息~ >"<
Ubuntu 為了加速開機的速度使用了 dash 來取代傳統的 bash
/bin/sh -> /bin/bash 改成了 /bin/sh -> /bin/dash
雖然說 dash 體積有比較小開機時速度也比較快
但是在開機之後使用某些原本在 bash 環境可以正常使用的 script
換到了 dash 之後反而會出現一些莫名其妙的問題
對於想在 Ubuntu 上面開發程式的人會是一件非常討厭的事情
暫時的解決辦法就是設成 /bin/sh -> /bin/bash
為了加速開機的速度反而在其他地方產生了問題
反正改變傳統一定是會帶來問題的
遇到新問題再想個辦法來解決

2007年7月5日 星期四

Java 的外部命令

import java.io.*;
...
try {
Process p = Runtime.getRuntime().exec("ls");
String line;
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null)
System.out.println(line);
input.close();
} catch (IOException e) {
...
}
...

基本又實用... 先記下來... :P

2007年7月3日 星期二

JNI - Java Native Interface

The Java Native Interface (JNI) is a programming framework that allows Java code running in the Java virtual machine (VM) to call and be called by native applications (programs specific to a hardware and operating system platform) and libraries written in other languages, such as C, C++ and assembly.
... from the link

HelloWorld.java
class HelloWorld
{
public native int[][] multiply(int A[][], int B[][]);
static
{
System.loadLibrary("HelloWorldImp");
}

public static void main(String[] args)
{
HelloWorld test = new HelloWorld();
int[][] A = new int[5][5];
int[][] B = new int[5][5];
int[][] result = test.multiply(A, B);
System.out.println(result[0][0]);
}
}

然後使用 javac HelloWorld.java 產生出 HelloWorld.class
接下來再使用 javah HelloWorld 產生出 HelloWorld.h

HelloWorld.h
/* DO NOT EDIT THIS FILE - it is machine generated */

#ifndef __HelloWorld__
#define __HelloWorld__

#include

#ifdef __cplusplus
extern "C"
{
#endif

JNIEXPORT jobjectArray JNICALL Java_HelloWorld_multiply (JNIEnv *env, jobject, jobjectArray, jobjectArray);

#ifdef __cplusplus
}
#endif

#endif /* __HelloWorld__ */

再把 HelloWorld.c 寫出來
HelloWorld.c
#include "HelloWorld.h"

JNIEXPORT jobjectArray JNICALL Java_HelloWorld_multiply (JNIEnv *env, jobject obj, jobjectArray A, jobjectArray B);
{
jobjectArray C;
...
return C;
}

最後使用 gcc -Wall -g -shared -fPIC HelloWorld.c -o libHelloWorldImp.so
現在終於可以執行 Java 程式了
java -Djava.library.path=./ HelloWorld
使用 Java 來做跨平台程式開發
在關鍵部份再利用 JNI 來將平台特性最佳化