This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless Rails.env.production? | |
after_filter do | |
objects = Mongoid::IdentityMap.values.flat_map(&:values) | |
changed_objects = objects.select { |o| o.changes.except('updated_at', 'locked_at', 'locked_until').present? } | |
unsaved_objects = changed_objects.select { |o| o.errors.empty? } | |
unless unsaved_objects.empty? | |
unsaved_objects.each do |obj| | |
Rails.logger.error "Unsaved object: #{obj.inspect}\n Changes: #{obj.changes.inspect}" | |
end | |
raise "Some changed objects have not been saved. See log for details." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def within_any(*args) | |
candidates = page.all(*args) | |
if candidates.empty? | |
query = Capybara::Query.new(*args) | |
raise Capybara::ElementNotFound.new("Unable to find #{query.description}") | |
end | |
error = nil | |
candidates.any? do | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby -w | |
require 'date' | |
require 'find' | |
# TODO | |
# - make work with -p option | |
def main | |
logopts = "--color=always --since=#{Date.today - 3} #{ARGV.join(' ')}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby1.9.3 | |
require 'taglib' | |
require 'debugger' | |
# TODO | |
# - CLI | |
# - -m, --monthly | |
# - -u, --update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env phantomjs | |
// Michael Schuerig, <[email protected]>, 2012. | |
// Portions are Copyright 2011 Valeriu Paloş ([email protected]). (see below) | |
// This script requires PhantomJS | |
// http://phantomjs.org/download.html | |
var jQueryUrl = "//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby -w | |
# Michael Schuerig, <[email protected]>, 2012. | |
# This file is in the public domain. | |
# Any trouble it may cause is yours, not mine. | |
# | |
# This is a pre-commit hook for git with a few checks I find useful | |
# useful in Rails projects. The checks are: | |
# | |
# * Bad tags (such as XXX, WTF, ...) as specified in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__cucumbercomp() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
COMPREPLY=( $( compgen -W "$1" -- "$cur" ) ) | |
} | |
__cucumbertags() { | |
sed -r -n 's/^\s*(((@[[:alnum:]]+)\s?)+).*$/\1/p' features/**/*.feature \ | |
| sed -r 's/\s+/\n/' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_cheat() | |
{ | |
local sheets | |
list="$HOME/.cheat/.sheets" | |
if [ ! -f "$list" ]; then | |
cheat sheets | sed -n 's/^ \(.*\)$/\1/p' > "$list" | |
fi | |
sheets=$(cat "$list") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Place this file at ~/.rvm/hooks/after_use_switch_gemfiles | |
# and make it executable. | |
# | |
# This version copies Ruby-specific Gemfile.lock.x to Gemfile.lock. | |
if [ -e "Gemfile" ]; then | |
. "${rvm_path}/scripts/functions/hooks/jruby" | |
unset current_platform gemfile_platform |