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
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
const axios = require('axios'); // promised based requests - like fetch() | |
function getCoffee() { | |
return new Promise(resolve => { | |
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
}); | |
} |
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
/** | |
* Create an ActionQueue and dispatch each synchronously | |
* @author tgroshon | |
* | |
* See an alternate implementation using ASync from | |
* https://github.com/facebook/flux/issues/106 | |
* by fabiozaffani | |
*/ | |
import {Dispatcher} from 'flux' |
Ever gotten this message?
fatal: Unable to create '/path/to/repo/.git/index.lock': File exists.
If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
A multi-level groupBy for arrays inspired by D3's nest operator.
Nesting allows elements in an array to be grouped into a hierarchical tree
structure; think of it like the GROUP BY
operator in SQL, except you can have
multiple levels of grouping, and the resulting output is a tree rather than a
flat table. The levels in the tree are specified by key functions.
See this fiddle for live demo.
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
// http://tile.openstreetmap.org/z/x/y.png | |
// example: http://tile.openstreetmap.org/12/2225/2367.png | |
lon2tile = (lon, zoom) => { | |
return (Math.floor((lon+180)/360*Math.pow(2,zoom))); | |
}; | |
lat2tile = (lat, zoom) => { | |
return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); | |
}; |
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
[].filter.call(document.querySelectorAll('.color-group .color'), function(el) { | |
return el.querySelector('.shade').textContent === 'A400'; | |
}).map(function (el) { | |
return el.querySelector('.hex').textContent; | |
}); |
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
/** | |
* removes duplicated objects with the specified prop | |
* @param {Array} myArr [our collection to check] | |
* @param {String} prop [name of the property to compare] | |
* @return {Array} [unique array] | |
*/ | |
removeDuplicates = (myArr, prop) => { | |
return myArr.filter((obj, pos, arr) => { | |
return arr.map(mapObj => mapObj[prop]).indexOf(obj[prop]) === pos; | |
}); |
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
/** | |
* Get a random floating point number between `min` and `max`. | |
* | |
* @param {number} min - min number | |
* @param {number} max - max number | |
* @return {float} a random floating point number | |
*/ | |
function getRandom(min, max) { | |
return Math.random() * (max - min) + min; | |
} |
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
/* @flow */ | |
var React = require("react") | |
var Immutable = require("immutable") | |
// In order to use any type as props, including Immutable objects, we | |
// wrap our prop type as the sole "data" key passed as props. | |
type Component<P> = ReactClass<{},{ data: P },{}> | |
type Element = ReactElement<any, any, any> |
NewerOlder