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
## | |
# Drills into related Mongoid models to create a single error message. | |
# | |
# @param obj [Object] An instance of a Mongoid model class. | |
# @param prefix [String] The class/attribute name prefix (for recursive calls). | |
# | |
# @return [String] A string of concatenated error messages. | |
# | |
def err_drill(obj, prefix = nil) | |
prefix = "#{obj.class.to_s.downcase}." if prefix.nil? |
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 | |
# Git Jira Tickets | |
# Outputs a list of Jira ticket numbers from a git log | |
# Usage: gjt <since_commit> | |
commit_messages=$(git log --merges --pretty=format:'%h %s' $1^..HEAD | sed "s/ /SPACE_DELIMITER/g") | |
lines=() |
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
module ActiveSupport::JSON::Encoding | |
def self.escape(string) | |
if string.respond_to?(:force_encoding) | |
string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) | |
end | |
json = string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } | |
json = %("#{json}") | |
json.force_encoding(::Encoding::UTF_8) if json.respond_to?(:force_encoding) | |
json | |
end |
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
#!/bin/bash | |
# Sets up a simple Sinatra project. | |
# Assumes RVM, Bundler and Foreman. | |
if [ $# -lt 1 ] || [ $# -gt 2 ]; then | |
echo Expected 1 or 2 arguments but got $# | |
echo Usage: sinatra-starter PROJECT_NAME [RUBY_VERSION] | |
exit | |
fi |
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
/* | |
Workaround for browsers that ignore the maxWidth argument of fillText() and strokeText() | |
Sample usage: | |
context.fillTextW("DISPROPORTIONABLENESS", 0, 10, 50); | |
*/ | |
CanvasRenderingContext2D.prototype.fillTextW = function(text, x, y, maxWidth) { | |
this.fillOrStrokeText("fillText", text, x, y, maxWidth); | |
} | |
CanvasRenderingContext2D.prototype.strokeTextW = function(text, x, y, maxWidth) { |