Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
dallasmarlow / gist:3763952
Created September 21, 2012 21:17
collect instance variables
def collect_instance_variables object
values = object.instance_variables.collect do |variable|
object.instance_variable_get variable.to_s
end
Hash[object.instance_variables.zip(values)]
end
@dallasmarlow
dallasmarlow / gist:3934017
Created October 22, 2012 20:38
consistent mysql server-id values based on mac address
# convert the last 4 octets of a mac address to base 10 for a numeric value between 0-4294967295 (which is the supported range for mysql's server-id)
# example mac address - "00:26:9E:2B:C7:36"
mac_address.split(':')[2..5].join.to_i(16)
# => 2653669174
#!/usr/bin/env ruby
%w[logger thread json collins_client highline/import file-tail zk].each {|l| require l}
# simple daemon to tail the act_post giant octopus log and create znodes for blogs and posts being created
class ZookeeperActPost
attr_reader :options, :collins, :log, :zk
def initialize options = {}
@options = {
log: STDOUT,
@dallasmarlow
dallasmarlow / gist:4435743
Created January 2, 2013 16:17
check a zookeeper quorum size from jmx
require 'java'
import javax.management.ObjectName
import javax.management.remote.JMXServiceURL
import javax.management.remote.JMXConnectorFactory
host = "zk-a835862a.tld"
port = 10010
config = {
require 'faker'
File.open('lorem.txt', 'w') do |file|
(10 ** 6).times do |i|
file.puts Faker::Lorem.sentence(10 ** 4)
puts i
end
end
@dallasmarlow
dallasmarlow / JSTN.css
Last active December 12, 2015 02:28 — forked from jstn/JSTN.css
/*
JSTN THEME FOR LIMECHAT 1.0
put this and the other thing in ~/Library/Application Support/LimeChat/Themes/
bg 1a2230
hlight 273146
red e44347
purps 8b84d0
fuscia c2339a
#!/usr/bin/env tumblr_ruby
require 'nrpe_check/extend'
require 'timeout'
require 'json'
@options = {
timeout: 120, # seconds
hbck_command: 'hbase hbck 2>/dev/null',
@dallasmarlow
dallasmarlow / check_hbase.rb
Last active December 17, 2015 11:49
hbck nagios check
#!/usr/bin/env tumblr_ruby
require 'zk'
require 'json'
require 'logger'
require 'socket'
require 'timeout'
require 'nrpe_check'
class CheckHBase
include NRPE::Check
@dallasmarlow
dallasmarlow / gist:5701763
Created June 3, 2013 21:51
class instance state hash
def instance_state_hash
self.instance_variables.map do |instance_variable|
self.instance_variable_get instance_variable.to_s.sub ':', '@'
end.hash
end
# plugins, recipes, clusters, etc
Dir['lib/*', 'recipes/*', 'config/groups/*'].each {|plugin| load plugin}
# default settings
load 'config/settings'