Skip to content

Instantly share code, notes, and snippets.

View theelous3's full-sized avatar

M.J. theelous3

  • Dublin, Ireland
View GitHub Profile
def range(*args):
def inner(start=0, stop=..., step=1):
if stop is ...:
stop = float('inf')
while start < stop:
yield start
start += step
if len(args) == 1:
return inner(stop=args[0])
else:
{
"Alabama": ["Autauga County", "Baldwin County", "Barbour County", "Bibb County", "Blount County", "Bullock County", "Butler County", "Calhoun County", "Chambers County", "Cherokee County", "Chilton County", "Choctaw County", "Clarke County", "Clay County", "Cleburne County", "Coffee County", "Colbert County", "Conecuh County", "Coosa County", "Covington County", "Crenshaw County", "Cullman County", "Dale County", "Dallas County", "DeKalb County", "Elmore County", "Escambia County", "Etowah County", "Fayette County", "Franklin County", "Geneva County", "Greene County", "Hale County", "Henry County", "Houston County", "Jackson County", "Jefferson County", "Lamar County", "Lauderdale County", "Lawrence County", "Lee County", "Limestone County", "Lowndes County", "Macon County", "Madison County", "Marengo County", "Marion County", "Marshall County", "Mobile County", "Monroe County", "Montgomery County", "Morgan County", "Perry County", "Pickens County", "Pike County", "Randolph County", "Russell County", "St.
test = {
'lol': ['wat', 'the', 'fuck'],
'ten': 'pence',
'who': {'did': 1, 'the': 2, 'poop': 3},
'this': [{'goes': {'pretty': 'deep'}, 'if': {'I': 'may say so'}}]
}
class StopSearch(Exception):
pass
"""
Server that accepts a connection, spawns a client handler. Client handler
accepts a request, sends a 404, and kills the connection. Client should attempt
to reuse the connection, failing. Client should retry a new request, passing.
"""
import time
import socket
import h11
from itertools import cycle, islice
import pprint
# one cycle of the group
def increasing_cyclical(xs, period, max_width):
"""
Find the subcycles of an iterable given a depth and breadth.
period: the depth of the subcycle
max_width: the breadth of the subcycle
"""
import socket
import time
from gzip import compress
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 8000))
s.listen(4)
while True:
def processor(burn=1):
def inner(gen):
def wrapper(*args, **kwargs):
g = gen(*args, **kwargs)
for _ in range(burn):
next(g)
return g
return wrapper
return inner
from collections import OrderedDict
class OrderedDefaultDict(OrderedDict):
def __init__(self, default, *args, **kwargs):
# Your default must be callable.
self.default = default
super().__init__(*args, **kwargs)
def __missing__(self, key):
self[key] = value = self.default()
from threading import BoundedSemaphore
from types import GeneratorType
from collections.abc import MappingView, Sequence
from functools import partial
_ALLOWED_SEQUENCE_TYPES = (
Sequence,
MappingView,
GeneratorType
from threading import BoundedSemaphore
from types import GeneratorType
from collections.abc import MappingView, Sequence
from functools import partial
_ALLOWED_SEQUENCE_TYPES = (
Sequence,
MappingView,
GeneratorType