Skip to content

Instantly share code, notes, and snippets.

View matthuhiggins's full-sized avatar

Matthew Higgins matthuhiggins

View GitHub Profile
@matthuhiggins
matthuhiggins / hash.rb
Created December 25, 2010 02:16
ruby 1.9 hash
sweet_hash = {
foo: "bar",
faz: "baz"
}
@matthuhiggins
matthuhiggins / Questions
Created August 8, 2011 23:46
Frozen Rails Give-away
Day job: Web/Mobile Developer @ GoTime
Your Rails contributions: Gems https://rubygems.org/profiles/2519
What's your Ruby/Rail experience?: 4 years, working almost always with Rails.
How do you use GitHub?: Private hosting for work and public hosting for open source
require 'uri'
require 'net/http'
require 'net/https'
module Curl
class Easy
attr_accessor :uri, :headers, :follow_location, :max_redirects
attr_accessor :response, :redirect_count
def initialize
if ARGV.size != 2
puts "usage: cassandra_tokens.py <current_size> <new_size>"
exit
end
CURRENT_NODES = ARGV[0].to_i
GOING_TO_NODES = ARGV[1].to_i
RING_SIZE = 2**127
def tokens(node_count)
@matthuhiggins
matthuhiggins / gist:1998191
Created March 8, 2012 02:38
delayed query
function SearchPlaces(inputSelector) {
var input = $(inputSelector).hintInput(),
baseUrl = input.attr('data-source');
function currentQuery() {
if (input.hasClass('empty')) {
return '';
} else {
return input.val();
}
@matthuhiggins
matthuhiggins / braintree.rb
Created April 13, 2012 16:10
Using Object#tap to create scopes
Braintree::Configuration.tap do |config|
if settings = YAML.load_file(Rails.root.join('config', 'braintree.yml'))[Rails.env]
config.environment = :sandbox
config.merchant_id = settings['merchant_id']
config.public_key = settings['public_key']
config.private_key = settings['private_key']
end
end
@matthuhiggins
matthuhiggins / Gemfile
Created May 29, 2012 21:43
cassandra interaction
source "http://rubygems.org"
gem 'mcmire-cassandra', require: 'cassandra/1.0'
@matthuhiggins
matthuhiggins / setup_teardown.rb
Created June 12, 2012 22:37
test time tracker
@@test_classes = {}
@@test_methods = {}
setup do
@start_time = Time.now
end
teardown do
delta = Time.now - @start_time
@matthuhiggins
matthuhiggins / Gunfile
Created May 11, 2013 22:27
Hello World, Gunner
p "Hello world"
@matthuhiggins
matthuhiggins / bad.rb
Created June 11, 2013 19:19
ElasticSearch scroll responses
{
"_scroll_id"=>"c2NhbjsxOzc4NjprWFFSS01qU1JOYXVmZ3MxN0dYQVVROzE7dG90YWxfaGl0czozOw==",
"took"=>2,
"timed_out"=>false,
"_shards"=>{
"total"=>5,
"successful"=>2,
"failed"=>3,
"failures"=>[
{"status"=>500, "reason"=>"SearchContextMissingException[No search context found for id [784]]"}, {"status"=>500, "reason"=>"SearchContextMissingException[No search context found for id [787]]"},