Skip to content

Instantly share code, notes, and snippets.

View int64ago's full-sized avatar
🎯
Focusing

Cody Chan int64ago

🎯
Focusing
View GitHub Profile
@int64ago
int64ago / myservice.sh
Last active August 29, 2015 14:11
sysvinit service example for python script
#!/bin/bash
#
# myservice Start up myservice
#
# chkconfig: 2345 55 25
# description: This's the description
#
# processname: myservice
# Source function library
@int64ago
int64ago / lookfor.sh
Last active August 29, 2015 14:11
Find the substring from all files of current directory recursively
#!/bin/bash
path='.'
keyword=$1
function deep(){
for file in `ls $1` ; do
if test -d $1"/"$file ; then
deep $1"/"$file
else
cat $1"/"$file | grep $keyword > /dev/null
@int64ago
int64ago / centos_rsync.sh
Last active August 29, 2015 14:11
Centos rsync script
#!/bin/bash
#wget works, too
#wget -r -p -k -np -c -nH --cut-dirs=1 -e robots=off -t5 -R iso,gif,css,js,ico,png,html,1 -P /srv/http/centos/ http://mirrors.aliyun.com/centos/6.5/
RsyncBin="/usr/bin/rsync"
RsyncPerm='-avrt --delete --exclude=isos/ --exclude=i386/'
Version=6.5 #depends
Target='/srv/http/centos/$Version/' #depends
Repo='rsync://mirrors.kernel.org/centos/$Version/'
LogFile='/srv/http/centos/log' #depends
Date=`date +%Y-%m-%d`
----- BEGIN LICENSE -----
Andrew Weber
Single User License
EA7E-855605
813A03DD 5E4AD9E6 6C0EEB94 BC99798F
942194A6 02396E98 E62C9979 4BB979FE
91424C9D A45400BF F6747D88 2FB88078
90F5CC94 1CDC92DC 8457107A F151657B
1D22E383 A997F016 42397640 33F41CFC
E1D0AE85 A0BBD039 0E9C8D55 E1B89D5D
@int64ago
int64ago / dnsmasqupdate.sh
Created December 21, 2014 16:41
dnsmasq update for China
#!/bin/sh
cnlist() {
wget -4 --no-check-certificate -O /etc/dnsmasq.d/accelerated-domains.china.conf https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf
wget -4 --no-check-certificate -O /etc/dnsmasq.d/bogus-nxdomain.china.conf https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf
}
adblock() {
wget -4 --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt |
grep ^\|\|[^\*]*\^$ |
sed -e 's:||:address\=\/:' -e 's:\^:/127\.0\.0\.1:' | uniq > /etc/dnsm
@int64ago
int64ago / GetCDNJS.py
Created January 12, 2015 06:14
Get data from cdnjs.com and save to json
#!/usr/bin/python2
import urllib, json
from BeautifulSoup import BeautifulSoup
data = {}
# inconformity
blacklist = ['mathjax', 'yui', 'documentup']
res = urllib.urlopen('https://cdnjs.com/').read()
soup = BeautifulSoup(res)
libs = soup.findAll('tr', attrs={'data-library-name': True})
@int64ago
int64ago / del_all_zbyte_files.py
Created January 16, 2015 04:04
Delete all zerobyte files for Qiniu
# -*- coding: utf-8 -*-
# Dependents:
# qiniu-sdk(https://github.com/qiniu/python-sdk/releases)
# requests(http://docs.python-requests.org/en/latest/user/install/)
from qiniu import Auth
from qiniu import BucketManager
access_key = '...'
secret_key = '...'
bucket_name = '...'
@int64ago
int64ago / ubuntu1404-shadowsocks.sh
Created January 29, 2015 12:31
shadowsocks server auto deploying script for ubuntu14.04
#!/bin/bash
if [ X$1 = X ]
then
echo 'No passwd input!'
exit
fi
apt-get update
apt-get -y install python-pip python-m2crypto supervisor
pip install shadowsocks
@int64ago
int64ago / topy
Created April 7, 2015 02:33
Monitor script for Gateway
alias topy='tmux attach -t topy || tmux new-session -s topy -d "htop" \; rename-window htop \; split-window -v -p 50 "nload -u K" \; attach -t topy'
@int64ago
int64ago / source.list
Created April 7, 2015 02:40
source.list for ubuntu14.04
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse