Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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__)
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 / 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
@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 / 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 / time_strftime.py
Last active February 16, 2017 07:31
time and strftime
import time
tstr = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
print tstr
@zhangchunlin
zhangchunlin / nginx.conf
Created May 9, 2017 23:42
nginx.conf , openresty, redirect, ip
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 6699;
location / {