Skip to content

Instantly share code, notes, and snippets.

View tonycoco's full-sized avatar

Tony Coconate tonycoco

View GitHub Profile
@tonycoco
tonycoco / select2.rb
Created February 19, 2014 17:28
Select2 Capybara Support File
# Useage: select2("value to select", from: "label text")
module Capybara
module Select2
def select2(value, options={})
select_name = options[:from]
select2_container = first("label", text: select_name).find(:xpath, "..").find(".select2-container")
select2_container.find(".select2-choice").click
find(:xpath, "//body").find(".select2-drop li", text: value).click
end
@tonycoco
tonycoco / heroku-pg-backup.sh
Last active August 29, 2015 13:56
Heroku PG Backup
curl -o latest.dump `heroku pgbackups:url`
rake db:drop db:create db:migrate
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U root -d DATABASE_development latest.dump
rm latest.dump
@tonycoco
tonycoco / controller_spec.rb
Last active May 25, 2023 06:04
The Greatest Hits of Rspec Testing: Volume 1
require "spec_helper"
describe ExampleController do
context "GET #index" do
let(:resources) { FactoryGirl.create_list(:resource) }
before do
get :index
end
@tonycoco
tonycoco / Procfile.local
Created May 31, 2013 20:28
Example local - Procfile.local
log: tail -f log/development.log
redis: redis-server /usr/local/etc/redis.conf
db: postgres -D /usr/local/var/postgres
require 'sauce'
require 'capybara'
require 'capybara/rails'
require 'capybara/sauce'
class ActionDispatch::IntegrationTest
include Rails.application.routes.url_helpers # for x_path and x_url helpers
include Capybara::DSL
def require_js
@tonycoco
tonycoco / 0-readme.md
Created December 3, 2012 17:05 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@tonycoco
tonycoco / tm2-bundles
Created September 14, 2012 17:01
TextMate 2 Bundles
These are some needed bundles for TM2...
cd ~/Library/Application Support/Avian/Bundles
git clone https://github.com/cucumber/cucumber-tmbundle Cucumber.tmbundle
git clone https://github.com/kuroir/SCSS.tmbundle
git clone https://github.com/mads379/Whitespace.tmbundle
open Cucumber.tmbundle/color_themes/Sunburst.tmTheme
@tonycoco
tonycoco / config.ru
Created July 11, 2012 16:40
Rack It Up... Using POW! with PHP (Or, rather using PHP with Rack)
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson ([email protected])
# clearly this could be cleaner, but it does work
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
# WP's redirect_canonical doesn't do an infinite redirect of /
@tonycoco
tonycoco / image_filters.rb
Created June 11, 2012 15:04
Useful image filters (Instagram/Hipster/Cool) for CarrierWave using MiniMagick (ImageMagick)
module CarrierWave
module MiniMagick
def toaster_filter
manipulate! do |img|
img.modulate '150,80,100'
img.gamma 1.1
img.contrast
img.contrast
img.contrast
img.contrast
@tonycoco
tonycoco / rubyhashsyntax.rb
Created May 11, 2012 17:17
Confusing Ruby Hash Syntax
# New
range :percentile, from: percentile[0], to: 1
# Old
range :percentile, :from => percentile[0], :to => 1