Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
HungYuHei / gist:1225875
Created September 19, 2011 02:24
openvpn config
sudo apt-get install openvpn
cp /usr/share/doc/openvpn/examples/easy-rsa/2.0 ~/ -r
source ./vars
./clean-all
./build-ca
./build-key-server
./build-key
./build-dh
sudo cp server.conf /etc/openvpn/
@HungYuHei
HungYuHei / setup.sql
Created September 20, 2011 04:35 — forked from iwinux/setup.sql
Set up a database in MySQL
CREATE DATABASE `databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'mypass';
GRANT ALL ON databasename.* TO 'user'@'localhost';
@HungYuHei
HungYuHei / gist:1235143
Created September 22, 2011 15:56
openvpn-ip
# max-routes 600
route 1.51.0.0 255.255.0.0 net_gateway
route 1.184.0.0 255.254.0.0 net_gateway
route 27.148.0.0 255.252.0.0 net_gateway
route 49.52.0.0 255.252.0.0 net_gateway
route 49.120.0.0 255.252.0.0 net_gateway
route 49.140.0.0 255.254.0.0 net_gateway
route 49.208.0.0 255.254.0.0 net_gateway
route 58.17.0.0 255.255.0.0 net_gateway
route 58.18.0.0 255.254.0.0 net_gateway
@HungYuHei
HungYuHei / Display git branch in bash prompt with color
Created October 6, 2011 17:03
Display git branch in bash prompt with color
D=$'\e[37;40m'
PINK=$'\e[35;40m'
GREEN=$'\e[32;40m'
ORANGE=$'\e[33;40m'
WHITE=$'\e[33;0m'
YELLOW=$'\e[33;33m'
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
@HungYuHei
HungYuHei / 元素水平居中
Created October 9, 2011 03:05
元素水平居中
var element = $("#element");
var screenWidth = $(window).width();
var elementLeft = (screenWidth - element.outerWidth())/2 ;
element.css('left', elementLeft + 'px');
@HungYuHei
HungYuHei / gist:1277350
Created October 11, 2011 05:24
set-java-environment
JAVA_HOME="/usr/local/jdk1.7.0"
CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH=".:$PATH:$JAVA_HOME/bin"
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CLASS_PATH PATH CATALINA_HOME
@HungYuHei
HungYuHei / gist:1280335
Created October 12, 2011 05:00 — forked from lxneng/gist:1003770
git dropbox
~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git
~/Dropbox/git $ mkdir project.git
~/Dropbox/git $ cd project.git
~/Dropbox/git $ git init --bare
~/Dropbox/git $ cd ~/project
@HungYuHei
HungYuHei / gist:1294536
Created October 18, 2011 03:21
ruby1.9.2 中文 正则
"中文嚟嘎".match(/\p{han}+/u)
/@([\w\p{han}]{2,12})/ # 长度为@2-12的中英字符
@HungYuHei
HungYuHei / gist:1298689
Created October 19, 2011 15:45
rails csrf
skip_before_filter :verify_authenticity_token
<%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) %>
@HungYuHei
HungYuHei / gist:1311142
Created October 25, 2011 02:33
mongodb dump restore
mongodump -h dbhost -d dbname -o output_directory
mongorestore -h dbhost -d dbname --directoryperdb form_directory