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 / pkrank.py
Created June 10, 2015 06:08
Huawei PK rank statistics
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import os, sys, tarfile, tempfile, re
try:
tar = tarfile.open(sys.argv[1], 'r:gz')
tar.extractall(tempfile.gettempdir())
dirname = os.path.join(tempfile.gettempdir(),
os.path.basename(sys.argv[1])[:-len('.tar.gz')])
@int64ago
int64ago / npmsettings.sh
Last active January 14, 2016 11:52
npm settings
#!/bin/bash
mkdir $HOME/.npm-global
npm config set prefix $HOME/.npm-global
echo 'PATH=$PATH:/home/int64ago/.npm-global/bin' >> ~/.bashrc
source ~/.bashrc
npm config set registry https://registry.npm.taobao.org
npm config set disturl https://npm.taobao.org/dist
@int64ago
int64ago / extract.py
Created May 31, 2015 05:26
Extract Money & Jetton info from replay.txt
#!/usr/bin/python
import sys, re, StringIO, json
data = {'data': []}
def findPlayer(_id):
for player in data['data']:
if player['name'] == _id:
return player
@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
@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 / 直辖市+地级市
Last active January 14, 2016 02:23
直辖市+地级市
石家庄市
唐山市
秦皇岛市
邯郸市
邢台市
保定市
张家口市
承德市
沧州市
廊坊市
@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 / 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 / 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 / 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