Skip to content

Instantly share code, notes, and snippets.

@ion1
ion1 / gist:aaa5d1a840ed4f8dc4c0
Last active August 29, 2015 14:20
addFinalizer (1 :: Integer)
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.1
% ghc -ignore-dot-ghci -e 'let f x = System.Mem.Weak.addFinalizer x (putStrLn ("bye " ++ show x)) in mapM_ f [-10..10 :: Integer] *> System.Mem.performGC *> Control.Concurrent.threadDelay 1000000'
bye 10
bye 9
bye 8
bye 7
bye 6
bye 5
@@ @djinn @type (.)
f a b c = a (b c)
@@ @djinn @type (.)(.)
f a b c d = a b (c d)
@@ @djinn @type (.)(.)(.)
f a b c d = a (b c d)
@@ @djinn @type (.)(.)(.)(.)
@ion1
ion1 / FilterPartition.hs
Last active August 29, 2015 14:19
From filter to partition
filter p zs = foldr (select p) [] zs where { select p x xs | p x = x:xs | otherwise = xs }
filter' p zs = foldr (select p) ([],()) zs where { select p x ~(xs,_) | p x = (x:xs, ()) | otherwise = (xs, ()) }
partition p zs = foldr (select p) ([],[]) zs where { select p x ~(xs,ys) | p x = (x:xs, ys) | otherwise = (xs, x:ys) }
@ion1
ion1 / LEM.hs
Created April 9, 2015 17:32
Law of Excluded Middle in Cont
-- Law of Excluded Middle in Cont
import Data.Void
import Control.Monad.Cont
type Not f a = a -> f Void
type Either' r a b = (a -> r) -> (b -> r) -> r
hello :: String
@ion1
ion1 / PeirceLEM.hs
Last active July 10, 2022 02:24
Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
-- Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
{-# LANGUAGE Rank2Types #-}
import Data.Void
type Not a = a -> Void
type Peirce = forall a b. ((a -> b) -> a) -> a
type LEM = forall a. Either (Not a) a
@ion1
ion1 / log
Created March 14, 2015 00:59
fscache (and XFS?) issues
Mar 14 02:54:27 ahdin kernel: [50128.106275] INFO: task steam.exe:20809 blocked for more than 120 seconds.
Mar 14 02:54:27 ahdin kernel: [50128.106288] Tainted: P OE 3.16.0-31-generic #41~14.04.1-Ubuntu
Mar 14 02:54:27 ahdin kernel: [50128.106293] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 14 02:54:27 ahdin kernel: [50128.106298] steam.exe D ffff88031fc93440 0 20809 2351 0x20020000
Mar 14 02:54:27 ahdin kernel: [50128.106308] ffff8802b6fdb8a8 0000000000200082 ffff880097a45180 ffff8802b6fdbfd8
Mar 14 02:54:27 ahdin kernel: [50128.106316] 0000000000013440 0000000000013440 ffff8802217adbb0 ffff880097a45180
Mar 14 02:54:27 ahdin kernel: [50128.106323] ffff8802c0e2b4b8 ffff8802c0e2b4d0 ffffffffc0470b62 ffffea000597ec80
Mar 14 02:54:27 ahdin kernel: [50128.106330] Call Trace:
Mar 14 02:54:27 ahdin kernel: [50128.106419] [<ffffffffc0470b62>] ? xfs_vm_bmap+0x32/0xa0 [xfs]
Mar 14 02:54:27 ahdin kernel: [50128.106434] [<ffffffff817675c9>] schedule+0x29
@ion1
ion1 / beets-config.yaml
Created January 11, 2015 13:56
beets config
directory: ~/storage/media/audio/albums
library: ~/storage/media/audio/albums.blb
paths:
default: %asciify{%the{$albumartist} - $year%if{$month,-$month%if{$day,-$day,},} - $album%aunique{}/$disc-$track - %if{$disctitle,$disctitle - ,}%the{$artist} - $title}
singleton: %asciify{Non-Album/%the{$artist} - $title}
comp: %asciify{Various Artists - $year%if{$month,-$month%if{$day,-$day,},} - $album%aunique{}/$disc-$track - %if{$disctitle,$disctitle - ,}%the{$artist} - $title}
per_disc_numbering: yes
@ion1
ion1 / Foo.hs
Created September 19, 2014 22:57
-fdefer-type-errors
(a,b) = ("foo", "bar" + 42)
@ion1
ion1 / foo.html
Created August 20, 2014 20:04
foo
<!DOCTYPE html><html><head><title>Foo</title><style>body { font-size: 3em; }td { padding: 0.3em; text-align: right; }</style></head><body><table><tr><td><span style="color: red">0</span><span style="color: blue">1</span></td><td><span style="color: red">0</span><span style="color: blue">2</span></td><td><span style="color: red">0</span><span style="color: blue">3</span></td><td><span style="color: red">0</span><span style="color: blue">4</span></td><td><span style="color: red">0</span><span style="color: blue">5</span></td><td><span style="color: red">0</span><span style="color: blue">6</span></td><td><span style="color: red">0</span><span style="color: blue">7</span></td><td><span style="color: red">0</span><span style="color: blue">8</span></td><td><span style="color: red">0</span><span style="color: blue">9</span></td><td><span style="color: red">1</span><span style="color: blue">0</span></td></tr><tr><td><span style="color: red">1</span><span style="color: blue">1</span></td><td><span style="color: red">1
@ion1
ion1 / rcon
Last active August 29, 2015 14:05
rcon
https://gist.github.com/ion1/4589818#file-rcon