Skip to content

Instantly share code, notes, and snippets.

/* Usage: write sparse image to block device, padded to the logical block size (BLKSSZGET).
TODO: Combine neighbor logical blocks into larger chunks, possibly taking advantage of BLKALIGNOFF BLKPBSZGET BLKIOOPT.
Rationale:
I created a LUKS crypto block device with integrity. I'd want to wipe
each sector (i.e. logical block) so the sector's integrity checks,
before I could read from the sector. Upon "luksFormat", cryptsetup(8)
offers to wipe all sectors by default. If I'd overwrite a sector, the
sector's integrity bits'd be overwritten, too, so I'd no need to care
@insulsa
insulsa / 1.hs
Created February 27, 2019 13:46
Introduction to haskell parsec
import qualified Control.Monad
import qualified Text.Printf
import qualified Text.Parsec.Token
import qualified Text.ParserCombinators.Parsec
import qualified Text.ParserCombinators.Parsec.Language
data E = Int_E Integer | Y String | Z
identifier = Text.Parsec.Token.identifier Text.ParserCombinators.Parsec.Language.haskell
integer = Text.Parsec.Token.integer Text.ParserCombinators.Parsec.Language.haskell
#define g(x) int g##x(int n){int t=n; for (int i=1; i<n; i++) t=x(t); return t;}
int h(int n){return n+1;}
g(h)
g(gh)
g(ggh)
int f(int n){return gggh(n);}