Skip to content

Instantly share code, notes, and snippets.

@keoghpe
keoghpe / git-hist
Created March 4, 2020 11:01 — forked from isaldin/git-hist
git hist alias
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
# Run from the directory containing the app
# Given the app name
# Iterates over the models and replaces attr_accessible with strong params in the assocated controller
require 'active_support/inflector'
app_name = ARGV.first
models = Dir.entries("#{app_name}/app/models/").reject {|name| ['.', '..', '.gitkeep', 'permission.rb', 'user.rb'].include? name }.map {|name| name.split('.').first}
models.each do |model_name|
model_file_name = "#{app_name}/app/models/#{model_name}.rb"
@keoghpe
keoghpe / stripe_element_capybara_utils.rb
Last active August 29, 2019 10:51
Stripe Element Capybara Utils
module StripeElementsUtils
def fill_stripe_elements(card_number)
fill_stripe_element do
card_number.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
@keoghpe
keoghpe / IE9_fix.rb
Created November 10, 2015 09:54
IE9 Rails JSON Request Fix
before_action :fix_ie_params, only: [:create]
def fix_ie_params
unless params.has_key?(:my_missing_param)
begin
request.body.rewind
params.merge! ActiveSupport::JSON.decode(request.body.read)
rescue Exception=>e
Rails.logger.warn "[#{self.class}] #{e.message}"