Skip to content

Instantly share code, notes, and snippets.

View theverything's full-sized avatar
🙂
Writing code

Jeffrey Horn theverything

🙂
Writing code
View GitHub Profile
@theverything
theverything / kvtable.go
Created October 19, 2021 23:59
Golang Key Value Table
package kvtable
import (
"fmt"
"strings"
)
type Row struct {
Key string
Value string
@theverything
theverything / machine.js
Created October 5, 2021 20:52
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@theverything
theverything / bookmarks.json
Last active April 10, 2020 20:08
My Bookmarks
{}
@theverything
theverything / rsu-options-break-even.js
Created February 19, 2020 22:32
Calculate the break even of options vs RSUs
/**
*
* @param {number} multiplier The RSU to options ratio. A value of `3` would mean 3 options to 1 RSU.
* @param {number} strike The dollar amount of the options strike price.
*/
function calc(multiplier, strike) {
const percent = 1 / (multiplier - 1);
const currentPrice = strike * (percent + 1);
@theverything
theverything / machine.js
Last active February 11, 2020 22:55
Generated by XState Viz: https://xstate.js.org/viz
const kegbotMachine = new Machine(
{
id: "kegbot",
initial: "unauthenicated",
context: {
userID: null,
pourAmount: 0,
pourSelection: 0
},
@theverything
theverything / machine.js
Last active January 23, 2020 19:36
Generated by XState Viz: https://xstate.js.org/viz
const task = Machine({
id: 'task',
initial: 'loading',
states: {
loading: {
on: {
ERROR: 'error',
AVAILABLE: 'available',
},
},
@theverything
theverything / allSettled.ts
Last active October 4, 2019 21:31
allSettled
interface FulfilledPromise<T> {
status: 'fulfilled';
value: T;
}
interface RejectedPromise {
status: 'rejected';
reason: string;
}
@theverything
theverything / throttle.go
Created September 30, 2019 19:10
Throttle
package throttle
import (
"fmt"
"sync"
"time"
)
type concurrencyLock struct {
locker chan struct{}
@theverything
theverything / co-trottle.go
Created June 7, 2019 16:51
concurrent work with throttling
package main
import (
"fmt"
"log"
"strconv"
"strings"
"sync"
"time"
)
@theverything
theverything / konami.js
Created January 9, 2019 20:00
Konami Code
function konamiCode(cb) {
const UP = 38;
const DOWN = 40;
const LEFT = 37;
const RIGHT = 39;
const KONAMI_CODE = [UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT].join('-');
let keypresses = [];
let enabled = false;
let rootEl = null;
let passive = false;