Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""Simple HTTP Server With Upload.
https://github.com/tualatrix/tools/blob/master/SimpleHTTPServerWithUpload.py
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@cgsvv
cgsvv / coin.py
Last active March 21, 2019 05:13
#!/usr/bin/python
# coding: utf-8
import sys, time, random
emojis = ['🌝', '🌖', '🌗', '🌘', '🌚', '🌒', '🌓', '🌔']
def write(text):
sys.stdout.write('\r' + text)
sys.stdout.flush()
import subprocess, os, sys
def find_pid_byname(name):
out = subprocess.check_output("ps aux | grep %s | grep -v grep | grep -v %s" % (name, __file__), shell=True)
print out
lines = out.strip().split("\n")
if len(lines) == 1:
return int(lines[0].split()[1])
else:
raise Exception(str(len(lines)) + " process found")
@cgsvv
cgsvv / dumpmem.py
Last active December 12, 2018 05:29
def check_memory_status():
import gc, time, guppy, sys, os
homedir = os.path.expanduser("~")
#output = sys.stdout
output = open(homedir + "/dump" + time.strftime("%m%d%H%M%S"), "wb")
hp = guppy.hpy()
gc.collect()
print >>output, "garbage size", len(gc.garbage)