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
cd ~ | |
mkdir tools | |
cd tools | |
git clone https://github.com/thenigan/git-diffall.git | |
sudo ln -s ~/tools/git-diffall/git-diffall /usr/bin/git-diffall |
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
complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh |
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
### Add the following to HOME/tools/bin/gitmerge | |
#!/bin/sh | |
meld $2 $1 & | |
sleep 0.5 | |
meld $1 $3 & | |
sleep 0.5 | |
meld $2 $4 $3 | |
### Make it executable |
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
_.extend(Backbone.View.prototype, { | |
bubbleEventsTo : function(targetView) { | |
this.on("all", function() { | |
Backbone.View.prototype.trigger.apply(targetView, arguments); | |
}); | |
return this; | |
}) |
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
(function() { | |
Backbone.Model.prototype._save = Backbone.Model.prototype.save; | |
Backbone.Model.prototype.save = function(attrs, options) { | |
var that = this; | |
if (!options) { options = {}; } | |
if (this.savingNewRecord) { | |
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones | |
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well | |
_(['success','error']).each(function(event) { | |
// convert all callbacks to a single array of callbacks) |
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
// Based on http://www.intridea.com/blog/2011/2/8/fun-with-jquery-deferred | |
$.wait = function(time) { | |
var deferred = $.Deferred(function(dfd) { | |
setTimeout(dfd.resolve, time); | |
}); | |
// Can return susbset of Deferred object | |
// without any state mutating functionality: | |
// |
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
var uploadFormAndFile = function(form, file) { | |
var formData = new FormData(); | |
formData.append("email", form.email); | |
formData.append("name", form.name); | |
formData.append("thumbnail", file); | |
var uploadDeferred = $.Deferred(), | |
xhr = new XMLHttpRequest(); |
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
h = Hash[ *a.collect { |v| [ v, v ] }.flatten ] |
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
var MyCollection = Backbone.Collection.extend({ | |
fetchSingle : function() { | |
if (this.currentFetch && this.currentFetch.state() === "pending") this.currentFetch.abort(); | |
this.currentFetch = this.fetch.apply(this, _.toArray(arguments)); | |
return this.currentFetch; | |
} | |
}); |
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
RootApp.on("switchApp", function(appName, args) { | |
// Assuming the Root app has already instantiated all sub-apps | |
// and cached the instances by their names, fetch the app instance | |
var currentApp = RootApp.getSubappInstance(appName); | |
// If the app we're switching to is the currently active one, do nothing | |
if (RootApp.currentApp === currentApp) return; | |
// Stop the previously running app. Safe-guard with `if` in case |
OlderNewer