Skip to content

Instantly share code, notes, and snippets.

View ulinkwo's full-sized avatar
🤒
Out sick

Kyle Liu ulinkwo

🤒
Out sick
View GitHub Profile
@ulinkwo
ulinkwo / subversion-daemon-script
Created March 11, 2009 12:04
The Subversion as Daemon Script
#!/bin/sh
#
# start/stop subversion daemon.
test -f /usr/bin/svnserve || exit 0
OPTIONS=”-d -r /svnroot”
case “$1″ in
start)
@ulinkwo
ulinkwo / usefull-validation.js
Created March 31, 2009 09:42
Some Usefull Validations
//validate string length
function ValidLen(s,min,max){
if (s.length < min || s.length > max) { return false; }
return true;
}
// validate email
function ValidEmail(s){
var check = /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/;
if (!check.test(s)) { return false; }
#/bin/sh
# Here is how to tell sudo not to ask for password...
visudo
# Or if you are an expert, then directly edit the file /etc/sudoers
vi /etc/sudoers
# Add this line to the end of the file (this should be the LAST line!!!)...
private void createImage(OutputStream out) {
int width = 100;
int height = 100;
BufferedImage buffer = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
Graphics2D g = buffer.createGraphics();
// set background:
g.setBackground(Color.BLUE);
g.clearRect(0, 0, width, height);
// set fore color:
//搭配 scale operator
Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
//利用 ParameterBlock 物件儲存必要的 input Source 與 參數
ParameterBlock params = new ParameterBlock();
params.addSource(ri);//为RenderedImage对象或图像文件
params.add(scale); // x scale factor
params.add(scale); // y scale factor
params.add(0.0F); // x translate
params.add(0.0F); // y translate
params.add(interp); // interpolation method
<security-constraint>
<web-resource-collection>
<web-resource-name>Forbidden</web-resource-name>
<url-pattern>/pages/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
public static String getLocalMAC() {
InetAddress address;
String sMAC = null;
try {
address = InetAddress.getLocalHost();
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();
Formatter formatter = new Formatter();
for (int i = 0; i < mac.length; i++) {
sMAC = formatter.format(Locale.getDefault(), "%02X%s", mac[i],
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>documentElement</title>
<style type="text/css">
body{margin:0;padding:0;font:12px/150% arial;}
</style>
<script type="text/javascript">
function a(){
@ulinkwo
ulinkwo / log4j.properties
Created November 10, 2010 09:17
Log different level to different appender in log4j
### file appender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=100KB
log4j.appender.file.maxBackupIndex=5
log4j.appender.file.File=test.log
#NOTE:
log4j.appender.file.threshold=info
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
@ulinkwo
ulinkwo / log4j.xml
Created November 10, 2010 09:19
debugging messages to one file and other messages to another file. This can only be done with XML because we need a LevelRange filter.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
<appender name="file"
class="org.apache.log4j.RollingFileAppender">
<param name="maxFileSize" value="100KB" />
<param name="maxBackupIndex" value="5" />
<param name="File" value="test.log" />
<param name="threshold" value="info" />
<layout class="org.apache.log4j.PatternLayout">