Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE NoMonomorphismRestriction #-}
{-# OPTIONS_GHC -F -pgmF she #-}
import Control.Applicative hiding (empty)
import Control.Monad.Trans
import Control.Monad.Trans.Cont
import Control.Monad.Identity
import Data.Maybe
main :: IO ()
@maoe
maoe / test.hs
Last active August 29, 2015 14:02
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Aeson
import qualified Data.ByteString.Lazy as B
{- Generic Language extension -}
import GHC.Generics (Generic)
data Pull = Pull {
@maoe
maoe / influxdb.strace.log
Last active August 29, 2015 14:01
Strace of the influxdb process
Process 28432 attached with 28 threads - interrupt to quit
[pid 25696] futex(0xc2101a70e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25695] futex(0xc2109688e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25694] restart_syscall(<... resuming interrupted call ...> <unfinished ...>
[pid 25693] futex(0xc2106b88e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25678] restart_syscall(<... resuming interrupted call ...> <unfinished ...>
[pid 25677] futex(0xc21086f8e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25676] futex(0xc21086d0e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25675] futex(0xc2102948e8, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 25674] futex(0xc2102920e8, FUTEX_WAIT, 0, NULL <unfinished ...>
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}
@maoe
maoe / sublime-project.json
Created May 9, 2014 06:05
Sublime project file
{
"folders":
[
{
"follow_symlinks": true,
"path": ".",
"file_exclude_patterns": [
"cabal.sandbox.config",
"*.hi",
"*.o",
{-# LANGUAGE PatternSynonyms #-}
module List where
import Control.Applicative
import Control.Monad.State
import Data.Foldable
import Data.Monoid
import System.Random
import Control.Monad.Free
filter' : (a -> Bool) -> Vect n a -> (p ** Vect p a)
filter' _ Nil = (_ ** [])
filter' p (x :: xs) with (filter' p xs)
| (_ ** xs') = if (p x) then (_ ** x :: xs') else (_ ** xs')
{-
When elaborating right hand side of Main.filter':
Can't convert
Int
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
import Foreign.C.Types
import Control.Monad (when)
main :: IO ()
main = loop 10
where
loop n = when (n > 0) $ do
putStr $ "loop #" ++ show n ++ ": "
@maoe
maoe / command.rb
Created October 28, 2013 04:43
Run an external command and stream the output in a timely manner
def command(cmd, &block)
puts "Running #{cmd}"
PTY.spawn(cmd) {|stdout, stdin, pid|
begin
block.yield(stdout)
rescue Errno::EIO
puts "Errno::EIO"
end
}
rescue PTY::ChildExited
@maoe
maoe / Extras.hs
Created October 24, 2013 10:36
throttle/debounce in sodium
import Control.Applicative ((<$>), (<$))
import Data.Monoid (Last(..), (<>))
import Data.Sequence ((<|))
import qualified Data.Foldable as Fold
import qualified Data.Sequence as Seq
import Data.AffineSpace (AffineSpace(..), (.-^))
import FRP.Sodium