Skip to content

Instantly share code, notes, and snippets.

@thebiltheory
thebiltheory / timezones.json
Last active Apr 18, 2020 — forked from erdem/timezone_locations.py
Center location coordinates for timezones
View timezones.json
{
"Africa/Abidjan": [8, -5],
"Africa/Accra": [8, -2],
"Africa/Addis_Ababa": [8, 38],
"Africa/Algiers": [28, 3],
"Africa/Asmara": [15, 39],
"Africa/Bamako": [17, -4],
"Africa/Bangui": [7, 21],
"Africa/Banjul": [13.46666666, -16.56666666],
"Africa/Bissau": [12, -15],
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View fetchRetry.ts
function waitFor(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default async function fetchRetry(promise: Promise<unknown>, n: number, waitNseconds = 1000): Promise<unknown> {
try {
return await promise;
} catch (error) {
if (n === 1) throw error;
@thebiltheory
thebiltheory / useReduxPolling.ts
Created Feb 12, 2020
Dispatch a redux action every (n) seconds
View useReduxPolling.ts
import { useEffect, useRef } from 'react';
import { useDispatch } from 'react-redux';
function useReduxPolling(action: any, interval = 2000): void {
const dispatch = useDispatch();
const callback = useRef(action);
useEffect(() => {
callback.current = action;
View commitMessageConventions.md

FORMAT:

<type>[optional scope]: <description>

[optional body]

[optional footer]
View image_optimization.md

Optimize Images

  • Status: [proposed]
  • Deciders: [Hakim, Omar, Felix, Bil]
  • Date: [2019-06-13]

Technical Story: [description | ticket/issue URL]

Context and Problem Statement

View parseHtml.js
import parse from "html-react-parser";
import DOMPurify from "dompurify";
export default function parseHtml(response) {
if (response) {
const dirty = response;
const clean = DOMPurify.sanitize(dirty);
return parse(clean);
}
}
View response.json
{
"currency":"EUR",
"deals":[
{
"transport":"train",
"departure":"London",
"arrival":"Amsterdam",
"duration":{
"h":"05",
"m":"00"
@thebiltheory
thebiltheory / curry.js
Created Dec 19, 2017
Add some curry to your functions
View curry.js
let curry = function (tocurry) {
const params = Array.prototype.slice.call(arguments, 1);
return function () {
return tocurry.apply(this, params.concat(
Array.prototype.slice.call(arguments, 0)
));
};
};
@thebiltheory
thebiltheory / README-Template.md
Created Dec 4, 2017 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites