Skip to content

Instantly share code, notes, and snippets.

View robbeman's full-sized avatar

Robbe Clerckx robbeman

View GitHub Profile
@robbeman
robbeman / HeadwayWidget.jsx
Created April 21, 2020 18:47
Headway react component
/* global Headway */
import React, { memo } from 'react';
const HW_CONFIG_ACCOUNT = 'your-id-here'; // get this from env-variables
const ELEMENT_ID = 'headway-updates-widget';
function HeadwayWidget() {
// No need to render if no account is configured
if (!HW_CONFIG_ACCOUNT) {
return null;
@robbeman
robbeman / sortCoordinates.js
Last active April 25, 2019 07:27
Simple coordinate sorting
/**
* Sorting markers in rows from left to right. Because geolocation can be pretty
* detailed we can't just sort it as is, we need a math to make it feel natural.
*
* How this works:
* - Prioritise sorting on latitude (y-axis)
* - multiply the difference and round it this will "group" locations in rows.
* - 30 is an arbitrary value that felt good in my case, higher values will make tighter rows.
* - (Using `1` as multiplier you will see the sorting jumps long distances from left to right.)
* - If 0 (same row), sort by longitude, with full precision
@robbeman
robbeman / mongo_import.sh
Last active November 29, 2019 07:34
Mongo import shell script
#!/usr/bin/env bash
# Import collections in a specified folder to your mongo database
# requires 2 arguments
# 1) the database to import to
# 2) the folder containing the collections to import
# example usage
# sh mongo_import.sh dev ~/Documents/PROJECTS/example/mongo\ export
if [ -z ${1+x} ] || [ -z ${2+x} ]; then
@robbeman
robbeman / javascript lerp
Last active February 12, 2019 15:57
linear interpolation
/*handy arrow function definitions*/
/*
const lerp = (a,b,x) => a+x*(b-a);
const qarp = (a,b,c,x) => lerp(lerp(a,b,x),lerp(b,c,x),x);
const unlerp = (a,b,y) => (y-a)/(b-a);
const lerpUnlerp = (a, b, c, d, x) => a+((x-c)/(d-c))*(b-a);
*/
/**
* Linear interpolation