Skip to content

Instantly share code, notes, and snippets.

View goggin13's full-sized avatar

Matt Goggin goggin13

  • Braintree
  • Ithaca NY
View GitHub Profile
@goggin13
goggin13 / test_caching.rb
Last active December 10, 2015 20:38
A demo of some code I wrote to ensure cached values were being flushed appropriately.
# in spec_helper.rb
# Verify that the cache_busters bust the cache of the given method.
#
# * method is the name of the method we are testing (for RSpec output)
# * cache_busters is a hash of labels => procs which should result in
# in the cache being flushed
#
# Please set these variables in specs which will be using this function:
# @cached_function : a proc which executes the code to populate the cache
@goggin13
goggin13 / micro_post_spec.rb
Created February 5, 2013 21:32
This RSpec file should live at `spec/models/micro_post_spec.rb`. Your first assignment is to create the new MicroPost model, and to write the validations to make this spec pass.
require 'spec_helper'
describe MicroPost do
before do
@micro_post = MicroPost.new(user_id: 1,
content: "hello world")
end
describe "with valid attributes" do
@goggin13
goggin13 / rename_micro_post.rb
Last active December 13, 2015 16:48
Rename a model named Micropost to one named MicroPost for our INFO 2310 class
def replace_in_file(path, str, replacement)
puts "replacing #{str} with #{replacement} in #{path}"
contents = File.read(path)
File.write(path, contents.gsub(str, replacement))
end
def do_cmd(cmd)
puts cmd
`#{cmd}`
@goggin13
goggin13 / gist:5129352
Last active December 14, 2015 18:29
config file for a sample Ruby program
0:ec2-23-20-57-177.compute-1.amazonaws.com:4000
1:ec2-54-242-170-99.compute-1.amazonaws.com:4001
2:ec2-50-16-152-175.compute-1.amazonaws.com:4002
3:ec2-23-22-127-206.compute-1.amazonaws.com:4003
4:ec2-54-234-28-68.compute-1.amazonaws.com:4004
5:ec2-54-234-225-86.compute-1.amazonaws.com:4005
6:ec2-184-72-181-60.compute-1.amazonaws.com:4006
7:ec2-54-234-216-76.compute-1.amazonaws.com:4007
select
payment_instrument_detail_type,
M.company_name,
M.public_id,
merchant_fk,
count(*)
from gateway_production.transactions T
inner join gateway_production.merchants M ON
T.merchant_fk = M.pk
where
[{
"question": "A flashing red traffic light signifies that a driver should do what?",
"A": "stop",
"B": "speed up",
"C": "proceed with caution",
"D": "honk the horn",
"answer": "A"
}, {
"question": "A knish is traditionally stuffed with what filling?",
"A": "potato",