This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from microbit import * | |
import random | |
import radio | |
bss = [0, 1, 2] | |
score = 0 | |
radio.on() | |
radio.config( | |
power=4, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Main where | |
-------------------------------------------------------------------------------- | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Concurrent.Chan | |
import Control.Concurrent.Extra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
{- stack | |
--resolver nightly | |
--install-ghc | |
runghc | |
--package bloodhound | |
--package optparse-applicative | |
-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE OverloadedStrings #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f() | |
{ | |
if (p) | |
{ | |
// do something | |
} | |
else | |
{ | |
// do something else | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~~~~ | |
filter { | |
mutate { | |
add_field => { "[@metadata][target_index]" => "logstash-%{+YYYY.MM.dd}" } | |
} | |
if [program] == "jube" { | |
mutate { | |
update => { "[@metadata][target_index]" => "longterm-%{+YYYY.Q}" } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class A(object): | |
def f(self, a): | |
print a | |
def g(self, b, ff=A.f): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder