Skip to content

Instantly share code, notes, and snippets.

defined("flask", "test-module").
scope("module", "NONE").
scope("render", "test-module").
scope("render", "render-sub").
get_d(Name, CurrentScope) :- defined(Name, CurrentScope).
get_d(Name, PS) :- get_d(Name, PS), scope(CurrentScope, PS).
get_d("flask", A)?
/nix/store/01fcvccrfxallx8nvl37hm2wn4s8m5d2-binutils-2.23.1.drv
/nix/store/01fcw5v5kqil2bqz0n6rqrj8ajdjg26h-ncurses-5.9.drv
/nix/store/027jx787j79skn98avxmfg4n17i4m0d4-distutils.cfg.drv
/nix/store/02rwxn991y0r5qjx3is7r5aj7i24lrb8-bash43-015.drv
/nix/store/06n2pfr1h9b9xs3gcyjbcccv0k94329m-llvm-3.5.0.drv
/nix/store/094mng1j45bxnr4hz8awinhq4q0qxhaf-bash43-022.drv
/nix/store/0ipg6zpc6p7s2cqgmv8c1hfzw2m0gfm5-bash43-004.drv
/nix/store/0lc1bacgrp6k5yn3py9w7zfilf1s48jp-gpm-1.20.7.drv
/nix/store/0p1zbmsc0gjdx5d9389zh9ypknrnbrj1-bash43-032.drv
/nix/store/0vwbsqixj92pppgg5jai2lqikk3wjk5w-patchelf-0.8.drv
@teh
teh / puzzle
Last active August 29, 2015 14:20
puzzle
include "globals.mzn";
set of 1..5: a = 1..5; % Nicola, Ed, David, Nick, Nigel
set of 1..5: b = 1..5; % Guinea, Squirrel, Pitbull, Badger, Fish
set of 1..5: c = 1..5; % Moccachino, FlatWhite, Chai, Double Espresso, Decaf
set of 1..5: d = 1..5; % Car, Bike, Train, Plane, Walk
set of 1..5: e = 1..5; % Tartan, Paisly, Gingham, Striped, Polka
array[a] of var a: A;
array[b] of var b: B;
@teh
teh / ipython3.nix
Created April 15, 2015 15:01
ipython 3.1
{ stdenv, fetchurl, buildPythonPackage, pythonPackages, zeromq3, pyqt4 ? null
, notebookSupport ? true # ipython notebook
, qtconsoleSupport ? true # ipython qtconsole
, pylabSupport ? true # ipython --pylab (backend: agg - no gui, just file)
, pylabQtSupport ? true # ipython --pylab=qt (backend: Qt4Agg - plot to window)
}:
# ipython qtconsole works with both pyside and pyqt4. But ipython --pylab=qt
# only works with pyqt4 (at least this is true for ipython 0.13.1). So just use
# pyqt4 for both.
def get_records():
df = pandas.read_json('1.json')
df = pandas.io.json.json_normalize(df['accidents'])
for _, row in df.iterrows():
for c in row['casualties']:
for i in row['involved']:
row['caualty_severity'] = c['severity']
row['caualty_gender'] = c['gender']
row['caualty_class'] = c['class']
row['caualty_vehicle'] = c.get('vehicle', 'unknonwn')
@teh
teh / config.md
Last active August 29, 2015 14:17

Backwards compatible configuration

If some record can change it's a good idea to use a sum type, e.g. you start out with your new program like this:

data Wibble = WibbleV0 { port :: Int, name :: String }

A year later you have a new feature that requires more info. Now you

@teh
teh / deps.nix
Last active August 29, 2015 14:17
with (import <nixpkgs> {}).pkgs;
let
importDeps = stdenv.mkDerivation {
name = "importDeps";
src = fetchurl {
url = "file:///home/tom/testbed/nix-import-stuff/ext.zip";
sha256 = "0ivhsn2pp1sgzsywnd2x673ff5q62v9715kkw5vyf63rfh7fw9h4";
};
phases = "unpackPhase installPhase";
module Main where
import Python
import Test.QuickCheck
import Test.QuickCheck.Monadic
square :: Int -> IO Int
square = defVV "export = lambda x: x * x"
with (import <nixpkgs> {}).pkgs;
let monad-control = pkgs.haskellngPackages.callPackage ./monad-control-0.3.nix {};
pkg = haskellngPackages.callPackage
({ mkDerivation, base, monad-control, stdenv, yesod }:
mkDerivation {
pname = "yesod-nix";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
@teh
teh / ElmDerive.hs
Last active August 29, 2015 14:16
break hs
{-# LANGUAGE TemplateHaskell #-}
module ElmDerive where
import Language.Haskell.TH
makeElm :: Name -> Q [Dec]
makeElm t = do
-- Get list of constructors for type t
TyConI (DataD _ _ _ constructors _) <- reify t
x <- [d| x = "hi" |]