Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🌾
out on the farm

Franklin Harvey franklinharvey

👨‍🌾
out on the farm
View GitHub Profile
@franklinharvey
franklinharvey / minified.js
Last active Dec 6, 2020
I needed to transform dates in an HTML file to be in "MMM YYYY" format without using any dependencies. This is how I did it using vanilla JS. This can be pasted directly into a dev-tools console to test.
View minified.js
const dateFields=document.getElementsByClassName("blog-date"),monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"],transformDate=e=>{const t=new Date(e.innerHTML);return`${t.getDate()} ${monthNames[t.getMonth()]} ${t.getFullYear()}`};dateFields.forEach(e=>{e.innerHTML=transformDate(e)});
View keybase.md

Keybase proof

I hereby claim:

  • I am franklinharvey on github.
  • I am frankfrank (https://keybase.io/frankfrank) on keybase.
  • I have a public key ASB-O9aIr7bp-ZeNwSB92ZxTep-Gy_FklxWGVeOgto-cWAo

To claim this, I am signing this object:

@franklinharvey
franklinharvey / FullJitter.ts
Last active May 3, 2020
Full Jitter Exponential Backoff Algorithm
View FullJitter.ts
const BASE_TIMEOUT = 5 // in milliseconds, you can change this
const getTimeout = (attempt: number): number => {
const backoff = BASE_TIMEOUT * Math.pow(2, attempt) // exp. increases the timeout per attempt
const backoff_or_cap = Math.min(1000, backoff) // cap the timeout at 1 sec.
const ret = sample([0, backoff_or_cap]) // randomly choose between 0 and the backoff, this is the "jitter" part
return ret
}
// randomly choose from an array, a replacement of lodash's sample method
const sample = (arr: number[]) => {
@franklinharvey
franklinharvey / DraggableMarker.md
Last active Jan 7, 2021
Google Maps API v3.0 and react-google-maps snippets
View DraggableMarker.md

Kind of a barebones approach to draggable markers, saving the new position in state By Franklin Harvey

interface MarkerProps {
    position: google.maps.LatLng
    onDragMarker(e: google.maps.MouseEvent): void
}
@franklinharvey
franklinharvey / force_empty_trash.sh
Last active Aug 19, 2018 — forked from emotality/force_empty_trash.sh
Force empty Trash after placing Time Machine backups in trash, for all volumes in OSX (including connected drives).
View force_empty_trash.sh
#!/bin/bash
#### Created by Jean-Pierre Fourie
#### Editted by Franklin Harvey
### https://github.com/emotality
### https://github.com/franklinharvey
## force_empty_trash.sh
#
clear
echo " "
@franklinharvey
franklinharvey / Rectangle Comparison.md
Created Jan 5, 2018
A comparison of 100x100 rectangles from Illustrator, Sketch, and Figma in SVG format.
View Rectangle Comparison.md

Illustrator:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
<g>
	<path d="M99,1v98H1V1H99 M100,0H0v100h100V0L100,0z"/>
</g>