Skip to content

Instantly share code, notes, and snippets.

Avatar

Tyler Rick TylerRick

  • USA
View GitHub Profile
@fabriciofreitag
fabriciofreitag / detailed_hash_diff.rb
Last active Dec 1, 2020
Custom RSPec matcher for detailed hash compasion and diff
View detailed_hash_diff.rb
RSpec::Matchers.define :be_a_hash_like do |expected_hash|
match do |actual_hash|
matching_results = actual_hash == expected_hash
unless matching_results
system(
"git --no-pager diff $(echo '#{JSON.pretty_generate(expected_hash)}' | git hash-object -w --stdin) " +
"$(echo '#{JSON.pretty_generate(actual_hash)}' | git hash-object -w --stdin) --word-diff",
out: $stdout,
err: :out
)
@goodviber
goodviber / gist:54898bc705a928a3e18c9b725d52e5ca
Created Jul 12, 2018
can't find executable webpack-dev-server for gem webpacker (Gem::Exception)
View gist:54898bc705a928a3e18c9b725d52e5ca
bundle exec rails webpacker:binstubs
@pseudomuto
pseudomuto / Gemfile
Last active Mar 29, 2019
Blog Code: Monitoring Rails Requests
View Gemfile
source "https://rubygems.org/"
...
...
gem "statsd-instrument"
@michaelglass
michaelglass / alerts_and_confirms.rb
Last active Sep 24, 2019
test alerts & confirms in poltergeist & capybara webkit
View alerts_and_confirms.rb
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
@sj26
sj26 / apple_record.rb
Created Jun 23, 2013
How I do STI: Utilize descendent tracking and override model_name so they use the same URL helpers and parameters as their base class. Makes things like responders and form_for work as expected, while preserving things like to_partial_path.
View apple_record.rb
class AppleRecord < Record
end
@glebm
glebm / form_helper.js.coffee
Last active Dec 17, 2015
AngularJS Form Helper
View form_helper.js.coffee
angular.module('myApp').factory 'FormHelper', [->
class FormHelper
constructor: (scope, object, formName) ->
@scope = scope
@formName = formName
@object = -> @scope[object]
scope.$watch "#{formName}.$pristine", (pristine) =>
@unsaved = !pristine
@saved = false unless pristine
scope.$watch "#{formName}.$valid", (valid) =>
@gogogarrett
gogogarrett / artist_controller.rb
Last active Dec 17, 2015
Using Reform with a Workflow object to allow the controller to be simpler.
View artist_controller.rb
class ArtistsController < ApplicationController
def create
@form = create_new_form
workflow = Workflows::ArtistWorkflow.new(@form, params[:artist])
workflow.process do |obj|
return respond_with obj
end
render :new
@stackng
stackng / rails content_for caching
Created Mar 29, 2011
make action and fragment caching of rails3 compatible with content_for
View rails content_for caching
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?