Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / gspider.py
Created June 5, 2017 06:01 — forked from wolf0403/gspider.py
Gevent Spider
import gevent
import logging
import requests
try:
import simplejson as json
except:
import json
from gevent.pool import Group, Pool
@tiancheng91
tiancheng91 / redis_asyncio.py
Created July 5, 2017 03:21 — forked from yihuang/redis_asyncio.py
benchmark gevent vs asyncio on python3.4
import asyncio
import hiredis
d = {}
def process(req):
cmd = req[0].lower()
if cmd==b'set':
d[req[1]] = req[2]
return b"+OK\r\n"
@tiancheng91
tiancheng91 / start-celery-for-dev.py
Created July 15, 2017 09:52 — forked from chenjianjx/start-celery-for-dev.py
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os
@tiancheng91
tiancheng91 / base62.py
Created August 18, 2017 02:04 — forked from adyliu/base62.py
Base62 encode/decode tools (convert number to string)
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Base62 tools (convert number <=> string)
# v1.0/20130109
# python 2.x/3.x supported
#
#author: Ady Liu([email protected])
#github: github.com/adyliu
import sys
@tiancheng91
tiancheng91 / chromium
Created April 16, 2018 13:20 — forked from fujimakishouten/chromium
Chromium
#!/bin/sh
export GOOGLE_API_KEY="AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k"
export GOOGLE_DEFAULT_CLIENT_ID="811574891467.apps.googleusercontent.com"
export GOOGLE_DEFAULT_CLIENT_SECRET="kdloedMFGdGla2P1zacGjAQh"
/usr/bin/chromium
@tiancheng91
tiancheng91 / sysctl.conf
Created May 29, 2018 18:16 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@tiancheng91
tiancheng91 / nginx-tuning.md
Created June 8, 2018 18:04 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@tiancheng91
tiancheng91 / 1.google-analytics-proxy-nginx.conf
Created January 7, 2019 18:47 — forked from paivaric/1.google-analytics-proxy-nginx.conf
Google Analytics Proxy using Nginx to bypass Adblock and other blockers
server {
listen 80;
server_name your.domain.com;
location = /analytics.js {
# you have to compile nginx with http://nginx.org/en/docs/http/ngx_http_sub_module.html (this is not default)
# and http://nginx.org/en/docs/http/ngx_http_proxy_module.html (it's a default module)
proxy_set_header Accept-Encoding "";
@tiancheng91
tiancheng91 / chai.json
Created January 23, 2019 02:27 — forked from ksco/chai.json
中文左右拆字字库
{"卧":"臣卜","项":"工页","功":"工力","攻":"工攵","荆":"茾刂","邪":"牙阝","雅":"牙隹","期":"其月","欺":"其欠","斯":"其斤","鞭":"革便","勒":"革力","划":"戈刂","敬":"苟攵","鹳":"雚鸟","欧":"区欠","切":"七刀","鞋":"革圭","鄞":"堇阝","勤":"堇力","陌":"阝百","陈":"阝东","隐":"阝急","降":"阝夅","队":"阝人","防":"阝方","院":"阝完","阳":"阝日","际":"阝示","阴":"阝月","除":"阝余","险":"阝佥","隔":"阝鬲","障":"阝章","阶":"阝介","陀":"阝它","阵":"阝车","阿":"阝可","隘":"阝益","陵":"阝夌","陷":"阝臽","陶":"阝匋","陪":"阝咅","陕":"阝夹","陆":"阝击","阻":"阝且","孙":"子小","孔":"子乚","孩":"子亥","孤":"子瓜","职":"耳只","聩":"耳贵","聘":"耳甹","取":"耳又","聊":"耳卯","聪":"耳总","耻":"耳止","联":"耳关","聆":"耳令","耿":"耳火","耽":"耳冘","预":"予页","豫":"予象","双":"又又","对":"又寸","戏":"又戈","欢":"又欠","观":"又见","难":"又隹","鸡":"又鸟","艰":"又艮","驻":"马主","骚":"马蚤","驯":"马川","骆":"马各","骑":"马奇","驱":"马区","驰":"马也","骇":"马亥","驶":"马史","验":"马佥","骏":"马夋","骄":"马乔","驴":"马户","骤":"马聚","驳":"马爻","胡":"古月","故":"古攵","鸪":"古鸟","郁":"有阝","耐":"而寸","肆":"镸聿","雄":"厷隹","励":"厉力","耗":"耒毛","艳":"丰色","耕":"耒井","确":"石角","破":"石皮","础":"石出","碑":"石卑","研":"石开","碎":"石卒","碾":"石展","硕":"石页","磁":"石兹","碟":"石枼","砸":"石匝","碌":"石录","砖":"石专","碗":"石宛","砰":"石平","磕":"石盍","硬":"石
@tiancheng91
tiancheng91 / add_wsl_exclusions.ps1
Created May 5, 2019 03:04 — forked from ian-p-cooke/add_wsl_exclusions.ps1
powershell script to add WSL exclusions
$win_user = "ipc"
$linux_user = "ipc"
$package = "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"
$base_path = "C:\Users\" + $win_user + "\AppData\Local\Packages\" + $package + "\LocalState\rootfs"
$dirs = @("\bin", "\sbin", "\usr\bin", "\usr\sbin", "\home\" + $linux_user + "\.cargo\bin")
$dirs | ForEach { Add-MpPreference -ExclusionProcess ($base_path + $_ + "\*") }
Add-MpPreference -ExclusionPath $base_path