This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| require 'benchmark' | |
| require 'ascii_charts' | |
| def measure | |
| GC.disable | |
| Benchmark.realtime do | |
| yield | |
| end | |
| ensure | |
| GC.enable |
This file contains hidden or 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
| __snappercomp() { | |
| local cur="${COMP_WORDS[COMP_CWORD]}" | |
| COMPREPLY=( $( compgen -W "$1" -- "$cur" ) ) | |
| } | |
| # From http://github.com/jweslley/rails_completion | |
| # @param $1 Name of variable to return result to | |
| # @param $2 Command list | |
| __snappercmd() { | |
| any_command=$(echo $2 | sed -e 's/[[:space:]]/|/g') |
This file contains hidden or 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
| #! /bin/sh -e | |
| # Requires https://github.com/profh/romanic | |
| # gem install romanic | |
| device="default:CARD=X20" | |
| lock="/run/lock/mpd-announce" | |
| dotlockfile -r 0 -p "$lock" || exit 0 | |
| trap "dotlockfile -p -u \"$lock\"" EXIT TERM INT |