Skip to content

Instantly share code, notes, and snippets.

View twhite96's full-sized avatar
☢️
Cookin

tiff twhite96

☢️
Cookin
View GitHub Profile
@twhite96
twhite96 / nested-object-destructuring.js
Created November 24, 2022 05:09
Nested object destructuring
const cats = {
one: {
name: "Molly",
owner: "Fred Larkin",
color: "Brown",
age: 10,
kittens: 0
},
two: {
name: "Bob",
@twhite96
twhite96 / example.js
Created January 22, 2020 15:03 — forked from hwangbible/example.js
Scriptablify - lets you require('modules') in Scriptable app!
// 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: https://semver.npmjs.com/
const lodash = await require('lodash@^3.9.1');
@twhite96
twhite96 / script.rb
Created September 14, 2022 22:31 — forked from seancdavis/script.rb
Move files up one directory in Ruby
require 'fileutils'
path = File.expand_path('../', __FILE__)
Dir.glob("#{path}/**/*.*").each do |file|
new_path = "#{path}/#{file.split('/')[-1]}"
FileUtils.mv(file, new_path)
end
@twhite96
twhite96 / requests.js
Created May 5, 2019 03:31 — forked from yoav-lavi/requests.js
request module for Scriptable
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
module.exports = {
post: async ({ url, body, headers = {} }) => {
const request = new Request(url);
request.body = JSON.stringify(body);
request.method = methods.post;
request.headers = {
...defaultHeaders,
@twhite96
twhite96 / 0.md
Created July 13, 2022 00:49 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)

Keybase proof

I hereby claim:

  • I am twhite96 on github.
  • I am tiffanyrwhite (https://keybase.io/tiffanyrwhite) on keybase.
  • I have a public key ASA5Nx3oT2IS58_RK9yLdqB4-J3oBf9149o1Ka1wBoihJgo

To claim this, I am signing this object:

@twhite96
twhite96 / session.server.ts
Created March 21, 2022 07:05 — forked from kentcdodds/session.server.ts
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@twhite96
twhite96 / base64ArrayBuffer.js
Created January 28, 2022 21:25 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// 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:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
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
twhite96 / youtube-dl-cron.sh
Created September 18, 2021 02:24 — forked from vmassuchetto/youtube-dl-cron.sh
Shell script cron job to download YouTube videos from your subscription feed
#!/bin/bash
#
# Script to keep downloading YouTube videos to your computer using youtube-dl:
# http://rg3.github.io/youtube-dl/
#
# Put it to work:
#
# sudo wget "https://gist.github.com/vmassuchetto/10338703/raw" -O /etc/cron.hourly/youtube-dl-cron.sh
# sudo chmod +x /etc/cron.hourly/youtube-dl-cron.sh