Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
3ZsForInsomnia / discriminated-unions.ts
Last active Jul 28, 2020
Typescript expressive types workshop examples
View discriminated-unions.ts
* `kind` is what is called a "discriminator", as it allows us to determine (at runtime)
* what type the returned data is, _without_ relying on introspection of the values in the data.
* This let's us do "if (claim.kind === 'prescription') ...", which is much less fragile or "hacky" than
* "if (Object.keys(claim).includes('surgeryType') ..."
type surgicalProcedure = { kind: 'surgicalProcedure'; surgeryType: string };
type prescription = { kind: 'prescription'; refillsAllowed: number; medicationName: string };
View Simple HTTP server
#!/usr/bin/env python3
Very simple HTTP server in python for logging requests
./ [<port>]
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
3ZsForInsomnia / funWithPatternMatching.ts
Created Jan 11, 2020
Exploring a ts article on scala's pattern matching and another approach
View funWithPatternMatching.ts
interface IShape {
area: number;
sayHi(...args: any[]): string;
type: string;
interface Circle extends IShape {
type: 'circle';
interface Rectangle extends IShape {
3ZsForInsomnia / lensCompositionFun.js
Created Jan 2, 2020
Simple example of nice, clean lens composition in ramda using a helper
View lensCompositionFun.js
const nameLens = R.lensProp('name');
const user = {
name: 'Joe',
age: 34,
isLoggedIn: true,
address: {
number: 123,
street: 'best'
3ZsForInsomnia /
Last active Dec 25, 2019
Set latest config using gist cli
gist -u 234409331d0e01851a5e4cf1402c604d ~/
gist -u 005449d0adaa90d798f4bc0b93bebe27 ~/.bookmarks
brew list > brewList.txt
gist -u 8dade12e382afa0be6ee59d1b6b73d05 ~/brewList.txt
gist -u 903202277e1f22dd06fbc7127363c795 ~/.bashrc
gist -u d968207d98c8984849ca2f7349e8ac48 ~/.bash_profile
gist -u ed2ac2193c29b43b07a56ffb5b55d8fd ~/.vimrc
gist -u f05dabf617e353a98f5faa051704dafb ~/.zshrc
3ZsForInsomnia /
Last active Dec 25, 2019
Pull the latest config using gist cli
# get
curl >
chmod +x
# get
curl >
chmod +x
# get bookmarks for zshmarks
curl > .bookmarks
View .nvimrc
set syntax=on
syntax on
set noswapfile
set ignorecase
set spelllang=en
set spellfile=~/.vim/spell/en.utf-8.add
set nospell
3ZsForInsomnia / abstracted-extensions.js
Last active Mar 15, 2018
A React component that shows a comparison of checks using no constants, with open checks of constants, and with abstracted constants
View abstracted-extensions.js
import React from 'react'
const teacher = 'teacher';
const student = 'student';
const isTeacher = (userType) => {
return userType === teacher;
const isStudent = (userType) => {
3ZsForInsomnia / detectWhenPageIsLoaded.js
Last active Feb 12, 2018
Quick, ES5-based method for detecting when a page has (probably) fully loaded without relying on the "onload" event
View detectWhenPageIsLoaded.js
* Explanation of approach
* Check if an element exists with the tag, class, or id of "loading"
* Wait half of interval for things to load/setup/render
* If a "loading" element was found, check if it is visible every time the interval fires
* If the targeted element is not visible when checked, assume loading is complete
* If the targeted element is visible but is changed after the initial timeout, assume that loading is complete
* If no "loading" element is found, then watch <body> for changes
* This causes us to check for when <body> has not been modified for 3 seconds
* While this does add performance overhead (it is called every time <body> or any element below it is modified,
3ZsForInsomnia / video-player-excerpt.jsx
Last active Dec 1, 2017
Example of method wrapped usage of constants
View video-player-excerpt.jsx
// Import the constants file
const VideoPlayerComponent = React.createClass({
getInitialState: function() {
return {
// Default view - it does not matter how or when it is updated, so that is left out
view = views.viewing
render: function() {