乌敏岛 Ubin Island

Categories: 垃圾山; Tagged with: ; @ November 17th, 2013 21:14

如何去乌敏岛?

去Changi Point Ferry Terminal, 坐船($2.5/人) –> 乌敏岛;

地方不大,  本着能起多少起多少的原则, 我骑了这么多:

IMG_20131116_214805

 

几点主观性的说明:

1. 之前看到一个帖子里说乌敏岛上有很多猫(点这),  但我一直猫都没有看到, 相反的是狗很多, 路上遇到至少两个team的土狗, 以及一对行进中的野猪(我猜不是野猪);

2. 自行车很便宜, $10左右就能租一天, 不需要押金或是其他抵押;

3. 第一眼看到弯道标志, 我以为是”前方有屎”

4. 要是修个环岛的路骑着就比较爽了;

5. 很多卖水的地方, 所以基本不用带.  (大概在21KM处有一家, 老太太跟老头,很和善, 一瓶冰镇的100 Plus也只是$1.5; )

LESS.js Hello world

Categories: JavaScript; Tagged with: ; @ November 6th, 2013 23:58

What is Less?

LESS extends CSS with dynamic behavior such asvariables, mixins, operations and functions.

Less Hello world

Style.less:

@header-color: #FFF000;
h1 {
  border: black dashed 2px;
  color: @header-color;
}

for more syntax or functions: http://lesscss.org/#reference

HTML:

<html>
<head>
    <title>Test-Liguoliang.com</title>
    <link rel="stylesheet/less" type="text/css" href="./css/src/style.less" />
    <script src="./lib/less/less-1.5.0.min.js" type="text/javascript"></script>

</head>
<body>

<h1>Header</h1>

</body>
</html>

IntelliJ Idea Less compiler plugin:

http://plugins.jetbrains.com/plugin/7059?pr=idea

The must-have plugin if you are using Less.js and IntelliJ!

what you need to do is install the plugin, and config it. after you finished, it’ll compile the .less to .css every time you modify the .less.

image

Jersey/Jackson Polymorphic Deserialization

Categories: Java; Tagged with: ; @ October 1st, 2013 20:56

Jersey can handle concrete data binding smoothly, however, for Polymorphic, it’s not very configurable.

e.g.:

IUser

DefaultUser, SGUser, CNUser

We need a web service, which accept POST request from Client side:

saveUser(IUser newUser)…

Nobody knows it’s a DefaultUser or SGUser, or CNUser, except Spring config XML.  and there’re some ways to use Jersey do the deserialization.:

http://programmerbruce.blogspot.sg/2011/05/deserialize-json-with-jackson-into.html

 

However, I prefer to use “Simple” Data Binding from Jackson to do the mapping manually:

“Simple here just means that range of value types is limited to core JDK types”

  Object root = mapper.readValue(src, Object.class);
  Map<?,?> rootAsMap = mapper.readValue(src, Map.class);
 

So in the saveUser() method, we can get the raw values and then initialize the instances with the help of Spring to make sure what we know and what we only need to know is ‘Interface’/Contract:

saveUser(Map<String, Object> json) {

(Cast) json.get(“key”);

}

Code Review 痛并享受着

Categories: Java; Tagged with: ; @ September 12th, 2013 0:06

1. Interface

几乎所有的Class都是某些Interface的实现, 但我从来没有认真考虑过接口应该怎么用, 用到什么程度.

举例说, 有接口IDatabase, 还有具体类DefaultDatabase, Oracle, DB2…

理论上, 除了配置文件/Factory中可能会用到具体实现, 初次之外, 就不应该在任何Class中使用具体实现!

但事实上, 尤其是在不假思索, 取名叫做DefaultDataBase时,  经常会使用DefaultDataBase而不是IDatabase…

 

2. SVN

模块/文件夹 需要重构+重新命名.

由于担心SVN出现莫名其妙的问题, 所以新建了文件夹, 然后将新的文件逐步复制进去.

所有文件的历史记录将丢失.

 

3. Exception

WebService的Exception应该继续抛出, 而不是处理. 这样客户端在收到Exception后可以进行后续处理, 譬如重定向到某一个错误页面.

Maven: Reuse tests in other Modules

Categories: Development Notes; Tagged with: ; @ September 6th, 2013 0:13

Requirement:

Reuse testcase in other Modules.

In ‘Module A’, I want to reuse the testcases in ‘Module-Core’ (e.g. extend Module-Core…AbstractUserManagerTest)

Solution: using attached test

http://maven.apache.org/guides/mini/guide-attached-tests.html

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.