Skip to content

Instantly share code, notes, and snippets.

@jamescway
jamescway / gist:6208456
Created August 12, 2013 05:37
graph things
# A B C
# B C E
# C G
# D A F
# E F
# F H
require 'rgl/adjacency'
require 'rgl/traversal'
require 'rgl/dot'
require 'test/unit'
@jamescway
jamescway / gist:7729502
Created December 1, 2013 07:21
kata2-erlang
-module(kata2).
-export([chop/0, chop/2]).
% http://stackoverflow.com/questions/1035655/list-is-conceived-as-integer-by-length-function
chop() -> chop(6,[2,4,6,8,10]).
chop(Result) -> io:format("Location index... ~w~n", [Result-1]).
chop(Val, List) ->
if List == [] ->
-1;
@jamescway
jamescway / gist:8755800
Last active August 29, 2015 13:55
redis startup script
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@jamescway
jamescway / gist:9406983
Last active August 29, 2015 13:57
rails 2 utf-8
if Rails::VERSION::MAJOR == 2
require "active_support/core_ext/string/output_safety"
class ERB
module Util
# see https://github.com/rails/rails/issues/7430
def html_escape(s)
s = s.to_s
if s.html_safe?
s
def get_interface(tdb_id, server)
Decom.log.debug "Finding eth0 interface"
eth0_interface = server['interfaces'].find{|interface| interface['name'] == 'eth0' }; Decom.log.debug "server eth0 interface: #{eth0_interface.inspect}"
eth0_interface = thingsdb["interfaces/#{eth0_interface['id']}"].get; Decom.log.debug "eth0 interface: #{eth0_interface.inspect}"
eth0_interface
end
@jamescway
jamescway / gist:f7c8a9e7cb1ce4c8458b
Created December 4, 2014 16:23
kafkaReceiver put into main.scala
import com.twitter.zipkin.gen.{Span => ThriftSpan}
import com.twitter.finagle.stats.StatsReceiver
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
import com.twitter.zipkin.cassandra.CassieSpanStoreFactory
import com.twitter.zipkin.collector.{SpanReceiver, ZipkinQueuedCollectorFactory}
import com.twitter.zipkin.common._
import com.twitter.zipkin.receiver.kafka.KafkaSpanReceiverFactory
import com.twitter.zipkin.storage.WriteSpanStore
import com.twitter.zipkin.zookeeper.ZooKeeperClientFactory
/zipkin|master:bin/collector
[info] Loading project definition from /Users/jway/code/zipkin/project
[warn] Multiple resolvers having different access mechanism configured with same name 'local'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).
[info] Set current project to zipkin (in build file:/Users/jway/code/zipkin/)
[info] Set current project to zipkin-collector-service (in build file:/Users/jway/code/zipkin/)
[info] Writing build properties to: /Users/jway/code/zipkin/zipkin-collector-service/target/resource_managed/main/com/twitter/zipkin/build.properties
[error] I 1204 16:31:37.815 THREAD1 org.apache.zookeeper.Environment.logEnv: Client environment:user.dir=/Users/jway/code/zipkin
[error] I 1204 16:31:37.816 THREAD1 org.apache.zookeeper.ZooKeeper.<init>: Initiating client connection, connectString=localhost:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@19b27f92
[error] I 1204 16:31:42.918 THREAD43 org.apache.zookeeper.Clien
@jamescway
jamescway / statsdreceiver.scala
Created January 13, 2015 21:55
Finagle Statsd receiver
//https://groups.google.com/forum/#!topic/finaglers/0g2ySTVtZsg
import com.twitter.finagle.stats.{Counter, Gauge, Stat, StatsReceiver}
/**
* Created by mmlac on 8/13/14.
*/
class StatsDStatsReceiver extends StatsReceiver {
override val repr: AnyRef = this
From: /Users/jway/code/faraday-zipkin/lib/faraday-zipkin/trace_headers.rb @ line 53 Faraday::Zipkin::TraceHeaders#call:
48: trace_id = ::Trace.id
49: ::Trace.push(trace_id.next_id)
50: B3_HEADERS.each do |method, header|
51: Pry.config.input = STDIN
52: Pry.config.output = STDOUT
=> 53: binding.pry
54: env[:request_headers][header] = ::Trace.id.send(method).to_s
55: end
Fix Leader election Problems
[Note] this method may work every time
[Note] this was initially caused by deleting the kafka hosts and reprovisioning
delete the topic using zkCli.sh
rmr /brokers/topics/test2
sudo service kafka restart (on all the broker hosts using rundeck)
change to a different topic in your producer
you might see the number of LeaderNotAvailableException go down, maybe its doing some kind of replication here
at this point the consumer should be able to get messages and if u produce more, it should have fewer exceptions or 0