Skip to content

Instantly share code, notes, and snippets.

View jtschoonhoven's full-sized avatar

Jonathan Schoonhoven jtschoonhoven

View GitHub Profile
@jtschoonhoven
jtschoonhoven / Simple Screenplay Formatter [Google Docs Script]
Created December 28, 2022 01:40
A Google Docs Script for screenplay formatting.
/**
* @OnlyCurrentDoc
*
* The above comment directs Apps Script to limit the scope of file
* access for this add-on. It specifies that this add-on will only
* attempt to read or modify the files in which the add-on is used,
* and not all of the user's files. The authorization request message
* presented to users will reflect this limited scope.
*/
import os
import sys
from jinja2 import Environment, FileSystemLoader
from typing import Dict, Union
def render(
infile: str,
outfile: str = None,
data: Dict[str, Union[str, int]] = None,
@jtschoonhoven
jtschoonhoven / create-tor-heroku-app.sh
Created May 2, 2020 19:05
Deploying a Tor Hidden Service to Heroku in 5 Minutes
# ###############################
# Part 1: Create a new Heroku app
# ###############################
# Give your app a unique name
APP_NAME="my-secret-app"
# Create your project in a new repo
# This example uses React but you can use whatever you like
npx create-react-app $APP_NAME
@jtschoonhoven
jtschoonhoven / index.ts
Created April 13, 2020 21:01
Detect membership in string literal union type with type guard (intentionally does not compile)
const myStrings = ['A', 'B', 'C', 'D'] as const;
type MyStrings = typeof myStrings[number]
function isMyString(candidate: string): candidate is MyStrings {
const valid: typeof myStrings = ['A', 'B', 'C']; // Error! `valid` is not `typeof myStrings
return valid.indexOf((candidate as MyStrings)) !== -1;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.