Skip to content

Instantly share code, notes, and snippets.

@monsterxx03
monsterxx03 / cprofile
Created March 19, 2014 09:22
cprofile
def profile(result_file_name):
def wrapper(fn):
def inner_wrapper(*args, **kwargs):
import cProfile, pstats
pr = cProfile.Profile()
pr.enable()
value = fn(*args, **kwargs)
@monsterxx03
monsterxx03 / gist:3081d45ded8ac7649427
Created July 1, 2014 03:22
get value from memcache based on keystone's token id
# need install dogpile.cache
from hashlib import sha1
token_id = "b7e3119430214967ae34695bab783b08"
key = sha1("token-" + token_id).hexdigest()
c = memcache.Client([“127.0.0.1:11211”])
value = c.get(memcache_key)
print value
#!/usr/bin/python
#coding=utf-8
#****************************************************
# Author: XYJ - xyj.asmy@gmail.com
# Last modified: 2012-07-02 09:44
# Filename: observer.py
# Description:
#****************************************************
#coding=utf-8
#!/usr/bin/python
import re
import json
from bs4 import BeautifulSoup
with open('t1.txt') as f:
doc = f.read()
soup = BeautifulSoup(doc)
scripts = soup.find_all('script')
l = ['11', '11', '11', '22', '22', '33']
from collections import Counter
c = Counter(l)
c.most_comon()
>> [('11', 3), ('22', 2), ('33', 1)]
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 8001))
s.listen(2)
while 1:
conn, addr = s.accept()
print 'connected by', addr
conn.sendall('response\n')
while 1:
import socket
from thread import start_new_thread
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 8001))
s.listen(2)
print 'listening'
def clientthread(conn):

Keybase proof

I hereby claim:

  • I am monsterxx03 on github.
  • I am monsterxx03 (https://keybase.io/monsterxx03) on keybase.
  • I have a public key ASCvzuVyvGtUBllQW-u5m7Tz47GYN9OZpBPnvFzDZWs5ygo

To claim this, I am signing this object:

@monsterxx03
monsterxx03 / test.py
Created December 29, 2018 07:10
nagle's algorithm test
import socket
import time
host = '127.0.0.1'
port = 80
TOTAL_TIME = 0
count = 10
@monsterxx03
monsterxx03 / celery_test.py
Last active February 11, 2019 04:09
test for celery memory leak
import resource
import gc
from celery import Celery
app = Celery()
app.conf.update(BROKER_URL='redis://localhost:6379/1')
@app.task
def dummy():