Skip to content

Instantly share code, notes, and snippets.

@zii
zii / proxy.py
Last active April 28, 2016 02:09
A python script of http proxy
#coding: utf-8
import socket
import gevent
import time
from gevent.server import StreamServer
from gevent.socket import create_connection
class ForwardServer(StreamServer):
def __init__(self, listener, **kwargs):
@zii
zii / lzf test
Last active April 1, 2016 02:22
lzf压缩比(烂)
lzf: 205 / 218
n: 2
lzf: 205 / 218
lzf: 486 / 517
lzf: 486 / 517
lzf: 213 / 216
lzf: 213 / 216
lzf: 52 / 53
lzf: 88 / 92
lzf: 1372 / 1372
@zii
zii / 弟子规.txt
Last active September 16, 2018 08:01
弟子规
总 叙 信
弟子规 圣人训 首孝弟 次谨信 凡出言 信为先 诈与妄 奚可焉
泛爱众 而亲仁 有余力 则学文 话说多 不如少 惟其是 勿佞巧
奸巧语 秽污词 市井气 切戒之
入 则 孝 见未真 勿轻言 知未的 勿轻传
事非宜 勿轻诺 苟轻诺 进退错
父母呼 应勿缓 父母命 行勿懒 凡道字 重且舒 勿急疾 勿模糊
@zii
zii / bcast_receiver.py
Last active April 28, 2016 07:09
python broadcast
#coding: utf-8
# python broadcast receiver
import socket
recv_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
recv_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
recv_sock.bind(('', 9001))
while True:
data, addr = recv_sock.recvfrom(8192)
/redmine-2.4.1/config/environments/production.rb
添加一条
config.action_mailer.perform_deliveries = false
@zii
zii / webcrawler.py
Created July 22, 2016 06:15
celery webcrawler example
"""Recursive webcrawler example.
For asynchronous DNS lookups install the `dnspython` package:
$ pip install dnspython
Requires the `pybloom` module for the bloom filter which is used
to ensure a lower chance of recrawling a URL previously seen.
Since the bloom filter is not shared, but only passed as an argument
to each subtask, it would be much better to have this as a centralized
service. Redis sets could also be a practical solution.
A BloomFilter with a capacity of 100_000 members and an error rate
of 0.001 is 2.8MB pickled, but if compressed with zlib it only takes
@zii
zii / .bash_profile
Last active November 8, 2016 03:48
alias cdws="cd /e/dev/tbkt_web_student"
alias cdwt="cd /e/dev/tbkt_web_teacher"
alias cdt="cd /e/dev/tbkt_teacher"
alias cdapi="cd /e/dev/tbkt_api_student"
alias cdcms="cd /e/dev/tbkt_cms"
alias cdesms="cd /e/dev/xcp_esms"
alias cdm="cd /e/dev/tbkt_media"
alias cda="cd /e/dev/tbkt_sxqimo201605"
alias cdyy="cd /e/dev/tbkt_yystudent"
alias cdjxu="cd /e/dev/jiangxi/tbkt_user"
[常用快捷键]
ctrl-, 打开配置窗口
[theme]
github-atom-light-syntax
[package]
autocomplete-python # 自动完成+跳转定义
hyperclick # 支持ctrl-click跳转定义
script # 运行当前文件

disque调查报告

redis的作者搞了个分布式消息分发系统叫disque.

跟普通队列一样, 有入队(enqueue)和出队(dequeue)的操作, 另外还多一个确认操作(ACKJOB):

from pydisque.client import Client

c = Client(["192.168.0.200:7711"])
@zii
zii / mqcompre.md
Last active September 22, 2016 11:57

各家分布式队列系统的比较

redis

语言: c

虽然本身并非为队列设计, 但用于简单场景还是绰绰有余的. 用来做队列人也不少.

disque