Skip to content

Instantly share code, notes, and snippets.

@1328
1328 / gol.py
Created January 8, 2016 14:59
Game of Life
import random
import os
import time
from pprint import pprint
def populate_board(x_size = 40, y_size = 40, density = .3):
''' build a board x X y size '''
board =set()
population = x_size * y_size * density
@1328
1328 / a.py
Created January 5, 2016 16:53
a.py
LOG = '''
Tue Feb 24 00:00:02 2015 [11272386][-none-][FATAL] IBMDB2Manager: Persistent connection specified, but failed. Error: 42968: [IBM][CLI Driver] SQL8001N An attempt to connect to the database failed due to a product license problem. SQLSTATE=42968 SQLCODE=-8001
Tue Feb 24 00:00:02 2015 [12517544][-none-][FATAL] IBMDB2Manager: Persistent connection specified, but failed. Error: 42968: [IBM][CLI Driver] SQL8001N An attempt to connect to the database failed due to a product license problem. SQLSTATE=42968 SQLCODE=-8001
Tue Feb 24 00:00:02 2015 [11272386][-none-][FATAL] IBMDB2Manager: Could not connect to Database with non-persistent connection. Error 42968: [IBM][CLI Driver] SQL8001N An attempt to connect to the database failed due to a product license problem. SQLSTATE=42968 SQLCODE=-8001
Tue Feb 24 00:00:02 2015 [11272386][-none-][FATAL] Could Not Connect:: Database Is Not Connected
Tue Feb 24 00:00:02 2015 [11272386][-none-][FATAL] Stack trace for DB_ERROR:
#0 custom/include/database/CustomIBM
@1328
1328 / c.py
Created November 20, 2015 00:13
context
import sys
from functools import wraps
from warnings import warn
class GeneratorContextManager(object):
"""Helper for @contextmanager decorator."""
def __init__(self, gen):
@1328
1328 / x.py
Created October 14, 2015 23:03
xim
from __future__ import absolute_import, division, print_function
# might make this work on py2
from builtins import *
# Copyright (c) 2014, Varian Medical Systems, Inc. (VMS)
# All rights reserved.
#
# ximReader is an open source tool for reading .xim file (both compressed and uncompressed)
# HND compression algorithm is used to compress xim files. For a brief description of HND
@1328
1328 / x.py
Created October 13, 2015 17:20
testing code
import timeit
from random import shuffle, randrange
from functools import partial
from collections import deque
import time
def mean(al):
return sum(al)/len(al)
@1328
1328 / t.py
Created October 5, 2015 14:40
family tree
from pprint import pprint
data = {
"children": [
{
"id": 409,
"name": "Joe Bloggs",
"no_parent": "true"
},
@1328
1328 / ximmer2.py
Created September 30, 2015 22:51
ximmer2.py
from __future__ import absolute_import, division, print_function
# might make this work on py2
from builtins import *
# Copyright (c) 2014, Varian Medical Systems, Inc. (VMS)
# All rights reserved.
#
# ximReader is an open source tool for reading .xim file (both compressed and uncompressed)
# HND compression algorithm is used to compress xim files. For a brief description of HND
# compression algorithm please refer to the xim_readme.txt file.
@1328
1328 / ximmer.py
Created September 30, 2015 14:47
xim fix
from __future__ import absolute_import, division, print_function
# might make this work on py2
from builtins import *
# Copyright (c) 2014, Varian Medical Systems, Inc. (VMS)
# All rights reserved.
#
# ximReader is an open source tool for reading .xim file (both compressed and uncompressed)
# HND compression algorithm is used to compress xim files. For a brief description of HND
# compression algorithm please refer to the xim_readme.txt file.
@1328
1328 / h.py
Last active August 29, 2015 14:27
hang
from random import choice
# reorganize into functions, main
def load_categoties()
with open('words/animals') as a: #Create the pool of words to be randomly chosen from, and split it up into categories.
animal_list = a.read().splitlines()
with open ('words/jobs') as b:
jobs_list = b.read().splitlines()
@1328
1328 / s.py
Last active August 29, 2015 14:24
skills
from collections import defaultdict
from pprint import pprint
class Effect(object):
def __init__(self, what, how):
self.what = what
self.how = how
def apply(self, base):