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
# inject function | |
inject = (collection, object, handler)-> | |
$.each collection, (index, value)-> | |
object = handler(object, value) | |
true | |
object | |
# the same as a method | |
inject_method = (object, handler)-> | |
inject(this, object, handler) |
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
if (typeof Array.prototype.indexOf == "undefined") { | |
Array.prototype.indexOf = function(value) { | |
for (var i = 0; i < this.length; i++) { | |
if (this[i] == value) { | |
return i; | |
} | |
} | |
return -1; | |
} | |
} |
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
if Array.prototype.unique == undefined | |
Array.prototype.unique = -> | |
filtered_array = [] | |
$.each this.sort(), (index, value)-> | |
filtered_array.push(value) if filtered_array.indexOf(value) == -1 | |
filtered_array | |
if Array.prototype.is_unique == undefined | |
Array.prototype.is_unique = -> | |
this.length == this.unique.length |
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
[true, false].reduce(&:&) | |
[true, false].reduce(&:|) | |
# the same | |
[true, false].any? |
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
def method_missing(method_name, *arguments, &block) | |
return target.send(method_name, *arguments, &block) if target.respond_to? method_name | |
super | |
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
h.simple_format h.h(object.text) |
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 superkiller(o, prop_name) { | |
if(o.hasOwnProperty(prop_name)) { | |
delete o[prop_name] | |
} | |
$.each(x, function(i, e) { | |
if(typeof(e) == "object") { superkiller(e, prop_name) } | |
}); | |
} |
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
// coffescript | |
(options...)-> | |
$.each options, (i, v)-> | |
console.log v |
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
[diff] | |
external = /home/user/diff.py |
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 | |
/usr/local/bin/sqlformat --keywords upper --reindent --identifiers lower - |
OlderNewer