Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Georges itkovian

View GitHub Profile
View m.hs
messageSink success failure messageCount frequency = loop
where
loop = do
v <- await
case v of
Just n -> case n of
Right json -> do
Data.Conduit.yield (encodeNormalisedRsyslog json) $$ success
Data.Conduit.yield (SBS.pack "\n") $$ success
liftIO $ increaseCount (1, 0) messageCount frequency
View prs.py
from microbit import *
import random
import radio
bss = [0, 1, 2]
score = 0
radio.on()
radio.config(
power=4,
View Main.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Main where
--------------------------------------------------------------------------------
import Control.Applicative ((<$>), (<*>))
import Control.Concurrent.Chan
import Control.Concurrent.Extra
View gist:6ae1328a0933cfc32dc873a022eb26cb
handler :: MVar Int -> IO ()
handler s_interrupted = trace "Interrupt received" $ do
r <- readMVar s_interrupted
trace ("value was " ++ show r) $ modifyMVar_ s_interrupted (return . (+1))
{- this prints on the first SIGTERM:
Interrupt received
value was 0
@itkovian
itkovian / gpfs-get-inode-usage.hs
Created May 31, 2017
Retrieve inode usage for VO filesets from Elasticsearch and print out the relevant usage information
View gpfs-get-inode-usage.hs
#!/usr/bin/env stack
{- stack
--resolver nightly
--install-ghc
runghc
--package bloodhound
--package optparse-applicative
-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
View Aaaargh
f()
{
if (p)
{
// do something
}
else
{
// do something else
}
View gist:ae833bf62dbbcc8ba2ad
~~~~
filter {
mutate {
add_field => { "[@metadata][target_index]" => "logstash-%{+YYYY.MM.dd}" }
}
if [program] == "jube" {
mutate {
update => { "[@metadata][target_index]" => "longterm-%{+YYYY.Q}" }
}
}
View gist:7769327
#!/usr/bin/env python
class A(object):
def f(self, a):
print a
def g(self, b, ff=A.f):
View gist:7197243
Code:
_log.debug("prefix = %s, rndm = %s", prefix, rndm)
s = os.path.join(prefix, rndm[0], rndm[0:2], rndm, filename)
_log.debug("resulting string s = %s", s)
Output:
prefix = pubkey, rndm = 9gksLuHlOVGIleV6gjLk
View gist:5143640
import qualified Data.Map as M
import Data.Monoid
data MMap k a = MMap (M.Map k a)
instance (Ord k, Monoid a) => Monoid (MMap k a) where
mempty = MMap M.empty
(MMap m1) `mappend` (MMap m2) = MMap (M.unionWith mappend m1 m2)
You can’t perform that action at this time.