Skip to content

Instantly share code, notes, and snippets.

View RafeHatfield's full-sized avatar

Rafe Hatfield RafeHatfield

View GitHub Profile
#!/bin/bash
echo -n "GitHub User: "
read USER
echo -n "GitHub Token (2FA): "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
module Cancelerizer
def cancel arg
Sidekiq::ScheduledSet.new.each do |job|
(klass, method, args) = YAML.load job.args.first
if self == klass and args.first == arg
job.delete
end
end
end
end
require 'perftools'
TIMES = 100_000
Benchmark.bm do |bm|
bm.report 'FactoryGirl.build' do
PerfTools::CpuProfiler.start("factorygirl") do
TIMES.times { FactoryGirl.build :loans_search_form }
end
end
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
require 'spec_helper'
describe FeaturePool do
it "creates a new instance given valid attributes" do
Fabricate :feature_pool
end
it "is not valid without a name" do
Fabricate.build(:feature_pool, :name => "").should_not be_valid
end
@RafeHatfield
RafeHatfield / Gemfile
Last active December 24, 2015 10:49 — forked from cblunt/Gemfile
# ...
gem 'carrierwave'
gem 'fog'
@RafeHatfield
RafeHatfield / sunspot_sidekiq.rb
Last active December 23, 2015 20:49 — forked from nz/sunspot_resque.rb
Example to queue sunspot solr updates using sidekiq instead of resque
# app/models/post.rb
class Post
searchable :auto_index => false, :auto_remove => false do
text :title
text :body
end
after_commit :sidekiq_solr_update, :if => :persisted?