require 'benchmark'
n = 100_000
Benchmark.bm do |x|
x.report('Array interpolation: 1 param'){
n.times { User.where("email = ?", "[email protected]").to_sql }
}
x.report('Array interpolation: 3 params'){
This file contains hidden or 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) | |
This file contains hidden or 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)) |
This file contains hidden or 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 |
This file contains hidden or 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" |
This file contains hidden or 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 | |
# |
This file contains hidden or 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" |
This file contains hidden or 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. |
This file contains hidden or 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> |
This file contains hidden or 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> |
OlderNewer