This file contains hidden or 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
import os | |
import sys | |
try: | |
file | |
except NameError: | |
import io | |
file = io.FileIO | |
class RangeFile(file): |
This file contains hidden or 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
# by fcicq (fcicq at fcicq dot net) @ 2012.5.12, Released under GPLv2 | |
import hashlib | |
try: | |
from cStringIO import StringIO | |
except ImportError: | |
from io import BytesIO as StringIO | |
if bytes != str: ord = int | |
class ed2kHash(): | |
CHUNK_SIZE = 9728000 | |
BLOCK_SIZE = 262144 |
This file contains hidden or 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
--- cherokee/connection.c.orig 2011-10-13 02:07:44.000000000 +0800 | |
+++ cherokee/connection.c 2012-05-28 13:02:51.000000000 +0800 | |
@@ -2625,6 +2625,8 @@ | |
ret_t | |
cherokee_connection_open_request (cherokee_connection_t *conn) | |
{ | |
+ ret_t ret; | |
+ | |
TRACE (ENTRIES, "web_directory='%s' request='%s' local_directory='%s'\n", | |
conn->web_directory.buf, |
This file contains hidden or 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 -*- | |
# GPLv2, by fcicq | |
import urllib2, json, StringIO, gzip, base64 | |
def decodethunderuri(str): | |
if isinstance(str, unicode): str = str.encode('utf-8') | |
origstr = str | |
if str.startswith('thunder://'): | |
str = str[10:] | |
if len(str) % 4 != 0: str += '=' * (4- len(str) % 4) |
This file contains hidden or 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/python | |
# by fcicq, released @ 2011.5.12, MIT License. | |
# eventlet is required. | |
import eventlet | |
from eventlet.green import socket | |
### SETTINGS ### | |
SERVER_PORT = 1080 | |
IPV6_ENABLED = socket.has_ipv6 |
This file contains hidden or 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
import random | |
def random_bytes(size): | |
return "".join(chr(random.randrange(1, 256)) for i in xrange(size)) | |
def pkcs1_pad(text, size = 128): | |
l = size - len(text) - 3 | |
if l >= 8: # see RFC3447 7.2.1 | |
padding = random_bytes(l) | |
return '\x00\x02' + padding + '\x00' + text | |
else: |
This file contains hidden or 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/python | |
# -*- coding: utf-8 -*- | |
# | |
# Converts the specified JSON file with the specified encoding | |
# (default encoding is utf8 if not specified) into a formatted | |
# version with the specified indent (2 if not specified) and | |
# writes to STDOUT. | |
# | |
# Usage: jsoncat.py inputfile.json [input_encoding] [indent] | |
# |
This file contains hidden or 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
import random | |
# E = 129.875 | |
def dice(): | |
s = random.randint(1, 20) | |
if s <= 2: return random.randint(1, 20) | |
if s <= 8: return random.randint(21, 50) | |
if s <= 14: return random.randint(51, 99) | |
if s <= 17: return random.randint(100, 200) | |
if s <= 19: return random.randint(201, 500) | |
return random.randint(501, 1024) |
This file contains hidden or 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
Virtualization env friendly dstat, hiq + siq -> int, added steal by fcicq | |
Usage: | |
cd /usr/bin; sudo patch -p0 < /path/xxx.diff | |
--- /usr/bin/dstat 2010-06-11 14:08:01.000000000 +0800 | |
+++ /usr/bin/dstat.new 2012-08-12 21:06:56.000000000 +0800 | |
@@ -561,7 +561,7 @@ | |
class dstat_cpu(dstat): | |
def __init__(self): |
This file contains hidden or 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 | |
import base64, hashlib, hmac, json, sys, getpass | |
from Crypto.Cipher import AES | |
from Crypto.Hash import RIPEMD, SHA256 | |
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' | |
def prompt(p): | |
return getpass.getpass(p + ": ") |
OlderNewer