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
// Thanks to Jake Trent for the tip on how to do this | |
// https://jaketrent.com/post/react-dnd-text-drag-preview/ | |
// Create the canvas | |
const c = document.createElement('canvas'); | |
const ctx = c.getContext('2d'); | |
const body = document.querySelector('body'); | |
body.appendChild(c); |
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 partial1 = function partial(fn) { | |
// Drop the function from the arguments list and | |
// fix arguments in the closure. | |
const args = [].slice.call(arguments, 1); | |
// Return a new function with fixed arguments. | |
return function() { | |
// Combine fixed arguments with new arguments | |
// and call fn with them. | |
const combinedArgs = args.concat( |
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
class Map extends Component { | |
loadIncidents = () => { | |
const { project, baseMapApi } = this.props; | |
this.incidentEntrySource = new VectorSource({ | |
format: new GeoJSON(), | |
url: `${baseMapApi}path/to/resource/${project.id}` | |
}); | |
this.incidentEntryLayer = new VectorLayer({ | |
source: this.incidentEntrySource, |
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
// I found this somewhere, but cannot remember where. | |
// feel free to leave a comment if you'd like to claim it. | |
const wrap = function(min, max, v) { | |
const rangeSize = max - min; | |
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min; | |
}; |
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 "parser" of an object similar to classnames. | |
* Includes the key and value when the include prop is truthy | |
* Filters out the key/value otherwise. | |
*/ | |
const reduce = require('lodash/fp/reduce'); | |
const toPairs = require('lodash/fp/toPairs'); | |
const compose = require('lodash/fp/compose'); |
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
if (remix.isAwesome) { | |
return "Tell your friends"; | |
} else { | |
return "Demand a refund!"; | |
} |
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
if (remix.isAwesome) { | |
return "Tell your friends"; | |
} else { | |
return "Demand a refund!"; | |
} |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
OlderNewer