Skip to content

Instantly share code, notes, and snippets.

View crackwitz's full-sized avatar

Christoph Rackwitz crackwitz

  • Aachen, Germany
  • 02:36 (UTC +02:00)
View GitHub Profile
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]))
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
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
@crackwitz
crackwitz / dsmc.py
Created December 7, 2015 01:10
grab info out of Tivoli Storage Manager using the client console (dsmc)
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
import os
import sys
import subprocess
import json
import pprint
import glob
def getlen(filename):
avdata = json.loads(
subprocess.check_output(
@crackwitz
crackwitz / wind.py
Last active April 14, 2016 01:51
Ruft flugplatz-aachen.de ab und zeigt aktuelle Windgeschwindigkeit und Richtung an
import sys, os
import time
import urllib
import json
from lxml import etree # pip install lxml
def get_timestamp(tree):
import datetime
import re
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
#!/usr/bin/env python3
import numpy as np
import cv2
srcname = 'KIjDIBS'
source = cv2.imread('{}.png'.format(srcname))
height,width = source.shape[:2]
#!/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]
})
#include "debounce.h"
inline bool debounce(debounce_t *ctx, bool newsample)
{
if (newsample != ctx->prev)
{
ctx->prev = newsample;
ctx->count = 0;
}