Skip to content

Instantly share code, notes, and snippets.

auto socket_ = TAsyncSocket::newSocket(ev_, super::address());
std::shared_ptr<HeaderClientChannel> channel
= HeaderClientChannel::newChannel(socket_);
auto client_ = std::make_shared<ClientType>(channel);
@bigs
bigs / state.scala
Created June 22, 2015 18:07
state monad in scala?????
case class State[S, A](runState: S => (A, S)) {
def flatMap[B](f: A => State[S, B]): State[S, B] = State({
s: S =>
val (res, s1) = runState(s)
f(res).runState(s1)
})
def >>=[B](f: A => State[S, B]): State[S, B] = flatMap(f)
def >>[B](f: State[S, B]): State[S, B] = flatMap({ _ => f })
#!/bin/bash
concord kill --zookeeper-hosts localhost:2181 --zookeeper-path /bolt --task-id $1
#pragma once
#include <chrono>
#include <concord/time_utils.hpp>
namespace bolt {
class SnowflakeWorker {
public:
SnowflakeWorker(const uint8_t datacenterId, const uint8_t workerId)
: datacenterId_(datacenterId), workerId_(workerId) {}
@bigs
bigs / pubsub.thrift
Last active November 17, 2015 20:11
// feel free to add a `namespace` annotation here for your chosen language
namespace py concord.pubsub
namespace rb Concord.PubSub
namespace cpp concord.pubsub
namespace java concord.pubsub
service PubSubBroker {
// subscribe / unsubscribe a new consumer to a topic
void subscribe(1:string topic, 2:string host, 3:i32 port);
void unsubscribe(1:string topic, 2:string host, 3:i32 port);
usage: mediachain [-h] {ingest,list,get,history,revise,works,config} ...
Mediachain CLI
positional arguments:
{ingest,list,get,history,revise,works,config}
Mediachain subcommands
ingest Ingest a dataset
list List canonical IDs in the system
get Get the data for a canonical
bigs@mako:~/code/L-SPACE$ mediachain history 3fab9a8b-570d-47df-9157-6fd2cf94a5e5
{
"canonicalID":"3fab9a8b-570d-47df-9157-6fd2cf94a5e5",
"revisions":[
{
"signatures":{},
"description":"Photograph, gelatin silver print on paper",
"title":"Hy\u00e8res, France",
"author":{
"external_ids":{},
// pulse threshold (v)
Param threshold(1.5);
// clock mul (pos) or div (neg) factor
Param factor(1);
History last(0.);
History ticks(0.);
History childTicks(0.);
History clockLength(0.);
History childClockLength(0.);
#lang racket
(define miLRco
(lambda (new oldL oldR lat col)
(cond
((null? lat)
(col '() 0 0))
((eq? (car lat) oldL)
(miLRco new oldL oldR
(cdr lat)