Skip to content

Instantly share code, notes, and snippets.

View tvrcgo's full-sized avatar

tvrcgo

  • Guangzhou, CN
  • 13:57 (UTC +08:00)
View GitHub Profile
function FindProxyForURL(url, host) {
var PROXY = "PROXY 127.0.0.1:8080;SOCKS5 127.0.0.1:7070";
var DEFAULT = "DIRECT";
// domain .com/.net/.org
if (/(asahichinese|appspot|delicious|facebook|googleusercontent|googleapis|ggpht|html5rocks|hulu|twitter|twimg|staticflickr)\.com/i.test(host)) return PROXY;
if (/(4sqi|akamai|akamaihd|fbcdn)\.net/i.test(host)) return PROXY;
if (/(nobelprize|python|wikipedia|wikisource|wikimedia)\.org/i.test(host)) return PROXY;
@tvrcgo
tvrcgo / repo
Last active December 15, 2015 10:31
git repository initialization
#!/bin/bash
REPO_ROOT=/home/git/node
cd ${REPO_ROOT}
if [ -z "$1" ]; then
echo "------ fail: repository name required. ------"
exit 0
fi
@tvrcgo
tvrcgo / centosdeploy.sh
Last active August 29, 2015 14:14
centos deploy
#!/bin/sh
# node.js
cd ~
wget http://nodejs.org/dist/v0.10.36/node-v0.10.36-linux-x64.tar.gz
tar zxvf node-v0.10.36-linux-x64.tar.gz
cp ./node-v0.10.36-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/* /usr/sbin/
@tvrcgo
tvrcgo / post-receive
Last active December 15, 2015 10:35
git hook: refresh work trees on receiving git push.
#source ~/.bash_profile
export PATH=/usr/sbin:/usr/local/bin:$(npm bin):$PATH
# refresh dir.
git --git-dir=. --work-tree=$PWD/.. reset --hard
cd ..
# build.
echo '--- build start ---'
@tvrcgo
tvrcgo / mongosync.bat
Created February 5, 2015 16:27
mongo sync for win
@echo off
if "%1" == "" goto nohost
if "%2" == "" goto nodb
:sync
mongodump --host %1 --db %2
mongorestore --db %2 --drop dump/%2
:dropdump
@tvrcgo
tvrcgo / doskey.bat
Created March 28, 2015 14:24
windows commands alias
@ECHO OFF
doskey ls=dir /b $*
doskey ll=dir $*
doskey cat=type $*
doskey ..=cd..
doskey grep=find "$1" $2
doskey mv=ren $*
doskey rm=del $*
@tvrcgo
tvrcgo / tengine
Last active December 15, 2015 10:53
tengine manage.
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="tengine daemon"
NAME=nginx
DAEMON=/usr/local/tengine/sbin/nginx
CONFIGFILE=/usr/local/tengine/conf/nginx.conf
PIDFILE=/usr/local/tengine/logs/tengine.pid
SCRIPTNAME=/etc/init.d/tengine
@tvrcgo
tvrcgo / php-fpm
Created December 15, 2015 10:49
php-fpm manage.
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for php-fpm on Debian. Place in /etc/init.d and
# run 'update-rc.d -f php-fpm defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add php-fpm'
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $all
# Required-Stop: $all