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
creating custom Graphql Types | |
https://github.com/stylesuxx/graphql-custom-types/blob/master/src/scalars.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
export default function formCollectionToPlainObject(HTMLFormControlsCollection) { | |
return Object.entries(HTMLFormControlsCollection).reduce((acc, [key, value]) => { | |
return { | |
...acc, | |
[key]: value.value | |
}; | |
}, {}); | |
} |
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
export default ( | |
process.env.NODE_ENV === "production" | |
? require("./productionStore").default | |
: require("./developmentStore").default | |
); |
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 injectProps(options) { | |
return function(InitialComponent) { | |
return function DndStateInjector() { | |
return <InitialComponent {...options} />; | |
}; | |
}; | |
} |
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
import React, { Component } from "react"; | |
import _ from "lodash"; | |
export default class Example extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
uid: "", |
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 distanceBetweenPoints(p1, p2) { | |
// http://www.mathwarehouse.com/algebra/distance_formula/index.php | |
// https://stackoverflow.com/questions/20916953/get-distance-between-two-points-in-canvas | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot | |
// or | |
// Math.sqr((p2.x - p1.x) + (p2.y - p1.y)) | |
return Math.hypot(p2.x - p1.x, p2.y - p1.y) | |
} |
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
import { | |
GraphQLID, | |
GraphQLInt, | |
GraphQLString, | |
GraphQLObjectType, | |
GraphQLList, | |
GraphQLNonNull, | |
OrderTypeEnum, | |
GraphQLUnionType, | |
GraphQLInterfaceType, |
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 tests = [true, false, true] | |
const finalTest = tests.reduce((acc, val) => { | |
return acc && val | |
}, true); | |
console.log(finalTest) |
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
// https://stackoverflow.com/questions/14224535/scaling-between-two-number-ranges | |
function withinRange(val, { min, max }) { | |
return ( | |
val > max | |
? max | |
: val < min | |
? min | |
: val | |
); |
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
export default function popup(url, {name='', width=500, height=500}={}) { | |
// References | |
// https://developer.mozilla.org/en-US/docs/Web/API/Window/open | |
let options = ` | |
width=${width}, | |
height=${height}, | |
left=${window.screenX + ((window.outerWidth - width) / 2)}, | |
top=${window.screenY + ((window.outerHeight - height) / 2)} | |
` |