Skip to content

Instantly share code, notes, and snippets.

Tim Cuthbertson timbertson

Block or report user

Report or block timbertson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:344886
# basically, you just have nested "describe" blocks, with one "it" block per test.
describe 'deferred', ->
it 'should deal with a single defer', ->
single_def: (x) -> defer return_arg(x)
equal single_def.length, 2
callback_called: false
single_def "a", (result) ->
View cofeespec output
$ bin/cake test -f operations
passed 3 tests in 0.01 seconds
# verbose test listing
View gist:364555
exports.run_tests: run_tests: (cb) ->
remaining: (test for test in tests when test.success is null)
iterate: ->
if remaining.length == 0
cb()
return
test: remaining.shift()
test.run(iterate)
iterate()
View clean_up_if_bodies.patch
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 0a8d950..219911d 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -457,8 +457,8 @@ grammar: {
# The CoffeeScript switch/when/else block replaces the JavaScript
# switch/case/default by compiling into an if-else chain.
Switch: [
- o "SWITCH Expression INDENT Whens OUTDENT", -> $4.rewrite_condition $2
- o "SWITCH Expression INDENT Whens ELSE Block OUTDENT", -> $4.rewrite_condition($2).add_else $6, true
View expected.js
(function(){
var _a, _b, _c, _d, evens, num;
evens = (function() {
_a = []; _c = [1, 2, 3, 4, 5, 6];
for (_b = 0, _d = _c.length; _b < _d; _b++) {
num = _c[_b];
num % 2 === 0 ? _a.push((function() {
num *= -1;
num -= 2;
return num * -1;
View sync.coffee
class Sync
constructor: (reader, store) ->
@reader = reader
@store = store
pull_tags: (cb) ->
@reader.get_user_tags (tags) ->
@store.set_valid_tags(tags, cb)
pull_items: (tag_name, cb) ->
View defer.coffee
# defer can be placed in front of any function call that takes
# a callback as its last paramater.
# instead of this:
myFunc: (callback) ->
someFunction 1, 2, 3, (result) ->
doSomeThingWith(result)
callback(true)
# you will write this:
View test_deferred_output.js
(function(){
var check_later, debug, delay, return_arg, return_call;
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
require('/home/tim/dev/web/coffee-spec/lib/coffee-spec').autorun(global, 2);
debug = require("sys").debug;
delay = function(func) {
return process.nextTick(func);
};
return_arg = function(x, cb) {
return delay(function() {
View rspec_immediate_feedback_formatter.rb
require 'spec/runner/formatter/specdoc_formatter'
#monkey-patch the specdoc formatter to immediately print failure messages (and continue)
module Spec
module Runner
module Formatter
class SpecdocFormatter
alias :example_failed_without_immediate_feedback :example_failed
def example_failed(example, counter, failure)
example_failed_without_immediate_feedback(example, counter, failure)
View gist:763397
diff --git a/src/watchdog/observers/inotify.py b/src/watchdog/observers/inotify.py
index 4ea8004..ac6136f 100644
--- a/src/watchdog/observers/inotify.py
+++ b/src/watchdog/observers/inotify.py
@@ -688,6 +688,7 @@ if platform.is_linux():
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._inotify = Inotify(watch.path, watch.is_recursive)
+ self._moved_from_events = dict()
You can’t perform that action at this time.