Skip to content

Instantly share code, notes, and snippets.

@teh
teh / gist:c195cedccabcf54733e6bd0436b83c07
Created August 2, 2016 10:05
How to diff a nixops state file
$ cat .git/config
...
[diff "nixops"]
textconv = nixops export -s
$ cat .gitattributes
production/secrets/**/* filter=git-crypt diff=nixops
{%- extends 'full.tpl' -%}
{%- block input_group -%}
{%- endblock input_group -%}
{ fetchurl, stdenv }:
stdenv.mkDerivation rec {
name = "pies-1.2";
src = fetchurl {
url = "mirror://gnu/pies/${name}.tar.bz2";
sha256 = "18w0dbg77i56cx1bwa789w0qi3l4xkkbascxcv2b6gbm0zmjg1g6";
};
@teh
teh / wagner_fisher.py
Created January 18, 2016 12:26
wagner-fisher in numba
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,
-- NO !
record :: (Show a, Show label, MonadIO m) => label -> Pipe a a m ()
record label = do
x <- await
print (label, x)
yield x
-- yes:
record :: (Show a, Show label, MonadIO m) => label -> Pipe a a m ()
record label = do
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Concurrent (forkIO)
import Control.Monad (forever)
import Network.Wai.Handler.Warp (run)
import Network.Wai.Handler.WebSockets as WaiWS
import Network.WebSockets (acceptRequest, receiveDataMessage, sendTextData, PendingConnection, defaultConnectionOptions, DataMessage(..))
import Data.ByteString.Lazy (ByteString)
@teh
teh / ghcjs nix .sh
Created November 1, 2015 22:24
ghsc
$ nix-shell -p "haskell.packages.ghcjs.ghcWithPackages (pkgs: [pkgs.reflex-dom])"
import Reactive.Banana (compile)
import Reactive.Banana.Frameworks (newAddHandler, fromAddHandler, actuate, reactimate)
import Control.Concurrent (threadDelay, forkIO)
import Control.Monad (forever)
import Data.Char (toUpper)
main = do
-- newAddHandler returns an AddHandler (roughly a callback) and a
-- way to fire the callback (fire).
(es, fire) <- newAddHandler
import Data.ReactiveValue ((=:>), ReactiveFieldWrite(..), ReactiveFieldRead(..))
import Hails.Polling (pollingReactive)
main :: IO ()
main = do
hello <- pollingReactive (return "hello") (Just 1000000)
let out = ReactiveFieldWrite print
hello =:> out
getLine >> return ()
@teh
teh / manifest
Last active October 17, 2017 14:55
Create a an ACI image with tar, then run it with rkt.
{
"acKind": "ImageManifest",
"acVersion": "0.7.0",
"name": "my-app",
"labels": [
{"name": "os", "value": "linux"},
{"name": "arch", "value": "amd64"}
],
"app": {
"exec": [