Skip to content

Instantly share code, notes, and snippets.

let wait = new Promise(resolve => resolve(), ms)
@jdx
jdx / split_once.js
Last active October 10, 2016 12:58
Split() in JS like in every other language
let splitOnce = (str, c) => {
let [a, ...b] = key.split(c)
return [a, b.join(c)]
}
let [a, b] = splitOnce('foo=bar=baz', '=')
// a === foo
// b === bar=baz
@jdx
jdx / gulp-client.js
Last active August 11, 2016 23:56
Simple React gulp/client.js
'use strict'
const gulp = require('gulp')
const browserify = require('gulp-browserify')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
gulp.task('client:build', () => {
return gulp.src('./client/app.jsx')
.pipe(browserify({
@jdx
jdx / gulpfile.js
Last active August 11, 2016 23:49
Simple React gulpfile.js
'use strict'
const fs = require('fs')
const gulp = require('gulp')
const path = require('path')
fs.readdirSync(path.join(__dirname, 'gulp'))
.filter(f => f.endsWith('.js'))
.forEach(module => require('./gulp/' + module))
@jdx
jdx / app.jsx
Created August 11, 2016 23:19
Simple React super basic react jsx
const React = require('react')
const ReactDOM = require('react-dom')
class App extends React.Component {
render () {
return <div>
<h1>Hello world!</h1>
</div>
}
}
@jdx
jdx / index.html
Created August 11, 2016 23:13
Simple React index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple React</title>
</head>
<body>
<div id="app"></div>
<script src="/app.js"></script>
</body>
@jdx
jdx / server.js
Last active August 11, 2016 23:06
Simple React Basic Fileserver
'use strict'
const koa = require('koa')
const send = require('koa-send')
const path = require('path')
const app = koa()
app.use(require('koa-compress')())
app.use(require('koa-logger')())
app.use(require('koa-static')('public'))
'use strict'
const fs = require('fs-extra')
const path = require('path')
const os = require('os')
class Config {
constructor () {
this._path = path.join(os.homedir(), '.config', 'heroku', 'config.json')
this._read()
@jdx
jdx / words
Last active July 12, 2016 15:08
love - like
much - many
child - kid
large - big
deal - sale
companion - partner
trash - junk
above - over
specify - designate
capitulate: cease to resist an opponent or an unwelcome demand; surrender: the patriots had to capitulate to the enemy forces.

It's just as if a man were wounded with an arrow thickly smeared with poison. His friends & companions, kinsmen & relatives would provide him with a surgeon, and the man would say, 'I won't have this arrow removed until I know whether the man who wounded me was a noble warrior, a priest, a merchant, or a worker.' He would say, 'I won't have this arrow removed until I know the given name & clan name of the man who wounded me... until I know whether he was tall, medium, or short... until I know whether he was dark, ruddy-brown, or golden-colored... until I know his home village, town, or city... until I know whether the bow with which I was wounded was a long bow or a crossbow... until I know whether the bowstring with which I was wounded was fiber, bamboo threads, sinew, hemp, or bark... until I know whether the shaft with which I was wounded was wild or cultivated... until I know whether the feathers of the shaft with which I was wounded were those of a vulture, a stork, a hawk, a peacock, or another bird...