Archive for May, 2010

Batch script for converting files using FFMpeg

for /f %%f in (‘dir /b input’) do ffmpeg -i “./input/%%f” -vcodec libx264 -vpre “./ffpresets/libx264-max.ffpreset” “./output/%%f.mp4”
pause

No Comments

fiona, happy birthday

老婆啊, 生日快樂…
過左開開心心的一日, so good~
年年生日都同我過好無啊~

hehe… 你又老左一歲lu~
同我一齊開唔開心呢~ 好快三年半喇….
三年又三年, 十年都黎緊頭喇老婆~

1 Comment

Spring 3 on App Engine

Before writing this note, I referenced the site http://www.ardentlord.com/apps/blog/show/829881-spring-3-0-on-google-app-engine and would like to supplement some steps here.

1. Setup a Google App Engine project

2. Copy following .jar files, and add it in eclipse build path

org.springframework.asm-3.0.2.RELEASE.jar
org.springframework.beans-3.0.2.RELEASE.jar
org.springframework.context-3.0.2.RELEASE.jar
org.springframework.core-3.0.2.RELEASE.jar
org.springframework.expression-3.0.2.RELEASE.jar
org.springframework.web-3.0.2.RELEASE.jar
org.springframework.web.servlet-3.0.2.RELEASE.jar

3. Spring also depends on the following jars, which you can search for around the internet, or download from my Spring Example git repository:
antlr-3.0.1.jar
asm-2.1.jar
asm-commons-2.1.jar
commons-logging-1.1.1.jar

5. Finally, you’ll need to rename the commons-logging-1.1.1 jar to something else.

6. Since using RESTFul style URL, we would like to map /app/* to dispatcher servlet, (but not /* because we don’t want to redirect views (.jsp) also back to dispatcher).  Add the following in web.xml under /WEB-INF/ folder


<servlet>
<servlet-name><span style="color: #ff6600;">dispatcher</span></servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>

</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>

7. dispatcher-servlet.xml  <- the “dispatcher” should be the same as the

servlet-name defined in web.xml

Following is the sample of the file


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<context:component-scan base-package="com.allenkan.appengine.blog.controllers" />

<bean id="viewResolver" p:prefix="/WEB-INF/views/" p:suffix=".jsp" />

</beans>

8. Now we’re all done with setup! Just create a controller and a view. I made a simple hello.jsp view that outputs the request parameter “name”. Here’s the controller:

<pre>package example.controllers.hello;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloController {

@RequestMapping("/hello/{name}")
public String hello(@PathVariable String name, Model model) {
model.addAttribute("name", name);
return "hello/hello";
}
}
</pre>

9. Last but not least, the jsp file have to enable EL (Expression Language) by

defining isELIgnored=”false” in the page header.


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"  isELIgnored="false"  %>

No Comments