Skip to content

Instantly share code, notes, and snippets.

@franzwong
franzwong / deployerConfigContext.xml
Last active July 26, 2017 18:11
CAS Setup steps
<?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:sec="http://www.springframework.org/schema/security"
xmlns:cas="http://unicon.net/schema/cas"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
@franzwong
franzwong / TextMatch.java
Last active August 29, 2015 14:04
Regular expression
public static void main(String[] args) {
String text = "<a href=\"http://www.google.com\">google</a>";
Pattern p = Pattern.compile("<a href=\"(.*?)\">");
Matcher m = p.matcher(text);
if (m.find()) { // use find(), don't use matches()
System.out.println(m.group(1));
}
}
@franzwong
franzwong / linux_command.md
Last active August 29, 2015 13:57
linux command
  • Connect through SSH
ssh -l <user name> -i <pem file> <server ip>
  • Copy file
scp -i   @:
@franzwong
franzwong / data.txt
Last active December 23, 2015 10:29
jinja2 sample code
{
"greeting": "おはようございます",
"name": "先生"
}
@franzwong
franzwong / django_cheatsheet.md
Created December 24, 2012 12:42
django cheatsheet
  • Create project
django-admin.py startproject mysite
  • Create application
python manage.py startapp polls
@franzwong
franzwong / nodejs_cheatsheet.md
Created October 28, 2012 03:25
node.js cheatsheet
  • read file (sync)
var fs = require('fs');
var data = fs.readFileSync('text.txt', 'utf8');
console.log(data);
  • read file (async)
@franzwong
franzwong / autoclick.py
Created October 14, 2012 04:15
Auto click button (Windows)
import sys
import ctypes
import time
EnumWindows = ctypes.windll.user32.EnumWindows
EnumChildWindows = ctypes.windll.user32.EnumChildWindows
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
IsWindowVisible = ctypes.windll.user32.IsWindowVisible
@franzwong
franzwong / web.xml
Created October 5, 2012 04:02
Sample web.xml
<?xml version="1.0"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<servlet>
<servlet-name>My Servlet</servlet-name>
@franzwong
franzwong / resize.py
Last active January 11, 2022 01:14
Resize image with Python
import traceback
from PIL import Image
def resize():
filePath = 'example.jpg'
ratio = 0.5
image = Image.open(filePath)
width = image.size[0]
@franzwong
franzwong / jsf.md
Created October 2, 2012 07:13
Jsf cheatsheet
  • usage of h:selectOneMenu
<h:selectOneMenu value="#{manageStudent.student.gender}">
    <f:selectItem itemLabel="- Select Gender -" itemValue=""/>
    <f:selectItems value="#{manageStudent.genders}"/>
</h:selectOneMenu>
  • get HttpServletRequest and HttpServletResponse in managed bean