Skip to content

Instantly share code, notes, and snippets.

View jamigibbs's full-sized avatar

Jami Gibbs jamigibbs

View GitHub Profile
<div class="some-content">
{{#if (prod)}}
<p>Seen only in production</p>
{{/if}}
<p>This is some example text</p>
</div>
<div class="some-content">
{{#if prod}}
<p>Seen only in production</p>
{{/if}}
<p>This is some example text</p>
</div>
const Handlebars = require('handlebars')
Handlebars.registerHelper('prod', () => {
return process.env.NODE_ENV === 'production';
})
<div class="entry">
{{!-- only output author name if an author exists --}}
{{#if author}}
<h1>{{author.firstName}} {{author.lastName}}</h1>
{{/if}}
</div>
export const getNearestDivvyStation = (lat, lng) => {
const url = `${GOOGLE_PLACES_URL}?location=${lat},${lng}&radius=1000&type=point_of_interest&keyword=divvy&key=${API_KEY}`
return async (dispatch) => {
const { data } = await axios.get(url)
const current = {lat, lng}
const closest = data.results.map((station) => {
const coord = station.geometry.location
const closest = distance.sort( (a, b) => a.dist - b.dist )[0]
const distances = [
{
"coord": {
"lat": 41.8921794,
"lng": -87.6366551,
},
"dist": 396,
},
{
"coord": {
// User's current location
const current = {lat, lng}
const closest = data.results.map((station) => {
const coord = station.geometry.location
return { coord, dist: geolib.getDistance(current, coord) }
})
const coords = [
{
"lat": 41.8921794,
"lng": -87.6366551,
},
{
"lat": 41.894652,
"lng": -87.638362,
},
{
import geolib from 'geolib'
// .....
const dist = coords.map((coord) => {
return { coord, dist: geolib.getDistance(current, coord) }
})