This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import sys | |
import re | |
def lex(characters, token_exprs): | |
pos = 0 | |
tokens = [] | |
while pos < len(characters): | |
match = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
class RC4: | |
def __init__(self,public_key = None): | |
if not public_key: | |
public_key = 'none_public_key' | |
self.public_key = public_key | |
self.index_i = 0; | |
self.index_j = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import argparse | |
from gevent import monkey | |
monkey.patch_socket() | |
import logging | |
logging.basicConfig(level=logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
u""" | |
线性数据结构, 栈, 队列, deques, 容器结构, 数据项之间存在相对的位置 | |
""" | |
class Stack(object): | |
u""" | |
栈 先进后出 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function | |
import re | |
import sys | |
filter = re.compile(r'site-packages/requests/.*') | |
def tracer(frame, event, args): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from tornado import gen | |
from tornado import httpclient | |
from tornado import httputil | |
from tornado import ioloop | |
from tornado import websocket | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -w %{time_connect}:%{time_starttransfer}:%{time_total} -X POST 'http://service-uri' -H 'Content-Type: application/json' --data 'post-data' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"reflect" | |
"unsafe" | |
) | |
func BytesToString(b []byte) string { | |
return *(*string)(unsafe.Pointer(&b)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *server) respond(w http.ResponseWriter, r *http.Request, data interface{}, status int) { | |
w.WriteHeader(status) | |
if data != nil { | |
err := json.NewEncoder(w).Encode(data) | |
s.logf("json encode %s", err) | |
} | |
} | |
func (s *server) decode(w http.ResponseWriter, r *http.Request, v interface{}) error { | |
return json.NewDecoder(r.Body).Decode(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
""" | |
一个基于thread和queue的线程池,以任务为队列元素,动态创建线程,重复利用线程, | |
通过close和terminate方法关闭线程池。 | |
""" | |
import queue | |
import threading | |
import contextlib |