Skip to content

Instantly share code, notes, and snippets.

Avatar

Victor Nawothnig dminuoso

View GitHub Profile
View ex.hs
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
View gist.hs
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))
View 03.hs
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
View gist:ffadea142d47d8ffa6bf092aed4907cf
λ 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 Jul 20, 2018 — forked from borsboom/Sentinel.hs
hedis wrapper for Redis Sentinel support
View Sentinel.hs
{-# 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.
--
View tbqueue.rb
class TBQueue
def initialize size
tvar = Concurrent::TVar
@read = tvar.new []
@write = tvar.new []
@rsize = tvar.new 0
@wsize = tvar.new size
end
View gist:f3e0f276935e0eef31fcee67d5a0a637
| IdleTimeout Word32
| TerminationAction TerminationAction
| CalledStationId ByteString
| CallingStationId ByteString
| IdleTimeout Word32
| TerminationAction TerminationAction
| CalledStationId ByteString
| CallingStationId ByteString
View f.hs
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
View A.hs
module A where
class T a where
t :: a -> Bool
View const.rb
Const = Struct.new(:value) do
def fmap(*args)
-> (func) { self }.curry[*args]
end
def self.make(*args)
-> (o) { new(o) }.curry[*args]
end
end
You can’t perform that action at this time.