Skip to content

Instantly share code, notes, and snippets.

View dminuoso's full-sized avatar

Victor Nawothnig dminuoso

View GitHub Profile
chunksOf :: Int -> [a] -> [[a]]
chunksOf _ [] = []
chunksOf n l = take n l : chunksOf n (drop n l)
type Pixel = [Int]
serialize :: NP.PPM -> String
serialize (NP.PPM (NP.PPMHeader t w h) img)
= unlines ( [show (maximum rgbList)
, show h
manyN :: Int -> f a -> f [a]
manyN n v = many_v n
where
many_v 0 = pure []
many_v n = some_v (n - 1) <|> pure []
some_v 0 = pure []
some_v n = liftA2 (:) v (many_v (n - 1))
import Control.Arrow ((&&&))
import Control.Monad.Trans.State.Strict
import Control.Monad
import Data.Foldable
import Data.Maybe
import qualified Data.Set as S
import Data.List
data Op = Op !Dir !Int
λ foobar master ✗ docker build .
Sending build context to Docker daemon 60.93kB
Step 1/8 : FROM haskell:8.4
---> b3e06e1d3bb7
Step 2/8 : USER root
---> Using cache
---> b21f896888c0
Step 3/8 : ADD . /app
---> 1a026c288c89
Step 4/8 : WORKDIR /app
@dminuoso
dminuoso / Sentinel.hs
Created July 20, 2018 12:28 — forked from borsboom/Sentinel.hs
hedis wrapper for Redis Sentinel support
{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, MultiParamTypeClasses, NamedFieldPuns,
NoImplicitPrelude, OverloadedStrings, RankNTypes, ScopedTypeVariables, TupleSections,
ConstraintKinds, TemplateHaskell, StandaloneDeriving #-}
{-# OPTIONS_GHC -funbox-strict-fields -Wall -Werror #-}
-- dependencies: hedis retry safe data-default uuid monad-logger basic-prelude lifted-base either
-- | Wrapper for hedis to support redis-sentinel. It is
-- built-atop of, and re-exports most of, the "Database.Redis" module.
--
class TBQueue
def initialize size
tvar = Concurrent::TVar
@read = tvar.new []
@write = tvar.new []
@rsize = tvar.new 0
@wsize = tvar.new size
end
| IdleTimeout Word32
| TerminationAction TerminationAction
| CalledStationId ByteString
| CallingStationId ByteString
| IdleTimeout Word32
| TerminationAction TerminationAction
| CalledStationId ByteString
| CallingStationId ByteString
catchesHandler :: [Handler a] -> SomeException -> IO a
catchesHandler handlers e = foldr tryHandler (throw e) handlers
where tryHandler (Handler handler) res
= case fromException e of
Just e' -> handler e'
Nothing -> res
module A where
class T a where
t :: a -> Bool
Const = Struct.new(:value) do
def fmap(*args)
-> (func) { self }.curry[*args]
end
def self.make(*args)
-> (o) { new(o) }.curry[*args]
end
end