Skip to content

Instantly share code, notes, and snippets.

View titanous's full-sized avatar

Jonathan Rudenberg titanous

View GitHub Profile
@titanous
titanous / splunk.rb
Created November 7, 2011 20:52
Splunk search API client
require 'httparty'
class Splunk
include HTTParty
base_uri 'https://YOUR_SPLUNK_SERVER:8089/services'
def initialize(username, password)
@auth = { :username => username, :password => password }
end
def encode_hash(hash)
hash.map { |k,v| [k, encode(v)] }
end
def decode_hash(hash)
Hash[hash.map { |k,v| [k, decode(v)] }]
end
def hgetall(key)
decode_hash redis.hgetall(key)
@titanous
titanous / gist:1273058
Created October 8, 2011 23:32
Quick fix for tropo-agitate
%w(rubygems yaml socket json net/http uri).each { |lib| require lib }
#####
# This Ruby Script Emulates the Asterisk Gateway Interface (AGI)
# VERSION = '0.2.0'
#####
# We patch the Hash class to symbolize our keys
class Hash
def symbolize_keys
inject({}) do |options, (key, value)|
@titanous
titanous / 0-readme.md
Created October 7, 2011 16:20
Ruby 1.9.3-p0 with ruby-debug19

Ruby 1.9.3-p0 with ruby-debug19

Ruby 1.9.3-p0 requires a minor patch to make ruby-debug19 work. If you have ruby-build and rbenv installed, these scripts will install ruby-1.9.3-p0.

curl https://raw.github.com/gist/1270704/install-ruby-1.9.3-p0.sh | sh
user system total real
BERT int encode 0.010000 0.000000 0.010000 ( 0.013525)
MessagePack int encode 0.000000 0.000000 0.000000 ( 0.000396)
Yajl int encode 0.010000 0.000000 0.010000 ( 0.002894)
BERT int decode 0.000000 0.000000 0.000000 ( 0.000346)
MessagePack int decode 0.000000 0.000000 0.000000 ( 0.000336)
Yajl int decode 0.010000 0.000000 0.010000 ( 0.001949)
BERT array encode 8.010000 0.010000 8.020000 ( 8.022767)
MessagePack array encode 0.060000 0.000000 0.060000 ( 0.063025)
Yajl array encode 0.170000 0.000000 0.170000 ( 0.169183)
require 'benchmark'
module Arel
module Nodes
class Ordering
end
end
end
def old_reverse_sql_order(order_query)
def days_in_month(n)
if n == 2 then 28
elsif [4,6,9,11].include?(n) then 30
else 31
end
end
#!/bin/sh
git checkout master
git fetch mainline
git rebase mainline/master
git checkout production
git merge mainline/production
git merge master
git push mainline production
git checkout master
/*
* Generated by class-dump 3.3.3 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2010 by Steve Nygard.
*/
#pragma mark -
/*
* File: /System/Library/PrivateFrameworks/ApplePushService.framework/Versions/A/ApplePushService
/*
* Generated by class-dump 3.3.3 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2010 by Steve Nygard.
*/
#pragma mark -
/*
* File: /System/Library/PrivateFrameworks/ApplePushService.framework/applepushserviced