Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
//Example Usage of custom control
export default ({lat, lng, google}) => (
<GoogleMap
defaultCenter={{lat, lng}}
defaultZoom={14}
minZoom={6}
google={google}
containerStyle={{ height: '575px', width: '100%', position: 'relative' }}
>
<Marker position={{lat, lng}} />
const lastNotNull = (arr) => arr[arr.length - 1] ? arr[arr.length - 1] : lastNotNull(arr.slice(0, -1))
const values = [1, 3, 5, 2, null, null]
console.log(lastNotNull(values))
function unique(arr, func) {
const uniques = arr.reduce((o, k) => func(k) in o ? o : Object.assign(o, {[func(k)]: k}), {})
return Object.keys(uniques).map(k => uniques[k])
}
const numbers = [ 1, 2, 3, 5, 7, 22, 34, 56, 234]
const average = numbers.reduce(runningAverage)
function runningAverage (average, current, idx) {
return (average * idx + current) / (idx + 1)
}
var mapValues = function mapValues(obj, map) {
return Object.keys(obj).reduce(function (o, k) {
return Object.assign(o, _defineProperty({}, k, map(obj[k])));
}, {});
}
<html>
<head>
<title>
Audio
</title>
</head>
<body>
<audio id="myAudio" autoplay preload="auto" class="audio--source">