2010年11月17日 星期三

這就是人生........

忙了一年多 結果 看到這兩則新聞 就 傻在哪裡了.......


先前曾有消息指出Android 2.3版本的介面將會有所調整,並將以視訊方面的通訊功能為其主要特色,同時Google也傳出將在今年聖誕節前後正式釋出。目前Google已經將一組薑餅人的模型設立在總部前的草地上 (如以下影片),或許目前還在進行最後的相關調整作業吧?

這一年多來我們都在作類似的 project, 但 acer已經做出產品..........
雲端飄進家裡 宏碁Clear.fi扣緊家人

2010年11月16日 星期二

Lazy Make for Android



Step 1. Setup the Environment Variable
In the Windows Environment
DEV_CPP_HOME= C:\dev-cpp\bin
ANT_HOME= c:\ant
ANDROID_HOME=c:\android-sdk
JAVA_HOME = c:\jdk-1.6

PATH=%DEV_CPP_HOME%\bin;
%JAVA_HOME%\bin;
%ANDROID_HOME%\tools;
%ANT_HOME%\bin;

Step 2. Create Project
android create project \
--target 11 \ ( 11 for android 2.2 )
--name MyFirstActivity\
--path ./helloworld \
--activity MyFirstActivity \
--package idv.example.anr

Step 3. Write the Makefile
//Makefile is in the android project /helloworld
all:
ant debug
ant install
adb shell am start -n idv.example.anr/idv.example.anr.MyFirstActivity

Step 4. Make it.
//Makefile is in the android project
open the AVD ( android 2.2 )
and in the /helloworld, type make

2010年11月15日 星期一

Work Note, the adaptive bandwidth rule

adaptivebandwidthrule
Name=""
Category=""
Type="Stream"
Target="CaptureStream"
ResponseAction="ChangeProfile"
// ChangeMulticastTree
RangeMinKbps=
RangeMaxKbps=
ChangeProfileName="none"
ChangeMulticastTree
CallbackAction="fill the callback function name"
/>

C preprocessor, MACRO必要之惡

// file macroAid.hpp
#ifndef MACRO_AID_HPP
#define MACRO_AID_HPP

#define MACRO_SETTER_DECL( type, VarName)\
int Set##VarName(type v);
#define MACRO_SETTER_IMPL( cls, type, VarName, var)\
int cls::Set##VarName(type v) {\
this->var = v;\
return 0;\
}

#define MACRO_GETTER_DECL(type, VarName)\
type Get##VarName();
#define MACRO_GETTER_IMPL( cls, type, VarName, var)\
type cls::Get##VarName() {\
return this->var ;\
}

#define MACRO_VARIABLE_ACCESS_DECL( type, VarName, var )\
private:\
type var;\
public:\
MACRO_GETTER_DECL(type,VarName);\
MACRO_SETTER_DECL(type,VarName);

#define MACRO_VARIABLE_ACCESS_IMPL( cls, type, VarName, var)\
MACRO_SETTER_IMPL(cls, type, VarName, var);
MACRO_GETTER_IMPL(cls, type, VarName, var);
#endif

// a.hpp
#include "macroAid.hpp"
#ifndef A_HPP
#define A_HPP
class A {
MACRO_VARIABLE_ACCESS_DECL(int, Size, size);
MACRO_VARIABLE_ACCESS_DECL(int, Age, age);
};
#endif

// aSetFunc.cpp
#include "a.hpp"
MACRO_VARIABLE_ACCESS_IMPL(A, int,Size, size);
MACRO_VARIABLE_ACCESS_IMPL(A, int,Age, age);

雖然 MACRO會讓程式碼不易讓程式碼分析器 例如:SOURCE INSIGHT 解析,
但它真的很方便可以減少打錯字的危機, 用簡單的幾行就可以完成原本複雜的工作

瞎扯淡Dlib

最近因為在重寫一份library, 本來是毫無結構的c , 因為想要做一個像樣的成品,

開始用c++重寫. 一開始用 c++ template 寫了一個 Indexing-able的 link-list ,

然後利用寫了一個屬於自己的 XML container, 利用 libxml parse xml, 並且把資料放到自己的 container 裏面.

接著就越寫越大, 連 Hash 都寫出來了, hash pair 是 string name : variable pointer ,
想法是把 string 丟進去 hash 他就可以給我 variable 的 pointer + variable type , 之後就可以把值放入該 variable當中

日前閒逛 後發現 dlib 這個 c++ 的 library 存在, 他也打著高效能的號, 這個網址是dlib實作 thread的api 說明 http://dlib.net/api.html#threads , 我自己也有寫一個類似的API行為都很像, 果然用OO的 Modeling Code behavior 最後得到的結論都很像 hmm


我在想如果用來 dlib 做我目前的工作我想可以加快很多, 但 boost license 我並不太了解, 不太敢貿然使用

2010年11月1日 星期一

Work Note and Metaprogramming

Work note
XML Profile Manager
Parameter Manager
to use hashing instead the sequential search

突然想到 LiuKen之前說過的 language sugar 的議題,
c++ 與 c 本身的限制讓需要做些手腳才能夠有類似 javascript 與 c# 等
metaprogramming 的能力.
Metaprogramming
http://en.wikipedia.org/wiki/Metaprogramming
Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data.

"generative programming"
#!/bin/bash
# metaprogram
echo '#!/bin/bash' >program
for ((I=1; I<=992; I++)) do echo "echo $I" >>program
done
chmod +x program

Not all metaprogramming involves generative programming. If programs are modifiable at runtime or if an incremental compilation is available (such as in C#, Forth, Frink, Groovy, JavaScript, Lisp, Lua, Perl, PHP, Python, REBOL,Ruby, Smalltalk, and Tcl), then techniques can be used to perform metaprogramming without actually generating source code.

網路上找到的範例: 用 c++ 去產生一個 source 然後編譯.