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
#!/bin/bash | |
if [[ $NODE_ENV != production ]]; then | |
echo 'start: This is intended for production, use `npm run serve` instead' | |
exit 1 | |
fi | |
test -f .env && source .env | |
penguin run \ | |
--port "${PORT=3000}" \ | |
--database-driver [ penguin.js/pg --url "$DATABASE_URL" ] \ |
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
const routes = [ | |
{ path: '/api/v1/websites/:website', method: 'GET', service: getWebsite }, | |
{ path: '/api/v1/websites/:website', method: 'POST', service: createWebsite } | |
] | |
const notFound = (req, res) => res.end('Not found') | |
const api = proxyHandler(routes, { fallback: notFound }) | |
http.createServer(api).listen(3000) |
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
'use strict' | |
const fs = require('fs') | |
const vm = require('vm') | |
const cluster = require('cluster') | |
const shortid = require('shortid') | |
if (cluster.isMaster) { | |
// Act as master | |
cluster.on('online', worker => { |
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
#!/bin/bash | |
for component in src/components/*; do | |
echo $component | |
browserify \ | |
--extension .jsx \ | |
-t babelify \ | |
-t rollupify \ | |
-s $(basename $(basename $component .js) .jsx) \ | |
-o components/$(basename $(basename $component .js) .jsx).js \ |
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
class Todos extends Component { | |
constructor() { | |
super(); | |
this.state.todos = [{ name: 'Foo' }, { name: 'Bar' }]; | |
} | |
onChange(todo, name) { | |
this.setState({ | |
todos: this.state.todos.map( | |
(t, i) => i === todo ? { name } : t |
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
'use strict'; | |
const io = require('run-io'); | |
function performingIO(done) { | |
console.log('Heay IO ...'); | |
setTimeout(() => done(42), 1000); | |
} | |
function *myGenerator() { |
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 *myGenerator() { | |
const a = yield { fn: performingIO }; | |
return a; | |
} | |
const it = myGenerator(); | |
assert.deepEqual(it.next(), { value: { fn: performingIO }, done: false }); | |
assert.deepEqual(it.next(34), { value: 34, done: true }); |
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 performingIO(done) { | |
console.log('Heay IO ...'); | |
setTimeout(() => done(42), 1000); | |
} | |
function *myGenerator() { | |
const a = yield { fn: performingIO }; | |
return a; | |
} |
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 *myGenerator() { | |
const a = yield 2; | |
return a; | |
} | |
const it = myGenerator(); | |
it.next(); // => { value: 2, done: false } | |
it.next('hello') // => { value: 'hello', done: true } |
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
'use strict'; | |
const assert = require('assert'); | |
// Simple goal is to push out side-effects for testability | |
function liftMethod(ctx, method, opts) { | |
return lift(ctx[method], Object.assign({ ctx }, opts || {})); | |
} | |
function lift(fn, opts) { |
NewerOlder