Skip to content

Instantly share code, notes, and snippets.

View iconara's full-sized avatar
🤖

Theo iconara

🤖
View GitHub Profile
@iconara
iconara / keybase.md
Created March 7, 2014 13:58
Keybase proof

Keybase proof

I hereby claim:

  • I am iconara on github.
  • I am iconara (https://keybase.io/iconara) on keybase.
  • I have a public key whose fingerprint is 89E2 D758 F1B0 5851 90C3 AB85 3DD6 2FEB B09D 0BF2

To claim this, I am signing this object:

@iconara
iconara / restart_es
Created February 25, 2014 10:54
Restart an ElasticSearch node
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": true}}'
sudo service elasticsearch restart
# ... wait for the host to start ...
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": false}}'
@iconara
iconara / homebrew.mxcl.zookeeper.plist
Created February 19, 2014 09:59
ZooKeeper Homebrew launchd config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
@iconara
iconara / config.ru
Last active August 29, 2015 13:56
Bypass Grape and Rack::Response's response materialization
require 'grape'
class ResponseHijack
BODY_KEY = 'response_hijack.body'.freeze
CONTENT_TYPE_KEY = 'response_hijack.content_type'.freeze
def initialize(app)
@app = app
end
@iconara
iconara / profile_json_to_dot.rb
Last active February 2, 2016 21:39
Convert a JRuby JSON profile to a call tree graph (see second file for usage).
require 'json'
require 'set'
class ProfileConverter
def initialize(profile, io=$stdout, time_threshold=0.01)
@profile = profile
@io = io
@time_threshold = time_threshold
end
@iconara
iconara / full-log-402.log
Last active December 31, 2015 01:59
Assertion errors from /var/log/cassandra/system.log (three node cluster running DCE Cassandra 2.0.2 on EC2 m1.xlarge, two nodes failed with these errors at roughly the same time). The application uses cql-rb as a driver and was using Snappy compression at the time. We had started using compression about two hours before this happened. Restarting…
INFO [FlushWriter:5624] 2013-12-11 19:23:05,972 Memtable.java (line 366) Completed flushing /media/ephemeral0/cassandra/data/system/compactions_in_progress/system-compactions_in_progress-jb-30877-Data.db (176 bytes) for commitlog position ReplayPosition(segmentId=1385401494930, position=18377928)
INFO [CompactionExecutor:21719] 2013-12-11 19:23:05,974 CompactionTask.java (line 115) Compacting [SSTableReader(path='/media/ephemeral0/cassandra/data/system/compactions_in_progress/system-compactions_in_progress-jb-30877-Data.db'), SSTableReader(path='/media/ephemeral0/cassandra/data/system/compactions_in_progress/system-compactions_in_progress-jb-30876-Data.db'), SSTableReader(path='/media/ephemeral0/cassandra/data/system/compactions_in_progress/system-compactions_in_progress-jb-30875-Data.db'), SSTableReader(path='/media/ephemeral0/cassandra/data/system/compactions_in_progress/system-compactions_in_progress-jb-30874-Data.db')]
INFO [CompactionExecutor:21717] 2013-12-11 19:23:05,974 CompactionTask.java (line 11
@iconara
iconara / Explanation.md
Last active December 21, 2015 20:39
Pure Ruby MessagePack decoding speed

For fun I'm writing a MessagePack encoder/decoder in pure Ruby to see how close to the speed of the native C and Java implementations I can get. Currently it's just 20% slower than the native C extension for decoding (haven't implemented encoding yet), and twice as slow as native Java, when running in the latest Java 1.7.

Below are some benchmarks run in both MRI and JRuby, comparing the native decoders for both platforms with my pure Ruby implementation with and without InvokeDynamic in JRuby.

The MessagePack decoder code is here: https://github.com/iconara/msgpack-pure-ruby/blob/647bcf74f8b059e5e31cc620f81eeb39b73393a4/lib/msgpack.rb

The benchmark code is here: https://github.com/iconara/msgpack-pure-ruby/blob/647bcf74f8b059e5e31cc620f81eeb39b73393a4/spec/benchmark.rb

The benchmark outputs start with the output of java -version and then runs a series of benchmarks with one million repetitions of decoding the same chunk of bytes. The lines beginning with * show the Ruby version used and additional in

@iconara
iconara / start_cluster.sh
Last active December 12, 2015 10:39
Script that starts a local RabbitMQ cluster, tested with 2.7, 2.8 and 3.0
#!/bin/bash
# Usage: clusterctl start|stop
#
# Launches a local RabbitMQ cluster
#
# The name returned by `hostname -s` must resolve to 127.0.0.1
CLUSTER_SIZE=4
NODENAME_PREFIX='rmq'
class MyHandler
include Webbit::HttpHandler
def handleHttpRequest(request, response, control)
request.content("I'm a teapot").status(418).end
end
end
class Server
def run
@iconara
iconara / haproxy.rb
Created November 2, 2012 14:47
Start spot instances
require 'aws'
require 'pry'
require 'open-uri'
require 'base64'
class Starter
def initialize(ec2)
@ec2 = ec2
end