Skip to content

Instantly share code, notes, and snippets.

Heads down

tiff twhite96

Heads down
View GitHub Profile

Keybase proof

I hereby claim:

  • I am twhite96 on github.
  • I am tiffanyrwhite ( on keybase.
  • I have a public key ASA5Nx3oT2IS58_RK9yLdqB4-J3oBf9149o1Ka1wBoihJgo

To claim this, I am signing this object:

twhite96 / session.server.ts
Created Mar 21, 2022 — forked from kentcdodds/session.server.ts
Authentication in Remix applications
View session.server.ts
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
twhite96 / base64ArrayBuffer.js
Created Jan 28, 2022 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
View base64ArrayBuffer.js
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
twhite96 /
Created Sep 18, 2021 — forked from vmassuchetto/
Shell script cron job to download YouTube videos from your subscription feed
# Script to keep downloading YouTube videos to your computer using youtube-dl:
# Put it to work:
# sudo wget "" -O /etc/cron.hourly/
# sudo chmod +x /etc/cron.hourly/
twhite96 / index.js
Created Sep 26, 2020 — forked from kyleshevlin/index.js
Boolean operators don't distribute
View index.js
// I see this mistake often (and have made it myself before)
// What's the bug with this function?
function isFavSeason(season) {
return season === 'spring' || 'summer' ? 'yes' : 'no'
// Let's try it and find out
console.log(isFavSeason('spring')) // yes
console.log(isFavSeason('summer')) // yes
twhite96 /
Created Sep 3, 2020 — forked from wosephjeber/
Find and kill ruby process using specified port
# Puma occasionally doesn't kill all ruby processes when
# I shut down my local web server. Here are the steps
# to find and kill the processes.
# Find pid of process running on specified port
lsof -i :3000
# Kill process
sudo kill -9 [pid]
View tweet-when-to-use-generators-iterators.js
// Builds array of everything ahead of time
function collectAllItems() {
return [calculateFirst(), calculateSecond(), ...]
// This loop will end as soon as `isMatch(item)` is truthy.
// If the very first item in the array is a match, then we
// wasted all this time building the array in the first place.
for (let item of collectAllItems()) {
if (isMatch(item)) {

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
twhite96 / example.js
Created Jan 22, 2020 — forked from hwangbible/example.js
Scriptablify - lets you require('modules') in Scriptable app!
View example.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: gray; icon-glyph: magic;
// Defaults to the latest version and no automatic update; if the file exists, just use it
const moment = await require('moment');
// Use any SemVer options to specify a version you want
// Refer to the calculator here:
const lodash = await require('lodash@^3.9.1');