terra incognita

Set up Contiki and Cooja on Ubuntu from scratch


If you want to set up your Contiki development environment on a server rather than using the Instant Contiki virtual machine, this is for you.



Follow the steps in Contiki wiki page Setup Contiki toolchain in ubuntu 13.04.

Instead of cloning the Contiki repo in the Step 3 mentioned above, you should upload the Contiki folder from the Instant Contiki VM to your server. This is because the repo is outdated somehow. I had the problem that the source file cannot be compiled using the source files in the repo.

Now you should be able to compile example files.


You may want to simulate your application using Cooja on the server, which is useful when you need to do a batch simulation without GUI.

Do the following steps to configure Cooja simulation tools on your server.

Upload all files under the contiki/tools/cooja folder from the Instant Contiki to your server.

Go to cooja directory, run ant run to compile.

Now navigate to cooja/dist folder, run ......

2015-07-17 18:26 631

迈入人类进化新时代——Queal 测评


Queal 是一款「健康、快速并且可负担的饮食替代糊状物」(Healthy, quick & affordable meal replacement shake)[1]。作为一款日常餐饮替代物,Queal 提供了多种口味,能提供每日所需营养,这样用户就可以不用做饭了。选择 Queal,进入人类饮食新篇章。


在美利坚合众国,有一款产品叫做 Soylent,虽然官方风格不太一样,但是看起来都很骨骼惊奇。下面我们来做一个简单的对比,见下表。




85 USD (28 meals)


55 EUR (30 meals)

由 表 可知,价钱差不多。但是我们最后选择了 Queal,为什么呢?诶,说对了,因为 Soylent 不运到美国以外[2]。如果同行(peer)有幸通过 Soylent 进入了人类饮食发展的新篇章,请记得写一篇测评。



在周末的时候自费订购了一套 Taste Tester 套装,该套装包含 30 meals,7 种口味。关于口味的问题,笔者英文不好,无法理解 "AWESOME APPLE PIE" "FUNKY FOREST FRUIT" "BANANA MANIA" 之类的到底想表达什么味道,也就先不在意这个问题了。

在发货后一天,如期收到了送货上门的一个箱子。该箱子大概有 5kg 多重。为什么笔者这么确定呢?诶,又说对了。因为根据简单的计算,10 包 500g+ 的粉末加上其他的辅料,那么就是 total weight >= 500g * 10 = 5000g = 5kg。经过这么一番简单的数学推理,读者朋友是不是豁然开朗了呢?好的,下面我们进行开箱。


开箱(unboxing),最重要的就是把箱子开开了。本次开箱笔者采用了刀子,这样比较方便。如 图1 所示,开箱后会发现一张 manual,一张 business card 和下面的 10 包粉末状物体。


图2 中展示了拿掉 manual 以及 business card 后的样子,也就是送的一个杯子和粉末状物体的真身。

2015-04-30 18:59 332

Introducing XWPassbook


XWPassbook is a parody of Passbook in iOS.

Here is how it looks:


Try it

Just check it out on GitHub

2015-04-07 10:12 275 Objective-C iOS

Understanding MWPhotoBrowser

MWPhotoBrowser : UIViewController

MWZoomingScrollView : UIScrollView

- (void)handleDoubleTap:(CGPoint)touchPoint;


Zoom in (2x) or zoom out.


- (void)imageView:(UIImageView *)imageView doubleTapDetected:(UITouch *)touch;

- (void)handleDoubleTap:(UITouch *)touch;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;


- (void)handleDoubleTap:(CGPoint)touchPoint {

// Cancel any single tap handling

[NSObject cancelPreviousPerformRequestsWithTarget:_photoBrowser];

// Zoom

if (self.zoomScale != self.minimumZoomScale && self.zoomScale != [self initialZoomScaleWithMinScale]) {

// Zoom out

[self setZoomScale:self.minimumZoomScale animated:YES];

} else {

// Zoom in to twice the size

CGFloat newZoomScale = ((self.maximumZoomScale + self.minimumZoomScale) / 2);

CGFloat xsize = self.bounds.size.width / newZoomScale;

CGFloat ysize = self.bounds.size.height / newZoomScale;


JSON2Mantle:Generate Mantle models using JSON file

Mantle is a model framework for Cocoa and Cocoa Touch. However, it is still needed to put each field name in a JSON file into the Mantle model files. To stay lazy, I wrote a tool to generate Mantle models by xxx.json file in Python.

Here it is: https://github.com/sutar/JSON2Mantle


$ sudo pip install JSON2Mantle


Converts property names automatically

var_name will be converted to varName.

Reserved words in Objective-C will be converted. For instance,id would become modelId.

(Semi) type detection

Preliminarily, it is possible to deal with primitive tpes, such as NSIntegerNSStringBOOL. Detecting types like NSURL is to be done.

Nested JSON object

Consider the following user object:


"id": 10,

"name": "Clementina DuBuque",

"username": "Moriah.Stanton",

"email": "Rey.Padberg@karina.biz",

"address": {

"street": "Kattie Turnpike",


2015-03-11 00:59 299