Skip to content

Instantly share code, notes, and snippets.

View md2perpe's full-sized avatar

Per Persson md2perpe

View GitHub Profile
@bitonic
bitonic / cout.hs
Created November 1, 2011 19:23
cout in Haskell
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, IncoherentInstances #-}
class Cout a r where
(<<) :: IO String -> a -> IO r
instance Cout [Char] [Char] where
lm << x = fmap (++ x) lm
instance Cout [Char] () where
lm << x = lm >>= putStr . (++ x)
@md2perpe
md2perpe / gist:1886070
Created February 22, 2012 17:04
Binary trees in database with interval halving
For binary trees I've found a variant of nested sets.
The idea is to let
- the root node be represented by the interval [0, 1],
- the two children of the root node be represented by the intervals [0, 1/2] and [1/2, 1] respectively,
- the grandchild nodes by [0, 1/4], [1/4, 1/2], [1/2, 3/4] and [3/4, 1].
Then it's easy to find:
- the left and right children (one or both),
- all descendents of a node,
@md2perpe
md2perpe / jag-skams-inte.md
Last active April 27, 2021 21:38
Jag skäms inte

Jag skäms inte

Jag skäms inte över att vara svensk.
Men jag skäms över hur vissa ser ned på dem som vill bli svenskar.

Jag skäms inte över den svenska flaggan.
Men jag skäms över hur den används mot dem som vill hissa den.

Jag skäms inte över Sverige.
Men jag skäms över hur vissa anser sig ha ensamrätt till landet.

@staltz
staltz / introrx.md
Last active May 12, 2026 01:57
The introduction to Reactive Programming you've been missing
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.