fetch('/things/10', {
credentials: 'same-origin',
headers: {
'accept': 'application/json'
}
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
let UsernameField = (() => { | |
const _username = Symbol(); | |
const _handleNameChange = Symbol(); | |
return class UsernameField extends React.Component { | |
state = { | |
[_username]: 'DefaultUser', | |
} | |
[_handleNameChange] = (e) => { |
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
// A useful way of thinking about how the value of 'this' is bound in Javascript | |
// functions is to imagine that Function.prototype.call is being used | |
// implicitly at the call site to set the 'context' (the 'this' value). eg. | |
// assuming in each case | |
var o = {} | |
var o2 = {} | |
var fn = function(){} | |
// 1. bare function call |
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
import React from 'react/addons'; | |
export default function shallowRender(element) { | |
const shallowRenderer = React.addons.TestUtils.createRenderer(); | |
shallowRenderer.render(element); | |
return shallowRenderer.getRenderOutput(); | |
} |
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
import React from 'react'; | |
export default function flattenReactChildrenToArray(nodeChildren, accumulated = []) { | |
React.Children.forEach(nodeChildren, (childNode) => { | |
accumulated.push(childNode); | |
if (childNode && childNode.props && childNode.props.children) { | |
flattenReactChildrenToArray(childNode.props.children, accumulated); | |
} | |
}); | |
return accumulated; |
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 immutableJSFormatter = { | |
header(x) { | |
if (x && x.toJS) return ['span', {}, x.toString()]; | |
return null; | |
}, | |
hasBody(x) { | |
return x && x.toJS; | |
}, | |
body(x) { | |
return ['span', {}, JSON.stringify(x.toJS(), null, 2)]; |
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
var util = require('util'); | |
// nobody cares about warnings so lets make them errors | |
// keep a reference to the original console methods | |
var consoleWarn = console.warn; | |
var consoleError = console.error; | |
function logToError() { | |
throw new Error(util.format.apply(this, arguments).replace(/^Error: (?:Warning: )?/, '')); |
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
jest.dontMock('../getStuff'); | |
describe('getStuff', () => { | |
let getStuff; | |
let request; | |
let stuffStore; | |
it('loads the data', () => { | |
const id = 1; | |
const data = {a: 1}; |
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
var gm = require('gm'); | |
var glob = require('glob'); | |
var path = require('path'); | |
var fs = require('fs'); | |
const labels = []; | |
function pathWithSuffix(inpath, suffix) { | |
return path.join(path.dirname(inpath),path.basename(inpath,'.jpg')+suffix+'.jpg'); | |
} |
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
sony { | |
enable = 1 | |
# The floppy disk insertion delay. Set this to: | |
# 0: never automatically insert the disk | |
# 1: have the disk inserted immediately on startup. | |
# The System will then either boot from the disk or | |
# eject it. | |
# x: delay insertion by x (emulated) seconds. |