Skip to content

Instantly share code, notes, and snippets.

View zachwhalen's full-sized avatar
🥗

Zach Whalen zachwhalen

🥗
View GitHub Profile
{
"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
zachwhalen / tracery_count.py
Last active October 10, 2018 00:55
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|#","",match.group()) )
@zachwhalen
zachwhalen / another_rainy_day_novel.py
Created November 6, 2018 15:58
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):
lines.append('')
# add something to each column 5000 times
@zachwhalen
zachwhalen / my_rainy_day_novel.py
Last active November 6, 2018 16:02
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
zachwhalen / game.txt
Created February 4, 2019 18:13
flickgame
{"gameLink":"www.flickgame.org","canvasses":[[1495,"0",7,"b",150,"0",11,"b",148,"0",13,"b",145,"0",16,"b",143,"0",17,"b",142,"0",18,"b",141,"0",19,"b",140,"0",20,"b",139,"0",21,"b",138,"0",22,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",23,"b",136,"0",24,"b",135,"0",25,"b",134,"0",26,"b",133,"0",27,"b",132,"0",28,"b",131,"0",29,"b",131,"0",28,"b",36,"0",7,"8",37,"0",7,"9",45,"0",28,"b",35,"0",9,"8",35,"0",9,"9",44,"0",27,"b",35,"0",11,"8",32,"0",12,"9",43,"0",26,"b",35,"0",13,"8",29,"0",15,"9",42,"0",25,"b",35,"0",14,"8",28,"0",16,"9",42,"0",24,"b",26,"0",7,"8",2,"0",15,"8",26,"0",18,"9",42,"0",23,"b",26,"0",25,"8",25,"0",19,"9",43,"0",21,"b",26,"0",26,"8",24,"0",20,"9",44,"0",19,"b",24,"0",29,"8",17,"0",27,"9",45,"0",17,"b",24,"0",30,"8",16,"0",28,"9",45,"0",16,"b",24,"0",30,"8",16,"0",28,"9",46,"0",15,"b",24,"0",30,"8",16,"0",28,"9",48,"0",13,"b",24,"0",30,"8",16,"0",28,"9",50,"0",11,"b",24,"0",30,"8",16,"0",28,"9",52,"0"
@zachwhalen
zachwhalen / pride.py
Last active September 12, 2019 01:37
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(source.read()).sentences
def sentenceLength(sent):
return len(sent)
def filter(sent):
for ex in ["Chapter","Section",'\'']:
@zachwhalen
zachwhalen / botcode.gs
Created June 3, 2016 12:58
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 = {
@zachwhalen
zachwhalen / chessboard_novel.js
Last active December 1, 2020 03:05
A javascript macro for Bonnie Brunish's Chessboard Universe Generator
// Go to http://www.thermeon.net/InfernalMuseum/FIIIC2c.html 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
zachwhalen / friday.py
Created December 16, 2016 14:32
A quick and clunky way to make one of those videos where it speeds up every time something happens. Uses MoviePy.
#/usr/bin/python
# 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
zachwhalen / game.txt
Created December 2, 2021 02:42
flickgame
{"gameLink":"www.flickgame.org","canvasses":[[9,"2",1,"3",5,"2",1,"3",5,"2",1,"3",8,"2",1,"3",6,"2",1,"3",6,"2",1,"3",6,"2",1,"3",5,"2",1,"3",5,"2",1,"3",3,"2",1,"3",19,"2",13,"f",5,"2",1,"3",29,"2",1,"3",10,"2",1,"3",6,"2",1,"3",15,"2",1,"3",5,"2",1,"3",5,"2",2,"3",7,"2",1,"3",6,"2",1,"3",6,"2",1,"3",6,"2",1,"3",5,"2",1,"3",5,"2",1,"3",3,"2",1,"3",11,"2",1,"3",7,"2",13,"f",5,"2",1,"3",5,"2",1,"3",4,"2",1,"3",4,"2",1,"3",13,"2",1,"3",10,"2",1,"3",6,"2",1,"3",15,"2",1,"3",5,"2",1,"3",6,"2",1,"3",7,"2",1,"3",6,"2",1,"3",6,"2",1,"3",6,"2",1,"3",5,"2",1,"3",5,"2",1,"3",3,"2",1,"3",11,"2",1,"3",7,"2",13,"f",5,"2",1,"3",5,"2",1,"3",4,"2",1,"3",4,"2",1,"3",14,"2",1,"3",9,"2",1,"3",6,"2",1,"3",15,"2",1,"3",5,"2",1,"3",6,"2",1,"3",7,"2",1,"3",6,"2",1,"3",6,"2",1,"3",6,"2",1,"3",5,"2",1,"3",5,"2",1,"3",3,"2",1,"3",11,"2",1,"3",7,"2",13,"f",5,"2",1,"3",5,"2",1,"3",4,"2",1,"3",4,"2",1,"3",8,"2",1,"3",5,"2",1,"3",9,"2",1,"3",6,"2",1,"3",15,"2",1,"3",5,"2",1,"3",6,"2",1,"3",7,"2",1,"3",6,"2",1,"3",6,"2",1,"3",6,"2",1,"3",5