Skip to content

Instantly share code, notes, and snippets.

View dtlanghoff's full-sized avatar

Daniel Tobias Johansen Langhoff dtlanghoff

View GitHub Profile
#!/usr/bin/env python3
import random
def shiftCharCode(code, shift):
return ((code + shift + 185) % 217) + 32
def shiftString(s, shift):
return ''.join(chr(shiftCharCode(ord(i), shift)) for i in s)
-++/|+(5)++(3)(1)(1)<x+(2)x>$->#(2)<x(1)>s(1)<i+si>+||#(5)<x->x<y+$xz(100)<k-zk>y>><x$xa(0)<b+ab>>|-$->#(10)<x#x>x(0)<y+x$yz(0)<y+yz>>$->->#(30)<x+x(1)><x%$->#(10)<a*a$=?->#<F?=F*(2)(4)<B*+FBB>[-(20)(15)](100000)>[|->#||(1)<x+(1)x><x+(1)x><x|(1)<x+(1)x>><r$rp(0)<q+pq>>]<i+(100)i><x>x(100)>A(0)<I+AI>>M(1)<b+Mb>x>C(0)<m+mC><x*(113)x>|||*|||(1)<x(1)><x+|(1)<x(1)>x><x*||(1)<x(1)><x+|(1)<x(1)>x>x>|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x><x+|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x>x><x+|*|||(1)<x(1)><x+|(1)<x(1)>x><x*||(1)<x(1)><x+|(1)<x(1)>x>x>|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x><x+|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x>x>x><x+||*|||(1)<x(1)><x+|(1)<x(1)>x><x*||(1)<x(1)><x+|(1)<x(1)>x>x>|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x><x+|||(1)<x(1)><x+|(1)<x(1)>x><x+||(1)<x(1)><x+||(1)<x(1)><x+|(1)<x(1)>x>x>x>x><x+|*|||(1)<x(1)><x+|(1)<x(1)>x><x*||(1)<
#!/usr/bin/env python3
import codecs
import datetime
class Day:
def __init__(self, name, date):
self.name = name
self.date = date
@dtlanghoff
dtlanghoff / randomness.py
Last active August 29, 2015 13:56
Empirical randomness testing
import numpy as np
import scipy.stats
from scipy.misc import factorial
from sklearn.utils.extmath import cartesian
def equidistribution_test(Y, d):
observed = np.bincount(seq, minlength=d)
expected = len(seq) * np.ones(d) / d
return 1 - scipy.stats.chi2.cdf(np.sum((observed-expected)**2 / expected), d - 1)
#!/usr/bin/env python3
from math import acosh, atan, cos, cosh, log, sqrt, tan, tanh
viscosity = {'air': 1.9e-5,
'water': 8.9e-4,
'olive oil': 0.081}
density = {'air': 1.275,
'olive oil': 860.,
from __future__ import division
class Matrix:
def __init__(self, v):
self.value = [list(i) for i in v]
self.rows = len(self.value)
self.columns = len(self.value[0])
def __iter__(self):
return iter(self.value)
def __repr__(self):
#!/usr/bin/env python
import math
import sys
import gdal
import gdalconst
import numpy
from PIL import Image
#!/usr/bin/env python3
# Copyright 2013-2017 Daniel Tobias Johansen Langhoff
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
#!/usr/bin/env python3
import itertools
import pprint
from math import prod
import numpy as np
from scipy.optimize import least_squares
@dtlanghoff
dtlanghoff / app.py
Last active June 6, 2023 08:07
Slektskart
import io
import locale
import math
import lark
import pyproj
from PIL import Image, ImageDraw
from flask import Flask, make_response, render_template