Showcase on Socket IO for Web and Mobile

This is the showcase of Socket IO Library (written in Node JS) which brings the real time web sockets for the web and mobile.

I had created a video to showcase the features.

In the demo, the sample application is a stock application that have list of companies along with the data. The data will be changed every second and the changed data is reflected on web pages, iPhone Simulator, and my New ipad (Real device) in real time.

I had deployed the server side page at here: http://deep-moon-3881.herokuapp.com/, for you, you can open multiple browser window to see the changes of data. But the key here is the changing data can be broadcasted to native mobile apps instead of web HTML.

电影 大魔术师 感

刚看了一部中文电影,大魔术师,故事讲述清末明初军阀割据的年代,一个传统魔术师,和他的三年未见的未婚妻,和某军阀司令之间的故事。

电影带有很多经典魔术,有动作场面,也有喜剧成分。总司令真是傻得可爱啊。

故事穿插得有点不跟常理。比如,总司令原本看起来是坏人的,也有开枪杀人,但是最后也是好人。大魔术师原本要从司令那里带走他的未婚妻的,最后也教司令怎么去追她,教他变小魔术。大魔术师的那群班子原本是要设计绑架司令的,最后也跟司令一同对付真正的敌人(勾结外国势力的汉奸)。最后一幕是那群汉奸去看魔术,司令和那个女主角一起坐着坦克车,从正在播放的电影画面真正驾到舞台上,把汉奸炸飞了。原本看到有很多计谋,动作,轻微暴力的故事,最后都有点喜剧成分。。。

人有两种,一是喜欢去破解魔术,二是喜欢被魔术骗,也就是欣赏魔术。欣赏魔术最好了,为什么要拆穿呢。这是魔术师问总司令,总司令回答的。

梦想,在想而已,只是虚幻的。必须靠自己努力争取才会实现。

这是一部值得看的电影。推荐看。

电影电脑终结者 terminal error 感

刚看了一部欧美电影,电脑终结者 Terminal Error.

这是一部非常值得看的好电影,它让人深思:人过度依赖科技,电脑拯救全世界;还是科技让人类有更多时间做更重要的事情。

很感动的电影,一位父亲,忙于工作,和前妻分离,留下一个男孩。他是某安全软件公司的老板,他的软件供应整个城镇的系统。他曾经和他的前妻在很多年以前和一个黑客共事过。这名黑客说当年被这位老板炒鱿鱼,毁了他的生活,他怀恨在心,于是设计了一个智能型病毒,并感染了俄罗斯乌克兰的核电厂爆炸,造成200条生命死亡。这个病毒会自我学习进化,最后它搞乱了整个城市的系统,造成市内瘫痪。它告诉我们人类有多么的贪婪,想当上帝,因此它想拯救世界,毁灭全人类。

这部电影给我们的启示是我们应该珍惜及重视爱我们的人,而不要找任何借口,准备好了吗?不用准备了,就现在。

补充:
在电影里面常出现黑色背景青色的代码一直滚动着,仔细瞧了瞧,竟然是HTML和普通Javascript,看不出有什么危险性。
另外在电影里面也看到那个智能型病毒会自我学习进化,自己升级代码,有Genetic Programming 遗传学编程的味道,我想圣经里说的世界末日及救世主的出现,接下来的应该就是我们人类自己创造的科技。

Walkaround for Titanium 1.8.x deploy apps on Xcode 4.3 and iOS 5.1

Xcode 4.3 and iOS 5.1 are released and believed that many developers had upgraded to that. However, Titanium 1.8.x still not officially support Xcode 4.3 and iOS 5.1.

By the way, this is the walk around for Titanium 1.8.x to deploy apps on Xcode 4.3 and iOS 5.1, learn more at http://developer.appcelerator.com/blog/2012/03/titanium-and-xcode-4-3-revisited.html

The detailed steps that I had gone through:

1) Make sure if you have Xcode 4.3.1 installed, and then, you may execute:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

For me, I switched to /Developer, where my Xcode installed there.

2) Kindly download ios-sim, and copy over to the Titanium SDK path as listed in the link.

(However it is not enough to work in my machine and need following steps)

3) Open Titanium Studio, do a full clean rebuild for your apps, do not care if your iOS SDK Version just showing 5.0, but not 5.1.

4) After that, open Xcode 4.3.1.
If your apps name is MyApps, you probably see MyApps, MyApps-iPad, MyApps-iPhone, MyApps-universal in your schemes. Kindly select MyApps and choose your proper device (ipad or iPhone).

5) Modify your Project Build Settings -> Architectures, make sure Debug / Release all use Standard (armv7), and select iOS 5.1.
For Targeted Device Family, if you want to deploy your apps on iPhone, then you choose just iPhone, or iPad, or both (iPhone/iPad).

The Step 3 – 5 worked on my machine. Now I successfully deploy my existing iOS Apps on my iPhone and new iPad that running iOS 5.1.

Note: Titanium Version 2 that will released in April was announced to support iOS 5.1.

Apache Mahout A Machine Learning Library

Apache Mahout which is a Java based machine learning library released under Apache License.

Currently Mahout supports mainly four use cases: Recommendation mining takes users’ behavior and from that tries to find items users might like. Clustering takes e.g. text documents and groups them into groups of topically related documents. Classification learns from exisiting categorized documents what documents of a specific category look like and is able to assign unlabelled documents to the (hopefully) correct category. Frequent itemset mining takes a set of item groups (terms in a query session, shopping cart content) and identifies, which individual items usually appear together.

Learn more at https://cwiki.apache.org/confluence/display/MAHOUT/Mahout+Wiki

Have a QuickStart at https://cwiki.apache.org/confluence/display/MAHOUT/Quickstart

Overview for Functional Programming

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state.

In practice, the difference between mathematical functions and notion of a “function” used in imperative programming is that the imperative function can have side effect, it changes the program state. Means the same language expression can have different results over time, but functional programming is not, the data is immutable, unchangeable, the same language expression always lead to same result.

Functional programming promotes higher order function, that it is able to pass function as a parameter to other function.

In JavaScript,


var len = function(list) {
return list.length;
}
var sum = function(list) {
var total = 0;
for(var i = 0; i < list.length; i++) {
total += list[i];
}
return total;
};
var avg = function(list) {
var total = c(list, sum);
return total / c(list, len);
};
var c = function(list, m) {
return m(list);
};
var a = [1,2,3,4,5];
c(a, sum); // 15
c(a, avg); // 3

Many languages support Closures, the popular one is JavaScript, F#, Erlang, Scala (JVM Language). Java 7 is adding support declaration of Lambda function. Excitingly, PHP 5.3.0 started to support anonymous function now.

Before Java 7 is introduced, we also can declare anonymous classes (a class without assigning reference). From inside the method of anonymous classes to access the variable outside the scope of the anonymous class, the variable should declared as final. Means, the variable must be immutable, unchangeable, otherwise it caused side effect.


final int a = 0;
new SomeClass() {
void someMethod() {
System.out.println("a: " + a);
}
}

But sometimes we want to achieve some simple computation, we may just define an anonymous function passed as an argument to other function.

More Information

PHP 5.3.x
http://jburrows.wordpress.com/2011/06/24/the-state-of-functional-programming-in-php-5-3-x/