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
/** | |
* I want to be able to post a list of items, filter out relevant items, then continue with the post | |
* Afterwards I want to get the collection that was just created and add some stuff to it | |
* | |
* 1. Post list | |
* 2. Filter items from list | |
* 3. Continue with post | |
* 4. Add stuff to collection after | |
*/ | |
var mio = require('mio') |
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 mio = require('mio'); | |
var Message = mio.Resource.extend({ | |
attributes: { | |
id: { | |
primary: true, | |
}, | |
type: {}, | |
text: {} | |
} |
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
fs = require 'fs' | |
files = fs.readdirSync "#{process.cwd()}/json" | |
dataMap = {} | |
for file in files | |
raw = require "#{process.cwd()}/json/#{file}" | |
for x in raw.data | |
dataMap[x.id] = x |
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
val rules = Map(3 -> "fizz", 5 -> "buzz") | |
for { | |
i <- 1 to 100 | |
val out = rules.map { case (m, w) => if (i % m == 0) Option(w) else None }.flatten.reduceOption(_ + _).getOrElse(i) | |
} println(out) | |
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
Q = require('q') | |
sinon = require('sinon') | |
sinonChai = require('sinon-chai') | |
chai.use(sinonChai) | |
sinon.should() | |
describe 'testing promises', -> | |
aDeferred = Q.defer() | |
bDeferred = Q.defer() |
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
Q = require('q'); | |
sinon = require('sinon') | |
sinonChai = require('sinon-chai'); | |
chai.use(sinonChai); | |
sinon.should() | |
describe('testing promises', function() { | |
var aDeferred, bDeferred, moduleA, moduleB; | |
aDeferred = Q.defer(); |