This file contains 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
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds, PolyKinds, TypeOperators #-} | |
{-# LANGUAGE TypeFamilies, FlexibleInstances #-} | |
{-# LANGUAGE InstanceSigs #-} | |
-- When do I need TypeApplication? | |
-- When I need some intermediate types that change how |
This file contains 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 python | |
""" | |
Welcome to Tom-does-another-disgusting-hack. | |
This is an executable shim for the stack binary whose only purpose is | |
to make the amazing intero mode [1] work in a non-stack environment (Nix | |
in our case). | |
Dump it somewhere and make sure it runs *instead* of the actual stack binary. | |
You will not be able to use stack at the same time. |
This file contains 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 sklearn.base as base | |
import sklearn.linear_model as lm | |
import numpy | |
class ByThreshold(base.BaseEstimator, base.ClassifierMixin): | |
def __init__(self, estimator, threshold=0.95): | |
self.threshold = threshold | |
self.estimator = estimator |
This file contains 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 python | |
import sys | |
import time | |
import os | |
import subprocess | |
def main(): | |
if sys.argv[1:] == ["path", "--project-root", "--verbosity", "silent"]: | |
print "/home/tom/src/intero" |
This file contains 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
$ cat .git/config | |
... | |
[diff "nixops"] | |
textconv = nixops export -s | |
$ cat .gitattributes | |
production/secrets/**/* filter=git-crypt diff=nixops | |
This file contains 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
{%- extends 'full.tpl' -%} | |
{%- block input_group -%} | |
{%- endblock input_group -%} |
This file contains 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
{ fetchurl, stdenv }: | |
stdenv.mkDerivation rec { | |
name = "pies-1.2"; | |
src = fetchurl { | |
url = "mirror://gnu/pies/${name}.tar.bz2"; | |
sha256 = "18w0dbg77i56cx1bwa789w0qi3l4xkkbascxcv2b6gbm0zmjg1g6"; | |
}; |
This file contains 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 numpy | |
import timeit | |
import numba | |
@numba.autojit(locals=dict( | |
best_k=numba.int64, | |
pos=numba.int64, | |
ins_del_count=numba.int64, | |
i=numba.int64, | |
j=numba.int64, |
This file contains 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
# Solve n-queens problem with picosat | |
import pycosat | |
import numpy | |
import itertools | |
def get_cnf(N): | |
cnf = [] | |
# * convert to object because pycosat expects 'int's | |
# * add 1 because 0 is reserved in pycosat |
This file contains 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 PIL import Image | |
import numpy | |
from skimage.filter import sobel | |
from skimage.morphology import watershed | |
from scipy import ndimage as nd | |
grind = numpy.asarray(Image.open('grind.png')).mean(axis=2) | |
edges = sobel(grind) | |
markers = numpy.zeros_like(grind) |