Skip to content

Instantly share code, notes, and snippets.

View zsol's full-sized avatar

Zsolt Dollenstein zsol

View GitHub Profile
@zsol
zsol / fcat.hs
Last active December 21, 2015 13:28
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Time
import System.Exit
import System.IO.Error
import System.Locale
format :: String
format = "%Y-%m-%d %H:%M:%S,%q"
@zsol
zsol / Memo.hs
Created February 14, 2013 08:20
{-
you need the memoize cabal package to use this.
http://hackage.haskell.org/package/memoize-0.3
-}
import System.IO.Unsafe
import System.Posix.Files
import System.Posix.Types
import Data.Function.Memoize
import Debug.Trace
@zsol
zsol / Sum.hs
Last active December 12, 2015 08:08
Sums its arguments and also prints them in order
#!/usr/bin/env runghc
import System.Environment
import Control.Monad.Writer
import Control.Applicative
mySum :: (Num a, Show a) => [a] -> Writer [String] a
mySum [] = return 0
mySum (x:xs) = censor ((show x):) ((x+) <$> mySum xs)
main = do
{-# LANGUAGE GeneralizedNewtypeDeriving, GADTs, StandaloneDeriving #-}
import Control.Monad.Identity
import Control.Monad.Reader
import Control.Monad.Writer
import Control.Monad.Error
import Control.Applicative
import Data.Map
import Prelude hiding (lookup, log)
type Name = String
require 'formula'
class GtkMacIntegration < Formula
homepage 'https://live.gnome.org/GTK+/OSX'
url 'ftp://ftp.gnome.org/pub/gnome/sources/gtk-mac-integration/2.0/gtk-mac-integration-2.0.1.tar.xz'
version '2.0.1'
sha1 '9d939a2e4fb6c0ab4fe3d544ac712a152451249a'
head 'git://git.gnome.org/gtk-mac-integration'
depends_on 'pkg-config' => :build
@zsol
zsol / gist:4265895
Created December 12, 2012 07:49
unbounded queue based communication between producer and several consumers in haskell
-- tst
import Control.Concurrent.Chan
import Control.Concurrent
import Control.Exception (finally)
import System.IO.Unsafe (unsafePerformIO)
type Result = Int
execute_pig::String-> IO Result
@zsol
zsol / producer
Created October 9, 2012 20:32
carbon with 1s resolution
while true; do
echo "hlogster.test.count $i $(date +%s)" | /opt/graphite/bin/carbon-client.py localhost:2003:a;
echo $i
i=$((i+1))
i=$((i%10))
sleep 1
done
@zsol
zsol / gist:3682934
Created September 9, 2012 06:20
script to check for kafka consumer lag
from kazoo.client import KazooClient
config = {
'consumer_group': '<%= @consumer_group %>',
'topic': '<%= @topic %>'
}
def main():
zk = KazooClient()
zk.start()
@zsol
zsol / gist:3397650
Created August 19, 2012 20:51
PSQueue stack overflow
import Data.PSQueue
data Element = E Int String deriving (Show)
type Buffer = PSQ Int Element
instance Eq Element where
(E a _) == (E b _) = a == b
instance Ord Element where
(E a _) < (E b _) = a < b
{badmatch,
{error,
{{{function_clause,
[{rabbit_queue_index,journal_minus_segment1,
[{no_pub,del,ack},undefined]},
{rabbit_queue_index,'-journal_minus_segment/2-fun-0-',4},
{array,sparse_foldl_3,7},
{array,sparse_foldl_2,9},
{rabbit_queue_index,'-recover_journal/1-fun-0-',1},
{dict,map_bucket,2},