Skip to content

Instantly share code, notes, and snippets.


Zach Whalen zachwhalen

View GitHub Profile
zachwhalen / chessboard_novel.js
Last active Dec 1, 2020
A javascript macro for Bonnie Brunish's Chessboard Universe Generator
View chessboard_novel.js
// Go to and run this in a browser console
var txt = "";
while (txt.split(" ").length < 50000){
var yr = document.getElementById("Planet").innerText.split(" ")[2,3];
txt += "YEAR " + yr + "\n-----" + "-".repeat(yr.length) + "\n";
txt += document.getElementById("line0").innerText + "\n";
txt += document.getElementById("line1").innerText + "\n";
txt += document.getElementById("line1plus").innerText + "\n";
txt += document.getElementById("line2").innerText + "\n";
zachwhalen /
Last active Sep 12, 2019
This generates a poem from the input of a text file called "pride.txt". It relies on TextBlob.
from textblob import TextBlob
source = open('/path/to/file.txt')
np = TextBlob(
def sentenceLength(sent):
return len(sent)
def filter(sent):
for ex in ["Chapter","Section",'\'']:
View game.txt
zachwhalen /
Created Nov 6, 2018
Another rainy day novel for NaNoGenMo
# because we need randomness
import random
# create a variable to store the lines
lines = []
# iterate through 75 columns
for c in range(75):
# add something to each column 5000 times
zachwhalen /
Last active Nov 6, 2018
A generated novel for a rainy day.
# because we always need randomness
import random
# create a variable to store the novel as it's being written
novel = ''
# iteration
for i in range(50000):
# add this word to the "novel" 50,000 times
novel += " DRIP"
zachwhalen /
Last active Oct 10, 2018
A python counter for quantifying the number of possible variations for a Tracery grammar
import json
import re
# find out if a given chunk includes symbols
def get_symbols(phrase):
matches = re.finditer(r"#.*?#", phrase, re.MULTILINE)
symbols = []
for matchNum, match in enumerate(matches):
matchNum = matchNum + 1
symbols.append( re.sub(r"\.a|\.s|\.capitalize|#","", )
View botcode.json
"origin": ["this could be a tweet", "this is #alternatives# tweet", "#completely different#"],
"alternatives" : ["an example", "a different", "another", "a possible", "a generated", "your next"],
"completely different" : ["and now for something completely different", "so long and thanks for all the fish", "or, maybe, #alternatives# badger"]
zachwhalen /
Last active Jun 2, 2018
A bash script to create and open a new text file with the appropriate header for a blog post in a Pico site.
nn() {
# the header template
Title: Untitled Note
Template: blog-post
Description: New Note
Date: $(date)
zachwhalen /
Created Dec 16, 2016
A quick and clunky way to make one of those videos where it speeds up every time something happens. Uses MoviePy.
# use this script to make one of those videos where it speeds up
# every time something happens
# this has only been tested on a Mac with Python 2.7
# Also, moviepy is picky about codecs. What I have here seems to work
# (libxvid) but you may need to try something else
# Your mileage may vary
zachwhalen /
Created Jun 3, 2016
new doTweet function
function doTweet (tweet) {
var service = getTwitterService();
if (service.hasAccess()) {
var payload = {"status" : tweet }
} else {
var authorizationUrl = service.authorize();
msgPopUp('<p>Please visit the following URL and then re-run "Send a Test Tweet": <br/> <a target="_blank" href="' + authorizationUrl + '">' + authorizationUrl + '</a></p>');
var parameters = {