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
// api - foo | |
module.exports = function(app) { | |
return { | |
foo: function(req, res) { | |
var id = req.params.id | |
req.user.foo(id).complete(function(error, foo) { | |
res.setHeader("Content-Type", "application/json"); | |
res.render("json", { response: { data: foo, error: error } }); | |
}); | |
} |
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("/api/foo/:id", function() { | |
before(function() { | |
var user = { foo: function() {} }; | |
var query = { complete: function() {} }; | |
var foo = "ok"; | |
// stub with yields | |
sinon.stub(query, "complete").yields(null, foo); | |
sinon.stub(user, "foo").withArgs("1").returns(query); | |
login(user); | |
}); |
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! s:tab_label(n) | |
let bufnrs = tabpagebuflist(a:n) | |
let curbufnr = bufnrs[tabpagewinnr(a:n) - 1] | |
let hl = a:n ==? tabpagenr() ? 'TabLineSel' : 'TabLine' | |
let bufs = len(bufnrs) | |
if bufs == 1 | |
let bufs = '' | |
else | |
let bufs = '%#'.hl.'Number#'.bufs | |
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
cat = "Tama" | |
rabbit = "Peter" | |
%w[Pochi Taro Hachi].map do |dog; cat, rabbit, wolf| | |
p cat #=> nil | |
p rabbit #=> nil | |
p wolf #=> nil | |
cat = dog | |
rabbit = "Bob" | |
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
cat = "Tama" | |
%w[Pochi Taro Hachi].map do |cat| | |
p cat #=> "Tama", "Tara", "Tachi" | |
cat = "Mame" | |
end | |
p cat #=> "Tama" |
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
cat = "Tama" | |
%w[Pochi Taro Hachi].map do |dog| | |
p cat #=> "Tama" | |
cat = dog | |
end | |
p cat #=> "Hachi" |
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
NeoBundleLazy 'https://bitbucket.org/kovisoft/slimv' | |
augroup slimv | |
autocmd! | |
autocmd FileType lisp NeoBundleSource slimv | |
augroup END | |
"" slimv | |
let s:hooks = neobundle#get_hooks('slimv') | |
function! s:hooks.on_source(hooks) | |
let g:slimv_swank_cmd = |
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 isArray(obj) { | |
return Object.prototype.toString.call(obj) === "[object Array]"; | |
} | |
function isFunction(obj) { | |
return Object.prototype.toString.call(obj) === "[object Function]"; | |
} | |
function forEach(list, callback) { | |
if (isArray(list)) { |
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
// test | |
var testScope = function(outer, inner, a, b, c) { | |
test("", function() { | |
assert(outer === "function", "outer() is in scope"); | |
}); | |
test("", function() { | |
assert(inner === "function", "inner() is in scope"); | |
}); | |
test("", function() { | |
assert(a === "number", "a is in scope"); |
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
<!DOCTYPE html> | |
<html lang="utf-8"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Test</title> | |
<style> | |
#results li.pass { color: green; } | |
#results li.fail { color: red; } | |
</style> | |
<script type="text/javascript" src="/path/to/test.js"></script> |