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
$.fn.extend | |
myplugin: (options) -> | |
self = $.fn.myplugin | |
opts = $.extend {}, self.default_options, options | |
$(this).each (i, el) -> | |
self.init el, opts | |
self.log el if opts.log | |
$.extend $.fn.myplugin, | |
default_options: |
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
Jeremy | |
Absolutely brilliant | |
both technically | |
and oratorically | |
He wrote CoffeeScript | |
1st place 5k | |
21 min, 3 seconds | |
<7min mile | |
Big picture |
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
### | |
Modified from https://github.com/jashkenas/coffee-script/blob/master/Cakefile | |
Part of an upcoming PeepCode screencast. This snippet is MIT Licensed. | |
### | |
{spawn, exec} = require 'child_process' | |
task 'assets:watch', 'Watch source files and build JS & CSS', (options) -> | |
runCommand = (name, args) -> |
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
describe("AjaxForm", function() { | |
// Local vars for manipulation | |
var $form = null, | |
_requirejs_loaded = false, | |
found_errors = false, | |
submitted_successfully = false, | |
AjaxFormInstance = null, | |
RequireJSViews = { | |
AjaxFormView: null |
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 jQuery objects with Underscore collection methods. | |
# | |
# Each collection method comes in two flavors: one prefixed | |
# with _, which yields a bare DOM element, and one prefixed | |
# with $, which yields a jQuery-wrapped element. | |
# | |
# So if `this` is a jQuery object, instead of: | |
# | |
# _.max @, (el) -> $(el).height() | |
# |
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
# Conditional decrement. | |
# | |
# Decrement the value of a key only if the current value is greater than | |
# a specified value. | |
require 'rubygems' | |
require 'redis' | |
r = Redis.new | |
cond_decr = <<LUA |
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
alias rake="time rake" | |
# Run `padrino rake` when inside a padrino project, | |
# otherwise run the normal rake command. | |
function rake () { | |
if [[ -f ".components" ]]; then | |
padrino rake $* | |
else | |
ruby -S rake $* | |
fi |
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 simple Tweet POJO: | |
// $> javac TweetEvent.java | |
public class TweetEvent { | |
private String user; | |
private String text; | |
private String timezone; | |
private int retweets; | |
public TweetEvent(String user, String text, String timezone, int retweets) { |
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 assertViewAction(viewClass, eventCallbackName, elementAccessorName, eventName, viewReference) { | |
it("should run the " + eventCallbackName + " action when the " + elementAccessorName + " gets a " + eventName + " event (assertViewAction)", function() { | |
var isPrototypal = eventCallbackName in viewClass.prototype; | |
if (isPrototypal) { | |
spyOn(viewClass.prototype, eventCallbackName); | |
} | |
var view = viewReference(); | |
if (!isPrototypal) { | |
spyOn(view, eventCallbackName); | |
} |
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
/* This is the module, the implementation, distinct from the specification/interface. */ | |
define([...deps...], function(){ | |
return function(options){ | |
... | |
}; | |
}); |