Skip to content

Instantly share code, notes, and snippets.

@zhangchunlin
zhangchunlin / README.md
Created August 25, 2016 00:59 — forked from ficapy/README.md
代理设置

现在比较主流的方案可能就是SSR+kcptun了,基本上都能流畅看1080P的youtube了。下面讲述如何快速搭建服务端和客户端(主要针对osx和unix,win上有成熟的GUI方案)

服务端

SSR一键安装包(引用自https://www.91yun.org/archives/2079)

wget -N --no-check-certificate https://raw.githubusercontent.com/91yun/shadowsocks_install/master/shadowsocksR.sh && bash shadowsocksR.sh

https://github.com/xtaci/kcptun/releases下载适合自己系统的最新版本tar -xf解压得到server_linux_amd64.执行服务端.摘录文档如下

@zhangchunlin
zhangchunlin / drun
Created August 18, 2016 05:04
drun
#! /usr/bin/env python
#coding=utf-8
def main():
from optparse import OptionParser
import os
import logging
import sys
import time
@zhangchunlin
zhangchunlin / tcping.py
Created June 20, 2016 10:08 — forked from defnull/tcping.py
TCPing
def ping(server, port):
''' Check if a server accepts connections on a specific TCP port '''
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((server, port))
s.close()
return True
except socket.error:
return False
def test19():
src_fpath = "gbk.txt"
dst_fpath = "utf8.txt"
dstf = open(dst_fpath,"w")
for line in open(src_fpath):
try:
dstf.write(line.decode("gbk").encode("utf8"))
except Exception as e:
print "error when handle '%s': '%s'"%(repr(line),e)
@zhangchunlin
zhangchunlin / logger_example.py
Last active February 18, 2020 00:49
python snippet
import logging
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger(__name__)
@zhangchunlin
zhangchunlin / snippet.txt
Created December 4, 2015 02:25
postgresql hot standby replication
[1]
listen_addresses = 'localhost,IP_address_of_THIS_host'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
[2]
host replication rep 10.125.159.101/32 md5
@zhangchunlin
zhangchunlin / models.py
Last active December 4, 2015 02:44
linci.artifact models
#! /usr/bin/env python
#coding=utf-8
from uliweb.orm import *
import logging
log = logging.getLogger('linci.artifact')
class LinciArtifact(Model):
#artifact id = "%s-%s"%(asite,aindex)
@zhangchunlin
zhangchunlin / views.py
Created July 31, 2015 13:14
uliweb gevent long polling test
#coding=utf-8
from uliweb import expose, functions
import gevent
from gevent.queue import Queue, Empty
import json as json_
data_source = Queue()
@zhangchunlin
zhangchunlin / scancopyright.md
Last active August 29, 2015 14:08
Scancopyright install&usage

Scancopyright is a tool which can be used to scan copyright info of source code,you can use it to identity source code as GPL/other license or propriertary. I wrote it for the open source of our android source code. You can submit issue for improvement or questions.

Install

Scancopyright can be run cross platform(linux/windows...) in theory,but only linux installration is tested.

Install dependent modules

Scancopyright depend on python(2.6+)/uliweb/plugs/sqlalchemy,you should install them firstly. Example steps in ubuntu:

@zhangchunlin
zhangchunlin / decorator_demo.py
Created August 25, 2014 06:25
python decorator demo
#! /usr/bin/env python
#coding=utf-8
#from http://www.cnblogs.com/rhcad/archive/2011/12/21/2295507.html
#第一步:最简单的函数,准备附加额外功能
def test1():
'''示例1: 最简单的函数,表示调用了两次'''
def myfunc():