inns-blog
, inns-port
, ...
.. and gets a couple of scores (readibility, color, ...)
function a (callback) { | |
setTimeout(function () { | |
console.log('This is a'); | |
callback && callback(null); | |
}, 100); | |
} | |
function b (callback) { | |
setTimeout(function () { | |
console.log('This is b'); |
# encoding=utf-8 | |
import re | |
s = """It was a very cold evening, an old man was waiting for a ride across the river. He saw several horsemen pass by but he didn’t ask for any help. The wait seemed __1__(end).Then came another rider,the old man __2__(catch) his eye and said, “Sir, would you mind doing me a favor?” | |
Stopping his horse,he replied, “Of course.” Almost __3__(freeze), the old man could not get __4__ the ground. The horseman helped him onto his horse. He took the old man not just across the river,__5__ to his home. | |
“Sir, you didn’t even ask the other riders for help, why? What __6__ I had said ‘no’ and left you there?” the horseman asked. | |
The old man looked at him straight in the eyes and said, “I looked into their eyes, I found they didn’t care,__7__ told me it would be useless, but when I looked into __8__,I saw kindness.” | |
These words touched the rider deeply. “Thank you for __9__ you’ve said, I hope I will never be too busy to help others.” with that, Thomas Jefferson, the __10__(three) presid |
const range = (s, t = 0, a = 1) => [...Array(Math.abs(s - t))].map((x, i) => Math.min(s, t) + i * a).filter(x => x < Math.max(s, t)); | |
console.log(range(5)); | |
console.log(range(2, 5)); | |
console.log(range(0, 5, 2)); | |
// node.js: please run with `node --harmony_default_parameters --harmony range.js` |
var y = count(); | |
y.next(); | |
function *count() { | |
yield setTimeout(() => { console.log(1); y.next(); }, 1000); | |
yield setTimeout(() => { console.log(2); y.next(); }, 1000); | |
yield setTimeout(() => { console.log(3); y.next(); }, 1000); | |
yield setTimeout(() => { console.log(4); y.next(); }, 1000); | |
} |
function run(x, cb) { | |
var f; | |
if (this.constructor.constructor == (function*() {}).constructor) { | |
f = this; | |
} else { | |
f = x(); | |
} | |
var w = f.next(); | |
if (!w.done) { | |
setTimeout(() => { |
var $=(f,c,t,r)=>(r=(t=t||f()).next()).done?c&&c(r.value):setTimeout(()=>$(f,c,t),r.value); | |
$(function *() { | |
console.log(1); | |
yield 1000; | |
console.log(2); | |
yield 1000; | |
console.log(3); | |
yield 1000; | |
return 4; |
for (var i = 0; i < 3; ++i) { setTimeout(function () { console.log(i); }, 1000 * i); } | |
for (var i = 0; i < 3; ++i) { setTimeout(function (i) { console.log(i); }, 1000 * i, i); } |
let elements = [ | |
<div/>, | |
<div/> | |
]; | |
return React.createElement('div', null, ...elements); | |
// !!! using `<div>{elements}</div>` here will got a `unique key in array` error |
// Usage example: | |
// | |
// willTransitionTo(transition, params, query, callback) { | |
// observeStore(DraftStore, s => s.isLoaded()).then(() => { | |
// if (DraftStore.isMissingTitle()) { | |
// transition.redirect('composeDraft', params); | |
// } | |
// }).finally(callback); | |
// } |