Skip to content

Instantly share code, notes, and snippets.

View ulinkwo's full-sized avatar
:fishsticks:
Out sick

Kyle Liu ulinkwo

:fishsticks:
Out sick
View GitHub Profile
@ulinkwo
ulinkwo / install-rbenv
Created November 20, 2013 07:58
Install rbenv
#!/bin/sh
# Check out rbenv into ~/.rbenv.
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
# Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
# Add rbenv init to your shell to enable shims and autocompletion.
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
@ulinkwo
ulinkwo / ObjectSize.java
Last active December 19, 2015 09:39
Fetch Object Size
/**
*
* java -javaagent:agent.jar ObjectSize
*
**/
public class ObjectSize {
private static final int a = 1;
private long[] b = new long[0];
@ulinkwo
ulinkwo / server.js
Created May 23, 2013 13:24
A Simple HTTP Server in Node.js
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs");
// 创建一个HTTP服务器,以函数为回调参数用于响应当服务器收到请求时如何应答
// req 代表客户端请求,包含了一些客户端信息,如请求地址,请求参数等等
// res 代表客户端的响应,通过调用相应方法发送消息给客户端,如write等
http.createServer(function (req, res) {
// root作为web服务器的服务目录,html页面,图片等放在这里
@ulinkwo
ulinkwo / pom.xml
Last active December 15, 2015 04:38 — forked from Riduidel/pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
@ulinkwo
ulinkwo / nginx
Created June 4, 2012 07:18
Nginx Server init script in ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu or other *nix.
# Description: nginx init.d dash script for Ubuntu or other *nix.
### END INIT INFO
@ulinkwo
ulinkwo / subversion
Created June 4, 2012 07:13
Subversion Init Script in Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: svnserve
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start svnserve
### END INIT INFO
@ulinkwo
ulinkwo / XSSRequestWrapper.java
Created April 9, 2012 09:42
Stronger Anti Cross-Site Scripting (XSS) Filter for Java Web Apps
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
public class XSSRequestWrapper extends HttpServletRequestWrapper {
public XSSRequestWrapper(HttpServletRequest servletRequest) {
super(servletRequest);
}
@ulinkwo
ulinkwo / XSSFilter.java
Created April 9, 2012 09:41
Stronger Anti Cross-Site Scripting (XSS) Filter for Java Web Apps
public class XSSFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void destroy() {
}
@ulinkwo
ulinkwo / pom-desc
Created March 21, 2012 02:20
Maven POM Description
<project xmlns="http://maven.apache.org/POM/4.0.0 "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<!--父项目的坐标。如果项目中没有规定某个元素的值,那么父项目中的对应值即为项目的默认值。 坐标包括group ID,artifact ID和 version。-->
<parent>
<!--被继承的父项目的构件标识符-->
<artifactId/>
<!--被继承的父项目的全球唯一标识符-->
<groupId/>
<!--被继承的父项目的版本-->
@ulinkwo
ulinkwo / assembly-cfg
Created January 3, 2012 02:40
Maven assembly file
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bundle</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
<format>rar</format>
</formats>
<fileSets>
<fileSet>