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
module Kernel | |
def composed(actions) | |
lambda do |*args, &block| | |
actions.reverse.reduce(*args) do |result, next_op| | |
result = next_op.call(result, &block) | |
end | |
end | |
end | |
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
class Symbol | |
def [](*args) | |
proc {|obj| | |
obj.send(self,*args) | |
} | |
end | |
end | |
__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
String.prototype.to_f = function() { | |
var method = this; | |
var arity = method.match(/arity:(\d+)/); | |
var argument_count = -1; | |
if (arity) { | |
arity = arity[1]; | |
argument_count = 1 + arity; | |
} | |
method = method.replace(/\s*arity:\d+/, ''); |
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 cycle = function() { | |
var i = 1; | |
return function(first, second) { | |
if (first === 'reset') { | |
i = 1; | |
return; | |
} | |
var value = [first, second][i = 1 - i]; | |
return value; | |
}; |
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
#!/usr/bin/env ruby | |
deck = (1..21).to_a.shuffle | |
show_deck = -> { | |
n = 0 | |
deck.each_slice(7) { |pile| puts "\npile #{n+=1}\n\n#{pile.join("\n")}\n\n" } | |
} | |
select_pile = -> pile { | |
piles = *deck.each_slice(7) |
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
# run like this USER_NAME="?" USER_EMAIL="?" GITHUB_USER="?" GITHUB_TOKEN="?" bash < <(curl -s "https://raw.github.com/gist/1415243/setup_git_config.sh") | |
git config --global user.name "$USER_NAME" | |
git config --global user.email "$USER_EMAIL" | |
git config --global color.branch "auto" | |
git config --global color.diff "auto" | |
git config --global color.interactive "auto" | |
git config --global color.status "auto" | |
git config --global branch.autosetuprebase "always" | |
git config --global alias.co "checkout" |
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
static ScriptEngine engine = Ruby.CreateRuntime().GetRubyEngine(); | |
static dynamic dispatcher = null; | |
public static dynamic DynamicDispatcher(this object Source) | |
{ | |
dispatcher = dispatcher ?? engine.Execute("->(o){->(*args, &block){o.send(args.shift(), *args, &block)}}"); | |
return dispatcher(Source); | |
} | |
// example command.DynamicDispatcher("Caller=", new Caller("blah..")); |
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
#!/usr/bin/env bash | |
if command -v npm-$1 > /dev/null | |
then | |
npm-$1 ${@:2} | |
else | |
TMP1=`mktemp /tmp/tmp.XXXXXX` | |
trap "rm -f $TMP1" SIGINT SIGTERM SIGHUP SIGQUIT |
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(global) { | |
var typedArrays = ['Int8Array', 'Uint8Array', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array']; | |
for(var i=0; i < typedArrays.length; i++) { | |
if(typeof global[typedArrays[i]] === 'undefined') { | |
global[typedArrays[i]] = Array; | |
} | |
} | |
}(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
[HttpGet] | |
public virtual ActionResult Query() | |
{ | |
var result = entity.All(); | |
var q = Request.QueryString; | |
if (null != q["select"]) | |
{ | |
var selection = q["select"].Split(',').Select(col => entity[col] as SimpleReference).ToArray(); | |
result = result.Select(selection); |
OlderNewer