Skip to content

Instantly share code, notes, and snippets.

View matthooks's full-sized avatar

Matt Hooks matthooks

View GitHub Profile
# BEFORE
def validate_password_with_openid?
!using_openid? && require_password?
end
# AFTER
def validate_password_with_openid?
require_password?
end
Results 210.50
System Info
Xbench Version 1.3
System Version 10.6.1 (10B504)
Physical RAM 3072 MB
Model MacBookPro2,1
Drive Type INTEL SSDSA2M160G2GC
Disk Test 210.50
Sequential 132.18
Uncached Write 145.15 89.12 MB/sec [4K blocks]
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "example_gem/version"
Gem::Specification.new do |s|
s.name = "example_gem"
s.version = ExampleGem::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Name"]
s.email = ["Email"]
<false> is not true. (Test::Unit::AssertionFailedError)
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:48:in `assert_block'
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:500:in `_wrap_assertion'
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:46:in `assert_block'
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:63:in `assert'
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:495:in `_wrap_assertion'
/Users/matthooks/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/test/unit/assertions.rb:61:in `assert'
./features/step_definitions/contact_search_steps.rb:115:in `/^I should see contacts contacted more than two weeks ago$/'
features/contacts_search.feature:75:in `Then I should see contacts contacted more than two weeks ago'
# BAD
function1 = ->
console.log('stuff')
$(function1)
function2 = (parameter1) ->
console.log(parameter1)
$(function2)
html = """
This is a string in which you can insert #{stuff} and have many double quotes """""" without having to do \" to escape them
"""
html = """
<iframe id="#{id}_form" style="display:#{(!visible && 'none') || 'auto'}; width:400px; height:50px; border:0; overflow:hidden;" border="0" frameborder="0" scrolling="no" src="/attachments/new?target=#{id}&name=#{escape $attachment.val()}"></iframe>
"""
@matthooks
matthooks / gist:1379747
Created November 20, 2011 02:58
Simple counter cache setup for MongoMapper that supports single collection inheritance.
module CounterCache
extend ActiveSupport::Concern
module ClassMethods
def counter_cache(field)
class_eval <<-EOF
after_create "increment_counter_for_#{field}"
after_destroy "decrement_counter_for_#{field}"
EOF
end
firing pixel: http://p.nowspots-staging.com/event?ids=s%3A4ecab288b14b360001000067%2Ct%3A4de6f1b569db40775a000001%2Ca%3A4eb845059079f90001000002%2Cp%3A4ebd83d2d2f0160010000003&actions=profile-click&elapsed=381278&cb=1321908267111&url=http%3A//ads_app.dev/&stream=bszz
{
"content": {
"field_groups": [
{
"keys": ["username"],
"repeat": false
}
]
},
"settings": {
@matthooks
matthooks / Thin (local)
Created April 6, 2012 22:55
Performance comparison for Facebook app between Thin and Unicorn
Server Software: thin
Server Hostname: localhost
Server Port: 5000
Document Path: /serve?username=nowspots
Document Length: 3070 bytes
Concurrency Level: 10
Time taken for tests: 146.587 seconds
Complete requests: 10000