Skip to content

Instantly share code, notes, and snippets.

View ivalkenburg's full-sized avatar

ivalkenburg ivalkenburg

View GitHub Profile
export const interpolatedSteps = (geojson, numSteps = 4) => {
let minMax = [];
if (geojson.features.length < 1) {
minMax = [1, numSteps];
} else {
minMax = geojson.features.reduce((minMax, feature) => {
minMax[0] = Math.min(minMax[0] || feature.properties.hits, feature.properties.hits);
minMax[1] = Math.max(minMax[1], feature.properties.hits);
return minMax;
const distance = function(point1, point2) {
const R = 6371; // Radius of the earth in km
const dLat = (point2.lat - point1.lat) * Math.PI / 180;
const dLong = (point2.long - point1.long) * Math.PI / 180;
let a = 0.5 - Math.cos(dLat) / 2 + Math.cos(point1.lat * Math.PI / 180) * Math.cos(point2.lat * Math.PI / 180) * (1 - Math.cos(dLong)) / 2;
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
const box = {
sw: {long: -16.14990234375, lat: -26.980828590472107}, // bl
ne: {long: 39.7265625, lat: 20.632784250388028}, // tr
};
const points = [
{long: 21.62109375, lat: 3.601142320158735}, // inside
{long: -11.513671874999998, lat: 16.551961721972525}, // inside
{long: 28.4765625, lat: -19.228176737766248}, // inside
{long: 4.130859375, lat: 0.4394488164139768}, // inside
@ivalkenburg
ivalkenburg / errors.js
Created September 24, 2018 14:26
errors.js
import Vue from 'vue';
/**
* Handles laravel form requests errors.
*/
export class FormErrors {
constructor() {
this.setErrors({});
}
@ivalkenburg
ivalkenburg / guards.js
Created July 5, 2018 14:11
Vue-router guards
function guestGuard(routes) {
return routes.map(route => {
return {
...route,
beforeEnter: (to, from, next) => {
if(confirm('continue guest guard?')) {
next();
} else {
next(false);
}
<?php
class Resolver {
protected $container;
public function __construct($container)
{
$this->container = $container;
}