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
def http_head(url): | |
import httplib | |
import urlparse | |
redirects = 0 | |
while redirects < 10: | |
scheme, netloc, path, query, fragment = urlparse.urlsplit(url) | |
if scheme == 'https': |
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
#include <math.h> | |
#include <stdlib.h> | |
#define NV_MAGICCONST 1.7155277699214135 /* (4 * exp(-0.5) / sqrt(2.0)); */ | |
#define MAX_RANDOM 2147483647 /* (2 ** 31) - 1; */ | |
/* | |
* normalvariate ported from python's stdlib (random.normalvariate). | |
* released under the same licence as that (python license). | |
* |
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 asyncore | |
import asynchat | |
import socket | |
class Lobby(object): | |
def __init__(self): | |
self.clients = set() | |
def leave(self, client): | |
self.clients.remove(client) |
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 sys | |
import re | |
create_table_re = re.compile("db.create_table('([^']+)',") | |
field_name_re = re.compile("^(s*)('([^']+)', self.gf") | |
cur_model = None | |
input = open(sys.argv[1]) |
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
def get_random_name(): | |
""" | |
Return a random proper name in a somewhat efficient way. | |
""" | |
fp = open("/usr/share/dict/propernames") | |
fp.seek(0, 2) | |
size = fp.tell() | |
fp.seek(0) | |
fp.seek(int(random.random() * size * 0.95)) |
NewerOlder