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
let x=1 | |
# Repeat this command as much as wanted | |
let x++ && git diff HEAD~$x HEAD~$[x + 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
class Mixin | |
@mixin: (Klass)-> | |
# Class methods | |
Klass[key] = val for key, val of @ when key != 'mixin' | |
# Instance methods | |
Klass::[key] = val for key, val of @prototype | |
class Extra extends Mixin | |
@fn: -> alert 'class fn called' | |
fn: -> alert 'instance fn called' |
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
mixin = (Klass, Mixin) -> | |
# Class methods | |
Klass[key] = val for key, val of Mixin | |
# Instance methods | |
Klass::[key] = val for key, val of Mixin.prototype | |
class Mixin | |
@fn: -> alert "class fn" | |
fn: -> alert "instance fn" |
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
{ | |
"name": "BamPowLabs", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"express": "2.5.5", | |
"coffeekup": ">= 0.0.1", | |
"less": ">= 0.0.1", | |
"coffee-script": ">= 0.0.1", | |
"now": ">= 0.0.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
class Array | |
def frequencies(&block) | |
block ||= ->(x) {x} | |
Hash[group_by(&block).map {|k,v| [k, v.present? ? v.count : nil]} ] | |
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
assert = require 'assert' | |
_ = require 'lodash' | |
globals = | |
'+': (a,b) -> a + b | |
'*': (a,b) -> a * b | |
parse = (input) -> | |
JSON.parse(input.replace(/\s/g,",").replace(/[a-z\+\*]+/g, '"$&"')) |
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
fns = | |
'+': (a,b) -> a + b | |
'*': (a,b) -> a * b | |
parse = (input) -> | |
JSON.parse(input.replace(/\s/g,",").replace(/\+|\*/g, '"$&"')) | |
evaluate = (x)-> | |
if (Array.isArray(x)) # x is an expression | |
results = x.map (expression) -> evaluate(expression) |
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
# #fire | |
# Takes: r (A-J),c (1-10) | |
# Returns: MISS, HIT, SUNK, WIN, ()DUPE) | |
# #place | |
# Takes: r (A-J),c (1-10), Ship object | |
# Returns success/failure as a boolean | |
class Board | |
ROWS = 'ABCDEFGHIJ'.split(//) |
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 SendAll | |
def send_all(methods_and_args) | |
return self if methods_and_args.empty? | |
method_name, args = methods_and_args.pop | |
result = send method_name, *args | |
result.send_all result, query | |
end | |
end | |
class ActiveRecord::Relation |
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
# A sample Gemfile | |
source "https://rubygems.org" | |
# gem "rails" | |
gem 'haml' |
NewerOlder