Skip to content

Instantly share code, notes, and snippets.

Fabio Rehm fgrehm

Block or report user

Report or block fgrehm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
fgrehm / gist:4017563
Created Nov 5, 2012
AJAX helpers for JS specs
View gist:4017563
exports = {}
trueAjax = $.ajax
registry = {}
exports.registerSuccess = (url, result) ->
registry[url] = {success: result}
exports.registerFailure = (url, result) ->
registry[url] = {failure: result}
fgrehm / gist:4127812
Created Nov 21, 2012
View gist:4127812
// Based on
// 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);
fgrehm / gist:4251894
Created Dec 10, 2012
Inserts a new element in order
View gist:4251894
$.fn.insertInOrder = (newElement, iterator) ->
$container = $(this)
$siblings = $container.children()
$newElement = $(newElement)
if $siblings.length == 0
return this
index = _.sortedIndex $siblings, newElement, iterator
fgrehm / gist:4253540
Created Dec 10, 2012
Delete multiple git tags
View gist:4253540
for tag in $(git tag | grep -E 'v0\.([0-5])'); do git tag -d $tag && git push origin :refs/tags/$tag; done
fgrehm / gist:4489503
Last active Dec 10, 2015
knockout.js + handlebars
View gist:4489503
class HandlebarsTemplateEngine extends ko.templateEngine
renderTemplateSource: (compiledTemplate, bindingContext, options) ->
data = bindingContext.$data
htmlResult = compiledTemplate(data)
makeTemplateSource: (template, templateDocument) ->
throw "Could not find a template named: '#{template}'" unless JST[template]
fgrehm / gist:4952397
Last active Dec 13, 2015
Removing all installed gems
View gist:4952397
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
jQuery ($) ->
$indicator = $('#ajax-indicator')
$message = $indicator.find('span')
$(document).ajaxSend (event, jqXHR, ajaxOptions) ->
msg = if ajaxOptions.type == 'GET' then 'Carregando' else 'Processando'
$(document).ajaxStop -> $indicator.hide()
View en.yml
invalid_url: "must be a valid URL"
fgrehm / gist:5424514
Last active Dec 16, 2015
Vagrant + Docker notes
View gist:5424514

To kick off the provider would be nice to have the big picture of out how Vagrant features / commands map to docker "stuff". These are thoughts about how the integration might look like under the hood:

vagrant up

  • how can we tell docker to "just start" a container? "docker start base" would start the base image right?
  • would probably need to commit the base "box" image and interact with that
  • would it make sense to have a "commandless" docker run -d <image>?
fgrehm / Vagrantfile
Last active Dec 16, 2015
VBox + LXC
View Vagrantfile
Vagrant.configure("2") do |config| = "quantal64" :private_network, ip: ""
config.vm.define :vbox do |vbox_config| :forwarded_port, guest: 3000, host: 3001
vbox_config.vm.provision :shell, inline:
# vagrant-lxc required dependencies and vagrant itself
'sudo apt-get install -y redir lxc &&
You can’t perform that action at this time.