Skip to content

Instantly share code, notes, and snippets.

@mjtko
mjtko / error.rb
Created September 2, 2011 20:06
error.rb
# app/models/kebab.rb
module Kebab
class << self
def table_name_prefix
'kebab_'
end
end
end
# app/models/kebab/user.rb -- should work now
@mjtko
mjtko / show_exceptions-monkey-patch.rb
Created August 23, 2011 08:49
ActionDispatch monkey patch
module ActionDispatch
class ShowExceptions
private
# override public_path, because keeping static error pages in
# <Rails.root>/public is, well, ridiculous, as they can be
# statically accessed. It's. Just. Wrong.
def public_path
"#{Rails.root}/config/errors"
end
end
@mjtko
mjtko / handlebarsTemplateEngine.js
Created May 12, 2011 22:39
knockout template engine for handlebars.js
/*
Handlebars Template Engine for Knockout JavaScript library
*//*!
Copyright (c) 2011 Mark J. Titorenko
License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
ko.handlebarsTemplateEngine = function () {
// adapted from MooTools.Element
//
// This is necessary to allow us to easily deal with table
@mjtko
mjtko / nativeTemplateEngine.js
Created April 26, 2011 16:49
knockout "native" template engine
ko.nativeTemplateEngine = function () {
// monkey patch to convert possible NodeList into Array before iterating
ko.utils._setDomNodeChildren = ko.utils.setDomNodeChildren;
ko.utils.setDomNodeChildren = function (domNode, childNodes) {
var childNodesArray = Array.prototype.slice.call(childNodes);
ko.utils._setDomNodeChildren(domNode, childNodesArray);
};
// adapted from MooTools.Element
//