DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator

Build a Shadowsocks server – an easier alternative to VPN

Build a Shadowsocks server – an easier alternative to VPN
WARNING: An extra port 998 is also opened for shadowsocks service. I am being lazy so that I do not have handle exceptions when writing add/remove port scripts. Edit config.json and remove the port if you are worried. Last time I wrote a tutorial on how to build an PPTP server. Now a new way […]Read More

install/upgrade to the latest version of nodejs

install/upgrade to the latest version of nodejs
This code works on Debian, centos, ubuntu. #!/bin/bash #get latest node version number VERSION=$(curl http://nodejs.org/download/ | grep 'Current version:' | grep -o "v[0-9]\+.[0-9]\+.[0-9]\+") #check if linux is 64 or 32 bit if [ $(uname -m | grep '64' | wc -l) == 1 ]; then FILENAME="node-${VERSION}-linux-x64.tar.gz" else FILENAME="node-${VERSION}-linux-x86.tar.gz" fi wget "http://nodejs.org/dist/${VERSION}/${FILENAME}" tar -zxf "${FILENAME}" -C […]Read More

use sed to extract a substring using regular expressions

use sed to extract a substring using regular expressions
echo 'nice12343game' | sed -n 's/nice\(.*\)game/\1/p' OUTPUT: 12343 Notice the parenthesis signs need to be escaped inside the sed expression.Read More

node quick install

node quick install
64 bit linux wget http://nodejs.org/dist/v0.10.0/node-v0.10.0-linux-x64.tar.gz tar -zxf node-v0.10.0-linux-x64.tar.gz -C /usr/local/ --strip-components=1 doneRead More

php: user filter_var() and regular expressions to validate strings

php: user filter_var() and regular expressions to validate strings
$reference_code=filter_var($_REQUEST['reference_code'], FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/\w*/"))); $username=filter_var($_REQUEST['username'],FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/\w*/")));Read More