index | c | mu |
---|---|---|
1 | 2 | 3 |
This file contains hidden or 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
Using Jest CLI v0.4.13 | |
FAIL __tests__/foo-test.js (0.896s) | |
● foo() › it should throw | |
- Expected function to throw an exception. |
This file contains hidden or 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
#include <chrono> | |
#include <iostream> | |
#include <thread> | |
#include <vector> | |
using namespace std; | |
int main() { | |
vector<thread> workers; |
This file contains hidden or 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
#include <iostream> | |
#include <thread> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<thread> workers; | |
for (int i = 0; i < 5; ++i) |
This file contains hidden or 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
List<Runnable> actions = new ArrayList<Runnable>(); | |
for (int counter = 0; counter < 10; counter++) { | |
final int copy = counter; // notice the `final` keyword! | |
actions.add(new Runnable() { | |
public void run() { System.out.println(copy); } | |
}); | |
} |
This file contains hidden or 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
List<Runnable> actions = new ArrayList<Runnable>(); | |
for (int counter = 0; counter < 10; counter++) | |
{ | |
final int copy = counter; // notice the `final` keyword! | |
actions.add(() -> { System.out.println(copy); }); | |
} |
This file contains hidden or 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
List<Action> actions = new List<Action>(); | |
for (int counter = 0; counter < 10; counter++) | |
{ | |
int copy = counter; // block-scoping in action!! | |
actions.Add(() => Console.WriteLine(copy)); | |
} |
This file contains hidden or 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
// immutable version | |
const map = arr => | |
arr.reduce((prev, cur) => prev.concat(cur), []); | |
// mutable version | |
const map = arr => | |
arr.reduce((prev, cur) => { | |
prev.push(cur); | |
return prev; | |
}, []); |
This file contains hidden or 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
const Bluebird = require('bluebird'); | |
const fs = Bluebird.promisifyAll(require('fs')); | |
const getFilenamesContainingMichaelAsync = Bluebird.coroutine(function* (path) { | |
const filenames = yield fs.readdirAsync(path); | |
return filenames.filter(name => name.indexOf('Michael') !== -1); | |
}); | |
Bluebird.coroutine(function* () { | |
const filenamesContainingMichael = yield getFilenamesContainingMichaelAsync('~/some_dir'); |
This file contains hidden or 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
for (let i = 0; i < domElems.length; ++i) { | |
domElems[i].addEventListener('click', () => { | |
console.log(i); | |
}); | |
} |
NewerOlder