- 6月 19 週四 200809:14
拍到偷衣賊
- 6月 03 週二 200809: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"
- 6月 02 週一 200809:13
第一次還原魔術方塊
前段時間,魔術方塊突然又熱了一陣子,看著看著就想湊熱鬧。上週未在賣場補貨時,發現小朋友最愛的區域出現魔術方塊,順手就敲了一顆進購購物籃。回到家,看了看祕笈,用層解法不一會兒就弄出兩層,但是最後一層和最後一面卻花了兩個小時才排好。
- 5月 16 週五 200809:12
第一次內灣夜騎
- 4月 07 週一 200809:12
新玩具Trance 3
突然想玩自行車,所以星期日就跑去阿診自行車店看車。原本的目標是XTC SE2,在店裡被路人勸敗XTC HB3,對著SE2和HB3東看看、西看看的時候,看到老闆正在組新車,一問之下是Trance 1,再問價格是六萬多,直接拋棄不考慮。
繼續看老闆調教Trance 1時,一位老太爺騎著Anthem 1出現,此時目標開始轉移到雙避震車,看了看Anthem和Trance,比較喜歡Trance的外觀,可是對非預訂車款一無所知,看完Trance 1交車就先回家搜集情報了。
星期一早上剛好已經請假修牙,搞定牙齒之後離上工時間還有兩個多小時,自然就要把握時間再去車店逛逛。向老闆打聽中意的車款和售價,沒想到在這個大家都缺貨的時期,竟然有現貨。既然這麼巧,當然就拚下去啦!
一個半小時後,就開心地載著新玩具Trance 3趕去上工啦。
- 3月 20 週四 200809: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; } } - 3月 17 週一 200809:10
隱形眼鏡
戴了數年的眼鏡,鏡片鍍膜已經磨損、龜裂,所以下午就跑去換鏡片。等待的時候,順便問了一些隱形眼鏡的問題,本來想買日拋式,可是雙眼度數不同,要買就得買雙份,還在考慮的時候,老闆就說送我一副625度的季拋式試試看。所以,花了600元,不但換好鏡片,還得到隱形眼鏡、保養液、食鹽水。
- 2月 21 週四 200809: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:
- 2月 11 週一 200809: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"); } } - 2月 11 週一 200809: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好用多了。