Skip to content

Instantly share code, notes, and snippets.

module Zookeeper
class BroadcastTrigger
def initialize(zk, path)
@zk = zk
@path = path
end
def trigger
@zk.set(@path, "#{$$}")
rescue ZK::Exceptions::NoNode
Installing hitimes (1.1.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -DUSE_INSTANT_OSX=1 -Wall -c hitimes_ext.c
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -DUSE_INSTANT_OSX=1 -Wall -c hiti
@eric
eric / _scheduler.rb
Last active December 15, 2015 07:49
class Scheduler < Rufus::Scheduler::PlainScheduler
def initialize(zk, *args)
super(*args)
@zk_locker = zk.exclusive_locker('scheduler')
end
def run
@zk_locker.with_lock do
configure
@eric
eric / README.md
Last active December 17, 2015 00:39
Zookeeper-based storage adapter for rollout

Update

You can now find this packaged up nicely in a rubygem as rollout-zk.


Zookeeper storage adapter for rollout

I've implemented a zookeeper-based storage adapter for [rollout][] that does not require any network roundtrips to check if a feature is active for a user.

# from https://github.com/slyphon/zk/issues/68
require 'zk'
ZK_PATH = '/test/path/child'
CHILD_PATH = ZK_PATH + '/foo'
SLEEP_TIME = 1
class Writer
def initialize(start_signal, finish_signal)
reader: zookeeper: initiating connection to localhost:2181
reader: zookeeper: #zkc_set_running_and_notify!
reader: zookeeper: #event_thread_body starting event thread
reader: zookeeper: init returned!
reader: zookeeper: event_thread waiting until running: true
reader: zookeeper: event_thread running: true
zookeeper_server: Accepted socket connection from /fe80:0:0:0:0:0:0:1%1:54365
zookeeper_server: Accepted socket connection from /127.0.0.1:54366
zookeeper_server: Session establishment request from client /fe80:0:0:0:0:0:0:1%1:54365 client's lastZxid is 0x0
zookeeper_server: Connection request from old client /fe80:0:0:0:0:0:0:1%1:54365; will be dropped if server is in r-o mode
// Originally from:
// * http://blog.stephenboak.com/2011/08/07/easy-as-a-pie.html
// * http://jsfiddle.net/stephenboak/hYuPb/
//
// Improved by Eric Lindvall to be more d3-ish
function donutChart() {
var width = 450;
var height = 300;
var radius = 100;
@eric
eric / README.md
Last active December 21, 2015 08:09
Get graphs directly from codahale/metrics
@eric
eric / README.md
Last active December 21, 2015 20:39
Steps to get Sentry working over SSL on the JVM

Sentry and the JVM

Unfortunately Java's built-in cacerts do not include StartCom SSL root certificates.

Because of this, you must tell java to trust these certificates.

The easiest way I've found to do it is as follows:

1. Make a copy of the JRE cacerts

@eric
eric / gist:6432496
Last active December 22, 2015 06:39
(def levels {:trace org.apache.log4j.Level/TRACE
:debug org.apache.log4j.Level/DEBUG
:info org.apache.log4j.Level/INFO
:warn org.apache.log4j.Level/WARN
:error org.apache.log4j.Level/ERROR
:fatal org.apache.log4j.Level/FATAL})
(defn set-level
"Set the level for the given logger, by string name. Use:
(set-level \"skuld.node\", :debug)"