Skip to content

Instantly share code, notes, and snippets.

@jhosteny
jhosteny / test.cpp
Created May 6, 2019 13:27
test.cpp
#include <queue>
#include <deque>
#include <mutex>
#include <condition_variable>
#include <thread>
#include <chrono>
#include <algorithm>
#include <random>
#include <functional>
#include <boost/circular_buffer.hpp>
root@stretch:/home/vagrant# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:8d:c0:4d brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0

Keybase proof

I hereby claim:

  • I am jhosteny on github.
  • I am jhosteny (https://keybase.io/jhosteny) on keybase.
  • I have a public key ASASPH7_6fDL-vjgIZdyVowHjxcw9-bSjKyQwl8z746Gxwo

To claim this, I am signing this object:

@jhosteny
jhosteny / building-a-cqrs-web-application-in-elixir-using-phoenix.md
Last active January 15, 2022 22:43
Building a CQRS/ES web application in Elixir using Phoenix

Background

I've been interested in Command Query Responsibility Segregation and event sourcing since hearing Greg Young talk on the subject in early 2010. During the past seven years I've built an open-source Ruby CQRS library (rcqrs); worked professionally on .NET applications following the pattern; and more recently built an Event Store (eventstore) and CQRS library (commanded) in Elixir.

Building applications following domain-driven design and using CQRS feels really natural with the Elixir -- and Erlang -- actor model. An aggregate root fits well within an Elixir process, which are driven by immutable messages through their own message mailboxes, allowing them to run concurrently and in isolation.

The web application I built to implement these ideas in Elixir was [Segment Challen

#import <Foundation/Foundation.h>
#import <RestKit/CoreData.h>
@interface BRAccountItem : NSManagedObject
@property (nonatomic, retain) NSString * email;
@property (nonatomic, retain) NSDate * dateCreated;
@property (nonatomic, retain) NSDate * dateUpdated;
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * phone;
@jhosteny
jhosteny / gist:2578253
Created May 2, 2012 17:04
FuseFS with celluloid
require 'fusefs'
paxosdir = DCell::Paxos::PaxosDir.new(DCell.registry.globals.root)
FuseFS.set_root(paxosdir)
# Mount under a directory given on the command line.
FuseFS.mount_under "/tmp/foobar"
FuseFS.run
diff --git a/lib/dcell/celluloid_ext.rb b/lib/dcell/celluloid_ext.rb
index ff48c94..82b4c8a 100644
--- a/lib/dcell/celluloid_ext.rb
+++ b/lib/dcell/celluloid_ext.rb
@@ -9,6 +9,50 @@
# DCell overlay network back to the node where the actor actually exists
module Celluloid
+ class << self
+ def multicall(actors, responses, timeout, &block)
# -*- coding: utf-8 -*-
require 'celluloid/io'
module Celluloid
# Error that occurs, when we recieve an broken envelope
class BrokenEnvelopeError < Exception; end
# Error that occurs, when the client tries to call an unknown service
class UnknownServiceError < Exception; end