Skip to content

Instantly share code, notes, and snippets.

View cjhanks's full-sized avatar
🔥

zeekoni cjhanks

🔥
View GitHub Profile
@cjhanks
cjhanks / minpool.py
Created April 29, 2013 17:52
Minimal ThreadPool
from threading import Thread
from Queue import Queue
class ThreadPool(object):
# Nested private worker class
class Worker(Thread):
def __init__(self, queue):
#!/bin/bash
package="$1"
version="$2"
curl -X GET http://127.0.0.1:5000/package/$package/$version
@cjhanks
cjhanks / htool.py
Last active September 25, 2016 18:31
Haskell --> Python Tools
""" htool :: Haskell Tool
Module of borrowed operators from Haskell implemented in Python for the purpose
of gaining more familiarity with functional programming in a familiar
environment.
"""
__author__ = 'CjHanks'
__license__ = 'Free'
from operator import lt, gt
from signal import signal, SIGUSR1
from traceback import format_stack
from sys import stderr
def dump_frame(sig, frame):
if sig is SIGUSR1:
stderr.write(''.join(format_stack(frame)))
INIT
@cjhanks
cjhanks / ec2ls
Last active December 30, 2015 02:09
Ec2Ls
#!/usr/bin/env python2
from sys import argv
from fnmatch import fnmatch
from boto.ec2 import connect_to_region
pattern = '*' if 1 is len(argv) else argv[1]
machines = []
@cjhanks
cjhanks / gist:8137416
Created December 26, 2013 18:58
probability.py
from copy import copy
from random import shuffle
d = [ 0, 1, 2, 3, 4 ]
T = 0
F = 0
for i in range(0, 10000):
@cjhanks
cjhanks / cvgrind
Last active January 2, 2016 07:49
mixes callgrind with cProfile for more thorough profiling
#!/usr/bin/env python2
"""
:author: CjHanks <[email protected]>
Usage: cvgrind module {optional_entry_point}
# Will call
import module
# -- optionally --
module.optional_entry_point()
@cjhanks
cjhanks / parentclass.py
Created January 10, 2014 21:43
parent class
class Parent(object):
def method(self, *args, **kwargs):
raise NotImplementedError('NOT DONE')
@classmethod
def impl_method(Cls, data):
print(Cls, data)
class Child1(Parent):
@cjhanks
cjhanks / t0.py
Created February 21, 2014 06:02
sre-tests
"""
http://www.careercup.com/question?id=5127611667709952
"""
RowSize = 5
Data = [['a', 'b', 'c', 'd', 'e'],
['f', 'g', 'h', 'i', 'j'],
['k', 'l', 'm', 'n', 'o'],
['p', 'q', 'r', 's', 't'],
['u', 'v', 'w', 'x', 'y'],