Skip to content

Instantly share code, notes, and snippets.

View coryodaniel's full-sized avatar
☘️
O'Internets

Cory O'Daniel coryodaniel

☘️
O'Internets
View GitHub Profile
#
# 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.
@coryodaniel
coryodaniel / SassMeister-input-HTML.html
Created November 7, 2014 23:10
Generated by SassMeister.com.
<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>
@coryodaniel
coryodaniel / SassMeister-input-HTML.html
Created November 7, 2014 23:13
Generated by SassMeister.com.
<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>
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))
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)
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
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"
##
# 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
#
@coryodaniel
coryodaniel / array_vs_hash.md
Created December 8, 2015 17:14
Rails 5 ActiveRecord Query Building: Array vs Hash
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'){ 
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"