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 Foo = Backbone.Model.extend({ | |
initialize: function() { | |
_.bindAll(this, 'change'); | |
this.bind('change', this.change); | |
}, | |
change: function() { console.log(this.previous('foo'), "to", this.get('foo')) } | |
}); | |
var f = new Foo({foo: 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
var View = Backbone.View.extend({ foo: function() { View.render(); }}, { render: function() { console.log("static render"); } }) | |
new View().foo() |
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
# Checkout first git revision before a given date | |
# Example usage: gcodate 2011-06-20 | |
# Note that HEAD must be at a commit *after* the date you're targeting. | |
gcodate(){ git checkout "`git rev-list HEAD -n 1 --first-parent --before=$@`" && git show HEAD --stat } |
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
// Build filtered, sorted map of compared ratings | |
val compared = ListMap( | |
productFeatureComparison.getProductComparedRatings.asScala.toMap | |
// Filter out products that have no offers | |
.filterNot { case (pid, _) => lowestOffer(products.get(pid)) == None} | |
// Sort by similarity descending | |
.sortBy{-_._2.getSimilarity}:_*) | |
// Use the first 10 | |
.take(10) |
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
object =^ { def ^= = "meow" } | |
// defined module $eq$up | |
=^.^= | |
// res10: java.lang.String = meow |
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
// groups only holds lists of "good" things and "bad" things | |
val groups = Map('good -> List("beer", "bikes"), 'bad -> List("flat tires")) | |
// But we're interested in both "good" things and "not too bad" things | |
val known = (groups.get('good), groups.get('notTooBad)) match { | |
case (Some(goodThings), Some(notTooBadThings)) => "i know about good and not-too-bad things" | |
case (Some(goodThings), None) => "i know about good things only" | |
case (_, None) => "i might know about good things but nothing else" | |
case _ => "i may or may not know anything" | |
} |
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 getRecommendedProducts = { | |
val featureRatings = productFeatureComparison.getFeatureRatings | |
val compared = productFeatureComparison.getProductComparedRatings | |
// Loop the products being compared | |
compared groupBy { case (pid, comparedRatings: ComparedRatings) => | |
// Run a comparison on all of feature ratings against this compared product. | |
val groups = featureRatings groupBy { case (p) => | |
val (key: String, fr: ProductFeatureComparison.FeatureRating) = (p.getKey, p.getValue) |
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
[merge] | |
tool = opendiff | |
[core] | |
excludesfile = /Users/trevorhartman/.gitignore | |
editor = vim | |
[alias] | |
st = status -sb | |
ci = commit | |
co = checkout | |
br = branch |
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
ns("decide").ApplicationModel = Backbone.Model.extend({ | |
sync: function(method, model, options) { | |
// Our overriden sync supports these events: | |
// sync:start | |
// sync:success | |
// sync:error | |
// sync:complete | |
// | |
// Params dispatched with the event: |
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 @Stars | |
constructor: (container, w, h) -> | |
@renderer = new Highcharts.Renderer(container, w, h) | |
@group = @renderer.g().add() | |
render: => | |
# :%s/\\d\\+/\\=(submatch(0)-3)/ | |
@scale = .8 |