Skip to content

Instantly share code, notes, and snippets.

View tommeier's full-sized avatar

Tom Meier tommeier

View GitHub Profile
@tommeier
tommeier / cross_domain_helper.rb
Created July 12, 2012 07:29
CORS via rails include
require 'active_support/concern'
module CrossDomainHelper
extend ActiveSupport::Concern
included do
after_filter :cors_set_access_control_headers
def cors_preflight_check
#Short circuit API request and allow
# TODO : Set explicitly allowed routes
@tommeier
tommeier / .port
Created July 12, 2012 04:27
Install local ssl with pow
5000
@tommeier
tommeier / selenium_click_override.rb
Created June 22, 2012 04:48
Override Selenium for Chrome in click events.
Selenium::WebDriver::Element.class_eval do
def click_with_scroll
point = bridge.getElementLocationOnceScrolledIntoView @id
bridge.executeScript("window.scrollTo(0, #{point[:y]})")
click_without_scroll
end
alias_method_chain :click, :scroll
end
@tommeier
tommeier / model.rb
Created June 18, 2012 12:22
Redis Cache Shared
class Model < ActiveRecord::Base
include RedisCache
redis_cache :key_attribute => :name
end
@tommeier
tommeier / ci.rake
Created May 28, 2012 10:42
Rake file to split up specs into logical chunks for Jenkins to consume in isolated builds
begin
require 'rspec/core'
require 'rspec/core/rake_task'
#Divide & Conquer spec suite
#Each of these divisions should be represented by their own rspec rake task
DIVIDED_SPEC_RUNS = [ 'spec/controllers/', 'spec/models/', 'spec/middleware' ]
DIVIDED_REQUEST_RUNS = [ 'spec/requests/major_chunk_1/', 'spec/requests/major_chunk_2/', 'spec/requests/major_chunk_3/' ]
DIVIDED_TESTS = DIVIDED_SPEC_RUNS + DIVIDED_REQUEST_RUNS
@tommeier
tommeier / .gitconfig
Created April 24, 2012 01:43
.gitconfig
[user]
name = Tom Meier
email = [email protected]
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
@tommeier
tommeier / error.log
Created April 23, 2012 08:23
Stack trace from error in staging
File to import not found or unreadable:skin/icons/*.png. Load paths: Sass::Rails::Importer(/data/releases/20120423050001/app/assets/stylesheets/search.css.sass) /data/shared/bundled_gems/ruby/1.9.1/gems/compass-0.12.1/frameworks/compass/stylesheets /data/shared/bundled_gems/ruby/1.9.1/gems/compass-0.12.1/frameworks/blueprint/stylesheets (in /data/releases/20120423050001/app/assets/stylesheets/search.css.sass)
app/assets/stylesheets/skin/common/constants.css.sass:4
app/assets/stylesheets/search.css.sass:3
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:64:in `rescue in import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:42:in `import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/import_node.rb:25:in `imported_file'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:149:in `rescue in visit_import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:154:in `visit_import'
[GEM_ROOT]/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
(function($) {
window.Album = Backbone.Model.extend({
isFirstTrack: function(index) {
return index == 0;
},
isLastTrack: function(index) {
return index >= this.get('tracks').length - 1;
}
});
@tommeier
tommeier / some_spec.rb
Created April 17, 2012 01:45 — forked from myronmarston/some_spec.rb
VCR with placeholders
use_vcr_cassette 'some/cassette', :tag => :bad_staging_api
@tommeier
tommeier / spec_helper.rb
Created April 16, 2012 10:43
after_http_request
c.after_http_request(lambda { VCR.current_cassette && VCR.current_cassette.tags.include?(:bad_staging_api) }) do |req, res|
puts "OVERWRITING WILDCARDS"
res.body.gsub!('<TOTAL_RATE>', "836.00")
puts res.body
end