This file contains 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
# we want to test that a simple echo service has a message containing | |
# the IP we connect with. | |
function cleanup { | |
echo "cleanup" | |
echo "echo: $echo_pid" | |
echo "gk: $gatekeeper_pid" | |
(($echo_pid)) && kill $echo_pid; |
This file contains 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
A grade school teacher was asking students what their parents did for a living. "Tim, you be first," she said. "What does your mother do all day?" Tim stood up and proudly said, "She's a doctor." "That's wonderful. How about you, Amie?" Amie shyly stood up, scuffed her feet and said, "My father is a mailman." "Thank you, Amie," said the teacher. "What about your father, Billy?" Billy proudly stood up and announced, "My daddy plays piano in a whore-house." The teacher was aghast and promptly changed the subject to geography. Later that day, she went to Billy's house and rang the bell. Billy's father answered the door. The teacher explained what his son had said and demanded an explanation. Billy's father said, "I'm actually an attorney. How can I explain a thing like that to a seven-year-old?" |
This file contains 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
do a <- actionA | |
b <- actionB | |
c <- actionC | |
return (final a b c) | |
=> | |
final <$> actionA <*> actionB <*> actionC |
This file contains 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
whileJust :: Monad m => (b -> m (Maybe b)) -> b -> m b | |
whileJust action seed = action seed >>= maybe (return seed) (whileJust action) |
This file contains 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
require 'rzmq_brokers' | |
require 'ffi-rzmq' | |
log_transport = "inproc://reactor_log" | |
load 'config.rb' | |
class RunBroker | |
def initialize(master_context, log_transport, broker_endpoint) | |
@broker_config = RzmqBrokers::Broker::Configuration.new do | |
name 'broker-reactor' | |
exception_handler nil |
This file contains 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
require 'rubygems' | |
require 'rzmq_brokers' | |
class DBMessage | |
def self.create_from(worker, message) | |
if message.request? | |
LookupRequest.from_message(worker, message) | |
elsif message.success_reply? | |
LookupReplySuccess.from_message(message) | |
elsif message.failure_reply? |
This file contains 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
#include <czmq.h> | |
#include <stdio.h> | |
void asend(char * t, void * s) { | |
zmsg_t * msg = zmsg_new(); | |
zmsg_pushstr(msg,t); | |
zmsg_send(&msg,s); | |
} | |
void change_options(void * cvoid, zctx_t * ctx, void * pipe) { | |
puts("forked\n"); |
This file contains 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
module DateAndTime(DateData(..), rulemap) where | |
import Control.Concurrent(forkIO, threadDelay, ThreadId) | |
import Control.Monad(forever) | |
import Types | |
import qualified Data.ByteString.Char8 as BS | |
data Date = Date | |
data PeriodData = PeriodData { seconds :: Int } | |
data DateData = DateData { time :: Date } |
This file contains 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 TemplateHaskell, OverloadedStrings #-} | |
import Data.MessagePack | |
import qualified Data.ByteString.Lazy.Char8 as L | |
data OauthData = OauthData { key :: L.ByteString, | |
secret :: L.ByteString } | |
deriving(Show) | |
data Fake = Fake L.ByteString | |
deriving(Show) | |
deriveObject True ''OauthData |
This file contains 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
-- | |
-- Would you belive there was no way to create a token other than to do the full | |
-- authentication process in hoauth? This just creates value of type 'Token' for | |
-- this package from some strings. | |
-- | |
createToken :: T.Consumer -> OAuthTokenAndSecret -> O.Token | |
createToken c (OAuthTokenAndSecret token secret) = AccessToken app tokFields | |
where | |
app = Application (T.key c) (T.secret c) OOB | |
tokFields = R.fromList [ ("oauth_token", token), ("oauth_token_secret", secret) ] |