-
车站的田园与现代
-
老家的油菜花
-
[scala]50行实现web表单验证器
-
时间管理实践小记
-
GetBeanProperties via Scala
一个简单的用Scala写的获取bean属性的例子。核心方法是Introspector#getBean(Class)。 import java.beans.Introspector object GetBeanProperties { class Person(id: Long, name: String) { def getId = id def getName = name } def main(args: Array[String]): Unit = { println(GetBeanProperties(null)) println(GetBeanProperties(new Person(1L, “xnnyygn”))) } def apply[T](bean: T): Map[String, Any] = Option(bean) match { case None => Map[String, Any]() case _ => doApply(bean) } private def doApply[T](bean: T):…
-
迟到的2013春节小兔子
-
领取N2证书和之后
-
returnvalue & xwrapper
introduction 背景是WebService,具体实现是XFire。由于某种原因XFire的Fault无法使用,导致只能使用返回值表示成功与错误的情况。举例如下: // return type class IntWrapper { boolean success; String message; int value; } // client IntWrapper wrapper; if(wrapper == null) throw new NullPointException(“wrapper is null”); if(!wrapper.success) throw new Exception(wrapper.message); return wrapper.value; 实际实现时,发现服务有很多方法,每个方法有各自的返回类型,有部分重复。其次是服务端每个方法都必须try catch,把错误转化为返回值。第三是客户端代码也有重复,每次都要检查是否为null和是否成功。 为了减少重复代码,提供如下方案:
-
compile install mysql 5.6.10 and optimize for low memory VPS on debian 6
compile # download mysql-5.6.10 from https://dev.mysql.com/downloads/mysql/ tar zxf mysql-5.6.10 cd mysql-5.6.10 # set default charset to utf8 cmake -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci # install to /usr/local/mysql make && make install initialize database # create user mysql and change owner of /usr/local/mysql to mysql groupadd mysql useradd mysql -g mysql chown -R mysql:mysql /usr/local/mysql # still in mysql-5.6.10…
-
5k5购机记
配置列表 CPU Intel i5 3470 ¥1288 Motherboard GIGABYTE ga-h77-ds3h(rev 1.1) ¥679 Memory Kingston 4G 1600MHz ¥159 Graphic Card Sapphire HD 6770 1G ¥699 Wireless Card TP-LINK TL-WN851N 300M ¥154 Power Seasonic SII2-520W ¥439 Case Cooler Master RC-550-KKN1 ¥459 Monitor Dell U2312HM ¥1377 Hard Disk Seagate ST500DM002 SATA3 500G ¥345 No mouse, keyboard, dvd-rw 选配 选择台式机的原因一个是笔记本比较贵而且屏幕相对小,一体机总觉得差那么一点,另一个原因是去年就想配一台电脑,但是感觉没啥特别强烈的需求暂时放下了。…