Skip to content

Instantly share code, notes, and snippets.

title description date categories slug
QQ协议分析
QQ协议分析
2014-04-16
protocol
qq-protocol

一. 文字聊天协议族(TCPF, Text Chatting Protocol Family)

@gf0842wf
gf0842wf / Selenium PhantomJS Python Header.py
Created November 6, 2016 11:57 — forked from ozen/Selenium PhantomJS Python Header.py
How to set request headers when using Selenium Python with PhantomJS driver
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \
'AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/39.0.2171.95 Safari/537.36'
driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
@gf0842wf
gf0842wf / pipeline.py
Last active August 29, 2015 14:14
pipeline pattern by python generator
# -*- coding: utf-8 -*-
import os, sys
def default_next(func):
def wrapper(*args, **kwargs):
f = func(*args, **kwargs)
f.next()
return f
return wrapper
// For node-mongodb-native (npm install mongodb)
var mongodb = require('mongodb');
var MongoTransaction = function(db) {
this.db = db;
this.queue = [];
this.running = false;
this.failureFn = function(){};
}
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'fk':
@gf0842wf
gf0842wf / thttptcp.py
Created March 19, 2014 06:10
tornado同时提供http和tcp服务
# -*- coding:utf-8 -*-
import tornado.ioloop
import tornado.web
from tornado.ioloop import IOLoop
from functools import partial
import socket, Queue
fd_map = {} # 可以使用weakref.WeakValueDictionary
message_queue_map = {} # 可以使用weakref.WeakValueDictionary