Skip to content

Instantly share code, notes, and snippets.

@franzwong
franzwong / DocumentDAO.java
Created September 28, 2012 14:20
Sample for persisting CLOB with pure JDBC
package example.clob001;
import java.math.BigDecimal;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@franzwong
franzwong / mainScript.sql
Created September 29, 2012 03:50
Sample for persisting CLOB with PL/SQL
DECLARE
documentId DOCUMENT.ID%TYPE;
documentName DOCUMENT.NAME%TYPE := 'python cheatsheet';
documentFileName VARCHAR2(1024 CHAR) := 'python.html';
documentFile BFILE;
documentClob CLOB;
sourceOffset INTEGER := 1;
destinationOffset INTEGER := 1;
@franzwong
franzwong / python_cheatsheet.md
Last active August 19, 2021 10:31
Python cheatsheet

Python cheatsheet

  • for loop
for i in xrange(10):
  print i
@franzwong
franzwong / getpassExample.py
Created September 30, 2012 14:53
no password is shown when typing in console
import getpass
password = getpass.getpass('enter password: ')
@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
@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 / 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 / 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 / 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 / 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