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
exports = {} | |
trueAjax = $.ajax | |
registry = {} | |
exports.registerSuccess = (url, result) -> | |
registry[url] = {success: result} | |
exports.registerFailure = (url, result) -> | |
registry[url] = {failure: result} |
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
// Based on | |
// https://github.com/tbranyen/backbone/blob/70eed5bc9e5d3587bd85e9ff56f8ea99a7f8501d/backbone.js#L130-141 | |
// Bind an event like `on`, but unbind the event following the first trigger. | |
window.Backbone.Model.prototype.once = | |
window.Backbone.View.prototype.once = | |
window.Backbone.Events.once = function (events, callback, context) { | |
// Bind the original events. | |
this.on(events, callback, context); |
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
$.fn.insertInOrder = (newElement, iterator) -> | |
$container = $(this) | |
$siblings = $container.children() | |
$newElement = $(newElement) | |
if $siblings.length == 0 | |
$container.append($newElement) | |
return this | |
index = _.sortedIndex $siblings, newElement, iterator |
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
for tag in $(git tag | grep -E 'v0\.([0-5])'); do git tag -d $tag && git push origin :refs/tags/$tag; done |
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
# Deploy and rollback on Heroku in staging and production | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP' | |
STAGING_APP = 'YOUR_STAGING_APP' | |
REMOTE = ENV["REMOTE_HOST"] || "[email protected]" | |
def heroku_cmd(cmd) | |
Bundler.with_clean_env do | |
sh "heroku #{cmd}" |
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
class HandlebarsTemplateEngine extends ko.templateEngine | |
renderTemplateSource: (compiledTemplate, bindingContext, options) -> | |
data = bindingContext.$data | |
htmlResult = compiledTemplate(data) | |
ko.utils.parseHtmlFragment(htmlResult) | |
makeTemplateSource: (template, templateDocument) -> | |
throw "Could not find a template named: '#{template}'" unless JST[template] | |
JST[template] |
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
gem list | cut -d" " -f1 | xargs gem uninstall -aIx | |
gem list | grep -v 'test-unit\|psych\|rdoc\|minitest\|json\|io-console\|bigdecimal\|rake' | cut -d" " -f1 | xargs gem uninstall -aIx |
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
jQuery ($) -> | |
$indicator = $('#ajax-indicator') | |
$message = $indicator.find('span') | |
$(document).ajaxSend (event, jqXHR, ajaxOptions) -> | |
msg = if ajaxOptions.type == 'GET' then 'Carregando' else 'Processando' | |
$message.text("#{msg}...") | |
$indicator.show() | |
$(document).ajaxStop -> $indicator.hide() |
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
jQuery ($) -> | |
$('.add_fields').each -> | |
$this = $(this) | |
insertionNode = $this.data('association-insertion-node') | |
insertionTraversal = $this.data('association-insertion-traversal') | |
if (insertionNode) | |
if (insertionTraversal) | |
insertionNode = $this[insertionTraversal](insertionNode) | |
else |
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
en: | |
activemodel: | |
errors: | |
messages: | |
invalid_url: "must be a valid URL" |