Skip to content

Instantly share code, notes, and snippets.

View modsognir's full-sized avatar

Jared Fraser modsognir

View GitHub Profile
find app config db spec test -type f -name '*.rb' -or -name '*.coffee' -or -name '*.erb' -or -name '*.jbuilder' -or -name '*.js' | xargs sed -i '' -E "s/[[:space:]]*$//"
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch} your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any? {Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe. Thanks.|
{It is|It's} {appropriate|perfect|the best} time to make some plans for the future and {it is|i
@modsognir
modsognir / error.rb
Last active December 18, 2015 23:09 — forked from chewmanfoo/error.rb
Completed 500 Internal Server Error in 1867ms
NoMethodError (undefined method `include?' for nil:NilClass):
app/models/user.rb:121:in `svn_password_must_be_acceptable'
@modsognir
modsognir / idea.rb
Created January 15, 2013 11:38 — forked from kalleth/idea.rb
field :name
accessible
validates :presence do
message "please provide a name"
end
end
field :email
accessible
validates :format do
@modsognir
modsognir / valid.rb
Created October 11, 2012 02:54 — forked from notahat/valid.rb
Testing fail?
# I have a class that delegates functionality to a couple of objects that it
# constructs. I want to test this in isolation. I want to make sure that the
# objects are constructed with the right arguments. I also want to make sure
# that the results from the objects are handled correctly.
#
# I'm finding it hard to structure the code and test in a way that isn't
# cumbersome. What's below works, but it feels like a lot of stubbing and setup
# for something the should be simpler.
#
@modsognir
modsognir / ruby_require_speed.patch
Created May 27, 2011 02:14 — forked from xaviershay/ruby_require_speed.patch
This drastically speeds up require time on ruby 1.9 (17s down to 10s in our production rails app) , at the expense of disabling some edge case handling around autoloading. YMMV but it works for our rails app.
From 2fb8432982b7e8ffc4c05f912f47cd9ca7261427 Mon Sep 17 00:00:00 2001
From: Xavier Shay <xavier@rhnh.net>
Date: Sun, 1 May 2011 10:25:18 +1000
Subject: [PATCH] Disable some edge cases in requiring to speed it up.
---
load.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/load.c b/load.c
class Model < ParentModel
include Foo::Bar
extend Bar::Baz
module InternalModule
...
end
default_scope :order => 'id ASC'
products = Product.where("price = 100").limit(5) # No query executed yet
products = products.order("created_at DESC") # Adding to the query, still no execution
products.each { |product| puts product.price } # That's when the SQL query is actually fired
class Product < ActiveRecord::Base
named_scope :pricey, where("price > 100")
named_scope :latest, order("created_at DESC").limit(10)
end
# Allows you to do (1) instead of (2)
# 1
Given /^I sign up as a staff member with login "([^\"]*)"$/ do |login|
Cucumber(%Q{
When I go to the sign up page
And I fill in "Username" with "#{login}"
And I fill in "Password" with "password"
And I fill in "Password again" with "password"
And I fill in "Email" with "#{login}@domain.com"