View extensible_variants.ml
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
(* extensible variant types, including GADTs | |
* not to be confused with polymorphic variants | |
*) | |
type extend_me = .. | |
type extend_me += This | |
type extend_me += That of int | |
type extend_me += TheOther of string |
View rot13.rs
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
use std::io::{self, BufRead}; | |
fn rot13(s: &str) -> String { | |
s.chars().map(|c| { | |
if c.is_ascii_lowercase() { | |
((c as u8 - b'a' + 13) % 26 + b'a') as char | |
} else if c.is_ascii_uppercase() { | |
((c as u8 - b'A' + 13) % 26 + b'A') as char | |
} else { | |
c |
View stream_video.sh
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 bash | |
trap "trap - SIGTERM && echo 'shutting down!' && kill -- -$$" SIGINT SIGTERM EXIT | |
echo "kill me with 'kill $$'" | |
(nohup raspivid -o - -t 0 -w 800 -h 600 -fps 15 2>/dev/null | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8080/}' :demux=h264 --h264-fps=15 >/dev/null 2>&1) & | |
PID=$! | |
wait $PID | |
trap - SIGINT SIGTERM EXIT | |
wait $PID |
View fake.nix
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
with import <nixpkgs> {}; derivation { name = "fake"; builder = "${coreutils}/bin/touch"; args=[(placeholder "out")]; system = builtins.currentSystem; } |
View iota.dhall
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
{- requires to >= from -} | |
let stepsFromTo: Natural -> Natural -> Natural -> Natural = | |
\(from: Natural) -> | |
\(to: Natural) -> | |
\(step: Natural) -> | |
let diff = Natural/subtract from to | |
let State = { i: Natural, val: Natural } | |
let state = { i = 0, val = from } | |
let foldState = \(s: State) -> if Natural/isZero (Natural/subtract s.val to) | |
then s |
View Circ.hs
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 DeriveFunctor #-} | |
module Circ ( | |
Circ | |
, empty | |
, singleton | |
, length | |
, null | |
, delete | |
, rotateR |
View geo_dump.py
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 inspect | |
import shapely | |
class DataDumper: | |
def __init__(self, path): | |
self._handle = open(path, 'w') | |
def __enter__(self): | |
return self |
View gensym.m4
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
divert(-1) | |
changequote(`{', `}') | |
# gensym counter | |
define({%n}, 0) | |
# association for generic bodies | |
# _generic_setbody(name, body) -> store generic body by name | |
define({_generic_setbody}, {define({%gen[$1]}, $2)}) |
View bollocks.py
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 as np | |
import pandas as pd | |
# our goal is to standardize exactly 2 out of 4 columns in a grouped frame, | |
# using the within-group standard deviation and mean | |
df = pd.DataFrame({ | |
'a': ['Bennie', 'Bennie', 'Bennie', 'The Jets', 'The Jets'], | |
'b': [1.0, 3.0, 2.5, 7.1, 8.9], | |
'c': [-71.3, -80.4, -68.1, 2.5, 3.4], | |
'd': [25, 30, 40, 10, 15] # don't standardize me! |
View Makefile
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
# there is probably a way to get this from "stack path" | |
INCLUDE=C:\Users\Derrick\AppData\Local\Programs\stack\x86_64-windows\ghc-8.8.4\lib\include | |
all: hsdll.dll hsdll_stub.h usehsdll.exe | |
%.dll %_stub.h: %.hs %.def | |
stack ghc -- $^ --make -O2 -shared -static -o $@ | |
%.exe: %.c hsdll_stub.h hsdll.dll | |
gcc -O2 -I$(INCLUDE) -Wall -Wextra -std=c11 -pedantic $^ hsdll.dll -o $@ |
NewerOlder