Skip to content

Instantly share code, notes, and snippets.

@Nazek42
Nazek42 / terrain.py
Created April 11, 2019 00:29
CHAOS CONTROL
import numpy as np
from scipy.ndimage.filters import generic_filter
from random import random
import matplotlib.pyplot as pp
import matplotlib
grid = np.random.rand(128, 128)
weights = [ 1, 2, 1,
2, 3, 2,
@Nazek42
Nazek42 / dedict.py
Created August 12, 2017 23:35
Python two-way dictionary
# dedict, aka "double-ended dict"
# A data structure allowing for bidirectional lookups
#
# Syntax for lookups:
# By key:
# myDedict[key] OR myDedict[key:]
# By value:
# myDedict[:value]
# This is meant to evoke the dict literal syntax of key: value.
#
@Nazek42
Nazek42 / curry.py
Last active June 20, 2016 20:29
Python Currying
import functools
import inspect
# Decorator
def curry(func):
sig = inspect.signature(inspectable(func))
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
sig.bind(*args, **kwargs)