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 pprint | |
pp = pprint.pprint | |
def cartesian(a,b): | |
return set([u+v for u in a for v in b]) | |
def findrules(g, s): | |
return set(k for k in g if any(s in x for x in g[k])) |
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 nextprime(a, primes=[2]): | |
while True: | |
if all (a % p > 0 for p in primes): | |
return a | |
a += 1 | |
def factorize(n): | |
factors = [] | |
primes = [2] | |
p = 2 |
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 itertools | |
def cartesian(*lists): | |
if len(lists) == 0: | |
yield () | |
else: | |
for t in cartesian(*lists[1:]): | |
for x in lists[0]: | |
yield (x,) + t |
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 | |
import re | |
import subprocess | |
import pprint; pp = pprint.pprint | |
dsmdir = "p:\\tivoli\\tsm\\baclient" | |
assert os.getenv("PASS") is not None |
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 | |
import subprocess | |
import json | |
import pprint | |
import glob | |
def getlen(filename): | |
avdata = json.loads( | |
subprocess.check_output( |
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, os | |
import time | |
import urllib | |
import json | |
from lxml import etree # pip install lxml | |
def get_timestamp(tree): | |
import datetime | |
import re |
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
from __future__ import division | |
import os | |
import sys | |
import numpy as np | |
import cv2 | |
np.set_printoptions(precision=4, suppress=True) | |
def getseam(image, x0=0, y0=0, blur=False): | |
height, width, nch = image.shape |
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 python3 | |
import numpy as np | |
import cv2 | |
srcname = 'KIjDIBS' | |
source = cv2.imread('{}.png'.format(srcname)) | |
height,width = source.shape[:2] |
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 python3 | |
import os | |
import numpy as np | |
mydtype = np.dtype({ | |
'names': 'x y xy'.split(), | |
'formats': 'f4 f4 2f4'.split(), | |
'offsets': [0, 4, 0] | |
}) |
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 "debounce.h" | |
inline bool debounce(debounce_t *ctx, bool newsample) | |
{ | |
if (newsample != ctx->prev) | |
{ | |
ctx->prev = newsample; | |
ctx->count = 0; | |
} |