require 'benchmark'
n = 100_000
Benchmark.bm do |x|
x.report('Array interpolation: 1 param'){
n.times { User.where("email = ?", "user@example.com").to_sql }
}
x.report('Array interpolation: 3 params'){
View gist:702435b85267a5d09dee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name: database | |
# Recipe: default | |
# | |
# Description: | |
# Configure application servers to use mysql2 adapter for the database.yml config. | |
# All parameters except the adapter are pulled from the EY node JSON element. See | |
# http://docs.engineyard.com/use-deploy-hooks-with-engine-yard-cloud.html for an | |
# example of the node JSON object. This object is also used for by deploy hooks | |
# at Engine Yard. |
View SassMeister-input-HTML.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='cool-site'> | |
<div class='product-list'> | |
<div class='product'>Lorem</div> | |
<div class='ad'>Cool Ad</div> | |
<div class='product'>Dalor</div> | |
<div class='product'>Sit</div> | |
<div class='product'>Amet</div> | |
<div class='product'>Hanky</div> | |
</div> | |
<aside> |
View SassMeister-input-HTML.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class='cool-site'> | |
<div class='product-list'> | |
<div class='product'>Lorem</div> | |
<div class='ad'>Cool Ad</div> | |
<div class='product'>Dalor</div> | |
<div class='product'>Sit</div> | |
<div class='product'>Amet</div> | |
<div class='product'>Hanky</div> | |
</div> | |
<aside> |
View gist:63057
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DM Wishlist | |
* index profile | |
* erd tool | |
* Partial length indexes (for string indexes) | |
* relationship_set / get | |
* engine type | |
* User.all.update(User.aribitrary_column += 5) | |
* Validates is unique should only select once | |
* Dm-Validate, only validate DIRTY fields | |
* DataMapper-Cache (uses version to also invalidate (event and TTL)) |
View gist:63053
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_delete_constraints | |
model.relationships.each do |rel_name, rel| | |
debugger if $CASE_DEBUG | |
#Only look at relationships where this model is the parent | |
next if rel.parent_model != model | |
#Don't delete across M:M relationships, instead use their anonymous 1:M Relationships | |
next if rel.is_a?(DataMapper::Associations::RelationshipChain) | |
View gist:64172
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when :destroy! | |
# not sure why but this lazy_load is necessary | |
# otherwise children will not be deleted with destroy! | |
children.lazy_load | |
children.destroy! | |
when :set_nil |
View gist:65408
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestUsingBeforeFilter < Application | |
before :captcha_every_time!, :only => [:create,:destroy] | |
before :captcha_once_per_30_seconds!, :only => [:index], :unless => :is_admin? | |
def index | |
render | |
end | |
def create | |
render "Awesome form here" |
View gist:65565
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# A succinct wrapper for before filters to create threshold | |
# | |
# @param *args [~Array] | |
# args array for handling array of action names and threshold options | |
# | |
# @param threshold_options [Array] | |
# Array of actions to apply threshold; passed to before filters :only option | |
# |
View array_vs_hash.md
View gist:7256443
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: ruby | |
rvm: | |
- "ruby-2.0.0-p195" | |
services: | |
- memcache | |
- elasticsearch | |
- redis-server | |
before_install: | |
- "export DISPLAY=:99.0" | |
- "sh -e /etc/init.d/xvfb start" |
OlderNewer