Skip to content

Instantly share code, notes, and snippets.

-- shiny and exciting O(n log n) algorithm
-- the n parameter and the idea to use something like merge sort is from Bird
-- both of those things are really clever
join :: Ord a => Int -> [(a, Int)] -> [(a, Int)] -> [(a, Int)]
join 0 ax [] = ax -- n corresponds to length b, so if b is empty n = 0
join n [] bx = bx
-- something like merge sort but slightly different
join n ax@((a, ac):as) bx@((b, bc):bs)
| a < b = (a, ac + n) : join n as bx
import Data.List
-- import Debug.Trace
data Node a = DeadEnd a
| Passage a (Node a)
| Fork a (Node a) (Node a)
instance (Show a) => Show (Node a) where
show (DeadEnd a) = "DeadEnd " ++ show a
show (Passage a _) = "Passage " ++ show a
show (Fork a _ _) = "Fork " ++ show a
@yorickvP
yorickvP / Makefile.agricraft
Last active April 3, 2016 18:14
let's do some crop mutations
WateringCan: | Kiwi Beet Corn
Pumpkin: | Carrot Potato
Sugarcane: | Carrot Wheat
Melon: | Carrot Pumpkin
Dandelion: | Melon Sugarcane
Poppy: | Pumpkin Sugarcane
BlueOrchid: | Poppy Dandelion
Daisy: | BlueOrchid Dandelion
Allium: | BlueOrchid Poppy
let
pkgs = import <nixpkgs> {};
pypkg = pkgs.python27Packages;
in
{ stdenv ? pkgs.stdenv, python27 ? pkgs.python27, fetchFromGitHub ? pkgs.fetchFromGitHub,
virtualenv ? pypkg.virtualenv, pip ? pypkg.pip, setuptools ? pypkg.setuptools }:
let
inherit (pkgs.lib) concatMapStringsSep mapAttrsToList concatStringsSep;
deps = {
# the script fetches two other repos from github
@yorickvP
yorickvP / .gitignore
Last active September 20, 2016 09:56
electron-desktop
node_modules

Keybase proof

I hereby claim:

  • I am yorickvp on github.
  • I am yorickvp (https://keybase.io/yorickvp) on keybase.
  • I have a public key ASDL4mFp5PyVeysyX677R1QZi-KBg5DoPBa8wf3CMcq4ego

To claim this, I am signing this object:

{ pkgs ? (import <nixpkgs> {})
, stdenv ? pkgs.stdenv
, xdotool ? pkgs.xdotool
, makeWrapper ? pkgs.makeWrapper
, wmctrl ? pkgs.wmctrl
, fetchFromGitHub ? pkgs.fetchFromGitHub
, bash ? pkgs.bash
, python3 ? pkgs.python3
, libinput ? pkgs.libinput
, procps ? pkgs.procps
@yorickvP
yorickvP / cli.c
Created July 2, 2017 17:33
sss-cli
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "sss.h"
int cli_create(int argc, const char* argv[]) {
if (argc != 4) return 1;
unsigned long int shares = strtoul(argv[2], NULL, 10);
unsigned long int required = strtoul(argv[3], NULL, 10);
Mar 14 20:57:57 wiki postgresql-start[635]: 2018-03-14 20:57:57.044 GMT [7545] ERROR: column t1.tgconstrname does not exist at character 113
Mar 14 20:57:57 wiki postgresql-start[635]: 2018-03-14 20:57:57.044 GMT [7545] STATEMENT: SELECT DISTINCT NULL::text as pnspname, NULL::text as fnspname, c1.relname as prelname, c2.relname as frelname, t1.tgconstrname, a.attnum as keyseq, ic.relname as fkeyname, t1.tgdeferrable, t1.tginitdeferred, t1.tgnargs,t1.tgargs, p1.proname as updaterule, p2.proname as deleterule FROM pg_class c1 JOIN pg_index i ON (c1.oid=i.indrelid) JOIN pg_class ic ON (i.indexrelid=ic.oid) JOIN pg_attribute a ON (ic.oid=a.attrelid), pg_class c2, pg_trigger t1 JOIN pg_proc p1 ON (t1.tgfoid=p1.oid), pg_trigger t2 JOIN pg_proc p2 ON (t2.tgfoid=p2.oid) WHERE (t1.tgrelid=c1.oid AND t1.tgisconstraint AND t1.tgconstrrelid=c2.oid AND p1.proname ~ '^RI_FKey_.*_upd$') AND (t2.tgrelid=c1.oid AND t2.tgisconstraint AND t2.tgconstrrelid=c2.oid AND p2.proname ~ '^RI_FKey_.*_del$') AND i.indisprimary
$ postgres --version
postgres (PostgreSQL) 10.1
# postgresql_jdbc
nix-repl> postgresql_jdbc.src.urls
[ "http://jdbc.postgresql.org/download/postgresql-jdbc-9.3-1100.src.tar.gz" ]
# java
nix-repl> openjdk8.jre.name
"openjdk-8u172b02"