Skip to content

Instantly share code, notes, and snippets.

Aaron Graves agraves

Block or report user

Report or block agraves

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test.rb
# implicit
class ErrorReporter
def active?
Rails.environment.production?
end
end
Rails.environment.stub :production?, true do
assert ErrorReporter.active?
end
@agraves
agraves / gist:669c78761d5534c867ad
Last active Aug 29, 2015
Opened a can of whoop ass
View gist:669c78761d5534c867ad
Had a dream last night, uncle greg was being attacked by the wire fence behind gramp's
house in the dark by two fierce raccoons. Clung around his upper body, they were bitting
him repeatedly around hischest and head. Suddenly, in rushes three year old Aaron, like
little Yoda...he stealthy climbs up greg's body and sits up behind his head, reaching down,
he grabs each raccoon's head and quickly breaks their necks..the scene quickly falls away....
but you were left on the other side of the fence, I screamed, Come on, Aaron!! You can make it!!!"
You easily maneuver up the fence to the other side and I thought..."I guess a trip to the
hospital and two rabid shots are in order." Crazy dream...but I was wicked proud of you.
https://www.youtube.com/watch?v=NzcWQZ3yrNo
@agraves
agraves / instructions
Last active Aug 29, 2015
Remove expired digicert certs
View instructions
Instructions for clearing expired DigiCert SSL certificate on OSX
NOTICE: The following instructions "worked for me." Proceed at your own risk.
Symptoms:
* Visiting several sites, such as github, gravatar, twitter's CDN results in "invalid certificate" errors
* For example: http://i.imgur.com/8gPRfI3.png
Instructions
@agraves
agraves / gist:8605608
Created Jan 24, 2014
Tea starter kit
View gist:8605608
Tea Strainer - 9$ - https://www.harney.com/permanent-tea-filters.html
Black Tea - 6.25$/4oz - https://www.harney.com/irish-breakfast-tea.html
Green Tea - 12$/4oz - https://www.harney.com/japanese-sencha.html
Brew the Green for ~2 minutes in less than boiling water, no milk, maybe a little sugar. As for the black tea, 4 minutes, boiling water, milk & sugar.
View gist:5086657
ruby '1.9.3'
def local_group(*g, &block)
on_heroku = (ENV['HOME'].gsub('/','') == 'app')
if on_heroku
group(:test, &block)
else
group(*g, &block)
end
@agraves
agraves / gist:4772621
Created Feb 12, 2013
Trying to write platform-independent case-insensitive email search (without wildcards). Is this really the best way to do this?
View gist:4772621
email = 'you@yours.com'.gsub('%', '')
users = User.arel_table
User.find_by_sql(
users.
project(:id).
where(users[:email].matches email).
to_sql
).first
@agraves
agraves / user_search.rb
Created Feb 11, 2013
UserSearch refactor
View user_search.rb
class UserSearch
def self.search(term, topic_id = nil)
scope = User.scoped
if topic_id
scope = scope.joins("
LEFT JOIN (
SELECT DISTINCT(posts.user_id)
FROM posts
WHERE topic_id = #{topic_id.to_i}
View gist:4698596
1.9.3p327 :048 > t = User.new
=> #<User id: nil, name: nil, some_bool: nil, created_at: nil, updated_at: nil>
1.9.3p327 :049 > t.some_bool = 'a string'
=> "a string"
1.9.3p327 :050 > t.some_bool
=> false
View 20121101180136_implement_mongo.rb
class ImplementMongo < ActiveRecord::Migration
def change
create_table :mongo do |t|
t.string :key
t.text :value
end
end
end
@agraves
agraves / pages_controller_test.rb
Created Oct 9, 2012
Minitest controller test with clearance
View pages_controller_test.rb
require 'test_helper'
describe PagesController do
before{ sign_in }
subject{ PagesController.new }
%w{some_page another_page}.each do |page|
describe "rendering the #{page} page" do
it 'should render successfully' do
You can’t perform that action at this time.