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 GADTs, TypeFamilies, DataKinds, TypeOperators #-} | |
import Type.Reflection | |
type family Map f xs where | |
Map f '[] = '[] | |
Map f (x ': xs) = f x ': Map f xs | |
data HList xs where | |
HNil :: HList '[] |
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
#!/bin/sh | |
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ | |
db=$tmp/db | |
fs=$tmp/fs | |
mkdir "$tmp" | |
trap 'rm -rf "$tmp"' EXIT | |
pacman -Qlq | sort -u > "$db" |
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
#!/bin/sh | |
function dis { | |
case "$1" in | |
--stash) | |
export DIS_STASH_FILE="$(mktemp)" | |
gdb -batch -ex "disassemble $3" $2 >> $DIS_STASH_FILE | |
cat $DIS_STASH_FILE | |
;; |
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 python3 | |
# Ported from http://www.a1k0n.net/2011/07/20/donut-math.html | |
# Run with 'python donut.py' | |
import math | |
R1 = 1 | |
R2 = 2 | |
K2 = 5 |
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 GADTs #-} | |
import Control.Lens | |
import Control.Monad.Free | |
data Action | |
= Cellar | Chapel | Moat | |
| Chancellor | Village | Woodcutter | Workshop | |
| Bureaucrat | Feast | Gardens | Militia | Moneylender | Remodel | Smithy | Spy | Thief | ThroneRoom | |
| CouncilRoom | Festival | Laboratory | Library | Market | Mine | Witch |
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
! URxvt settings | |
URxvt.scrollBar: off | |
!URxvt.font: xft:terminus:size=12:antialias=true | |
URxvt.intensityStyles: false | |
URxvt.letterSpace: -1 | |
URxvt.perl-ext-common: default,matcher | |
URxvt.url-launcher: /usr/bin/firefox | |
URxvt.matcher.button: 1 | |
! Common |
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
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) | |
{ | |
int64_t b = -1, j = 0; | |
while (j < num_buckets) { | |
b = j; | |
key = key * 2862933555777941757ULL + 1; | |
j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1); | |
} | |
return b; | |
} |
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 Control.Applicative | |
import Control.Monad | |
import Data.Monoid | |
data SignalT m a | |
= Skip (m (SignalT m a)) | |
| Emit a (m (SignalT m a)) | |
instance Monad m => Functor (SignalT m) where | |
fmap f = go |
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 Arrows, GADTs #-} | |
data Par a b where | |
Pure :: (a -> b) -> Par a b | |
Seq :: Par a b -> Par b c -> Par a c | |
Par :: (a -> (a1, a2)) -> Par a1 b1 -> Par a2 b2 -> ((b1, b2) -> b) -> Par a b | |
instance Category Par where | |
id = Pure id |
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 FlexibleInstances #-} | |
{-# LANGUAGE OverlappingInstances #-} | |
import Control.Applicative | |
import Control.Concurrent | |
import Control.Concurrent.STM | |
import Data.Dynamic | |
import Data.Monoid | |
import Data.Word | |
import qualified Data.Foldable as F |
NewerOlder