在明新科技大學旁的出租屋拍到偷衣賊一枚。你這隻該死的偷衣賊, 浪費我整個晚上過濾三天的監視器紀錄。
- Jun 19 Thu 2008 09:14
拍到偷衣賊
- Jun 03 Tue 2008 09:13
VMWare Server使用shared disk
建立磁碟檔:
vmware-vdiskmanager.exe -c -s 20Gb -a lsilogic -t 0 SharedDisk.vmdk
修改.vmx檔:
scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsi1.virtualBus = "VIRTUAL" scsi1:1.present = "TRUE" scsi1:1.sharedBus = "TRUE" scsi1:1.fileName = "D:\Virtual Machines\Shared Disk\SharedDisk.vmdk" disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" diskLib.dataCacheMaxReadAheadSize = "0" diskLib.dataCacheMinReadAheadSize = "0" diskLib.dataCachePageSize = "4096" diskLib.maxUnsyncedWrites = "0"
- Jun 02 Mon 2008 09:13
第一次還原魔術方塊
前段時間,魔術方塊突然又熱了一陣子,看著看著就想湊熱鬧。上週未在賣場補貨時,發現小朋友最愛的區域出現魔術方塊,順手就敲了一顆進購購物籃。回到家,看了看祕笈,用層解法不一會兒就弄出兩層,但是最後一層和最後一面卻花了兩個小時才排好。
- May 16 Fri 2008 09:12
第一次內灣夜騎
- Apr 07 Mon 2008 09:12
新玩具Trance 3
突然想玩自行車,所以星期日就跑去阿診自行車店看車。原本的目標是XTC SE2,在店裡被路人勸敗XTC HB3,對著SE2和HB3東看看、西看看的時候,看到老闆正在組新車,一問之下是Trance 1,再問價格是六萬多,直接拋棄不考慮。
繼續看老闆調教Trance 1時,一位老太爺騎著Anthem 1出現,此時目標開始轉移到雙避震車,看了看Anthem和Trance,比較喜歡Trance的外觀,可是對非預訂車款一無所知,看完Trance 1交車就先回家搜集情報了。
星期一早上剛好已經請假修牙,搞定牙齒之後離上工時間還有兩個多小時,自然就要把握時間再去車店逛逛。向老闆打聽中意的車款和售價,沒想到在這個大家都缺貨的時期,竟然有現貨。既然這麼巧,當然就拚下去啦!
一個半小時後,就開心地載著新玩具Trance 3趕去上工啦。
- Mar 20 Thu 2008 09:11
用Hibernate建立Membership
@Entity @Table(name="memberships") @IdClass(MembershipPK.class) public class Membership { private Integer groupId; private Integer userId; @Id @Column(name="group_id") public Integer getGroupId() { return groupId; } public void setGroupId(Integer groupId) { this.groupId = groupId; } @Id @Column(name="user_id") public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } }
@Embeddable public class MembershipPK { private Integer groupId; private Integer userId; public Integer getGroupId() { return groupId; } public void setGroupId(Integer groupId) { this.groupId = groupId; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } }
- Mar 17 Mon 2008 09:10
隱形眼鏡
戴了數年的眼鏡,鏡片鍍膜已經磨損、龜裂,所以下午就跑去換鏡片。等待的時候,順便問了一些隱形眼鏡的問題,本來想買日拋式,可是雙眼度數不同,要買就得買雙份,還在考慮的時候,老闆就說送我一副625度的季拋式試試看。所以,花了600元,不但換好鏡片,還得到隱形眼鏡、保養液、食鹽水。
- Feb 21 Thu 2008 09:08
Wicket和Spring
在Wicket程式用Spring,要在web.xml加入設定:
<context -param> <param -name>contextConfigLocation</param> <param -value>/WEB-INF/spring*.xml</param> </context> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
在WebApplication中要建立SpringComponentInjector:
public class BasicApplication extends WebApplication { @Override protected void init() { super.init(); addComponentInstantiationListener(new SpringComponentInjector(this)); } }
如果還想把bean注入WebSession,要用InjectorHolder:
public class BasicSession extends WebSession { public BasicSession(Request request) { super(request); InjectorHolder.getInjector().inject(this); } }
設定好之後,只要在需要注入bean的地方用@SpringBean即可,範例如下:
public class SignUpPage extends BasePage { @SpringBean private UserService userService; public SignUpPage() { add(new SignUpForm("signUpForm")); } class SignUpForm extends Form { private String name; private String email; private String password; @SuppressWarnings("unused") private String confirmPassword; public SignUpForm(String id) { super(id); PasswordTextField passwordField, confirmPasswordField; add(new TextField("name", new PropertyModel(this, "name")).setRequired(true).add(new StringValidator.LengthBetweenValidator(2, 32))); add(new TextField("email", new PropertyModel(this, "email")).setRequired(true).add(EmailAddressValidator.getInstance())); add(passwordField = new PasswordTextField("password", new PropertyModel(this, "password"))); add(confirmPasswordField = new PasswordTextField("confirmPassword", new PropertyModel(this, "confirmPassword"))); add(new EqualPasswordInputValidator(passwordField, confirmPasswordField)); } @Override protected void onSubmit() { User user = new User(name, email, password, User.ROLE_USER); try { userService.createUser(user); setResponsePage(HomePage.class); } catch (DuplicatedUserNameException e) { error(getLocalizer().getString(getId() + ".nameTaken", getWebPage(), "User's name is taken: " + name)); } catch (DuplicatedUserEmailException e) { error(getLocalizer().getString(getId() + ".emailTaken", getWebPage(), "User's email is taken: " + email)); } } } }
- Feb 11 Mon 2008 09:07
程式和內嵌Jetty共用spring context
應用程式內嵌Jetty運行webapp時,希望程式和webapp共用同一個spring context,在web.xml設定context loader listener時,要改用自定的MyContextLoaderListener。
JettyServer.java:
import org.mortbay.jetty.Server; import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.webapp.WebAppContext; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; public class JettyServer implements ApplicationContextAware { private ApplicationContext applicationContext; public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } public void start() throws Exception { int port = Integer.parseInt(System.getProperty("jetty.port", "8080")); SelectChannelConnector connector = new SelectChannelConnector(); connector.setPort(port); Server server = new Server(); server.addConnector(connector); WebAppContext context = new WebAppContext(); context.setClassLoader(applicationContext.getClassLoader()); context.setAttribute("applicationContext", applicationContext); context.setServer(server); context.setContextPath("/"); context.setWar("src/main/webapp"); server.addHandler(context); server.start(); } }
MyContextLoader.java:
import javax.servlet.ServletContext; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.web.context.ContextLoader; public class MyContextLoader extends ContextLoader { @Override protected ApplicationContext loadParentContext(ServletContext servletContext) throws BeansException { return (ApplicationContext)servletContext.getAttribute("applicationContext"); } }
MyContextLoaderListener.java:
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoaderListener; public class MyContextLoaderListener extends ContextLoaderListener { @Override protected ContextLoader createContextLoader() { return new MyContextLoader(); } }
- Feb 11 Mon 2008 09:05
Maven設定Terracotta
Maven repository沒有Terracotta和Terracotta Maven Plugin,所以要在pom.xml加入:
<repositories> <repository> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> <id>terracotta-repository</id> <url> http://www.terracotta.org/download/reflector/maven2 </url> </repository> </repositories> <pluginrepositories> <pluginrepository> <id>terracotta-snapshots</id> <url> http://www.terracotta.org/download/reflector/maven2 </url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginrepository> </pluginrepositories> <build> <plugins> <plugin> <groupid>org.terracotta.maven.plugins</groupid> <artifactid>tc-maven-plugin</artifactid> <version>1.0.3</version> <configuration> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupid>org.terracotta</groupid> <artifactid>terracotta</artifactid> <version>2.5.1</version> </dependency> </dependencies>
不過,Terracotta DSO Eclipse Plug-in比Terracotta Maven Plugin好用多了。
- Feb 08 Fri 2008 09:03
blog救援完畢
全靠Wayback Machine和Google,花了7個小時剪剪貼貼之後,總共救回117篇文章。
- Feb 08 Fri 2008 09:03
server被偷
放在遙遠的樓梯間機房裡的server在除夕夜9:38斷線,10點多趕到時,發現攝影機被破壞,樓梯間鐵門被撬開,機房裡的server和監視器主機都消失了。已經工作七年的server配備Intel Pentium III 700MHz CPU、512MB RAM、160GB HDD,上面運行著bento.tw、cert.tw、ruby.tw、zbwei.net,不但有email、blog、wiki、forum、電子書,最重要的是,還有大家都喜歡的神秘圖片。目前正在靠archive.org和google慢慢整裡公開的blog和wiki內容,其餘的資料就安心上路吧!blog暫時搬到http://forth.wordpress.com/,FeedBurner亦已修改至新位置。
- Feb 05 Tue 2008 09:02
Apple IIc開箱照
沒想到在2008年竟然能看見Apple IIc開箱照,能從1988年5月5日完整保存至今,實在太神奇了。eBay才真的是什麼都有、什麼都賣、什麼都不奇怪。
- Feb 01 Fri 2008 08:59
Java調用Ruby物件
RubyHelp.java:
public class RubyHelper { static { System.setProperty("jruby.home", new File("").getAbsolutePath()); } private RubyHelper() { } public static Object create(String className, Class interfaceClazz, String scriptFileName) { InputStream scriptInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFileName); if (null == scriptInputStream) { throw new RuntimeException("Could not find " + scriptFileName); } StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; try { for (int n; (n = scriptInputStream.read(buf)) != -1;) { sb.append(new String(buf, 0, n, "UTF-8")); } scriptInputStream.close(); } catch (IOException e) { throw new RuntimeException("Error loading " + scriptFileName + ": " + e.getMessage()); } Ruby runtime = JavaEmbedUtils.initialize(new ArrayList()); runtime.eval(runtime.parse(sb.toString(), scriptFileName, runtime.getCurrentContext().getCurrentScope(), 0, false)); return JavaEmbedUtils.rubyToJava(runtime, runtime.evalScriptlet(className + ".new"), interfaceClazz); } }
HelloService.java:
public interface HelloService { void hello(); }
hello.rb:
class Hello def hello puts 'hello there' end end
Test.java:
public class Test { public static void main(String[] args) throws Exception { HelloService s = (HelloService)RubyHelper.create("Hello", HelloService.class, "hello.rb"); s.hello(); } }
- Dec 27 Thu 2007 20:59
常用的ruby程式庫
- rails
- mongrel
- mongrel_cluster
- acts_as_cached
- acts_as_ferret
- capistrano
- fcgi
- gettext
- sqlite3-ruby
- mechanize
- ruby-net-ldap
- ruby-openid
- sendfile
- log4r
- rspec
- ZenTest