Skip to content

Instantly share code, notes, and snippets.

Avatar
🍊

Zach Whalen zachwhalen

🍊
View GitHub Profile
@zachwhalen
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 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 / pride.py
Last active Sep 12, 2019
This generates a poem from the input of a text file called "pride.txt". It relies on TextBlob.
View pride.py
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",'\'']:
View game.txt
{"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 / another_rainy_day_novel.py
Created Nov 6, 2018
Another rainy day novel for NaNoGenMo
View another_rainy_day_novel.py
# 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 Nov 6, 2018
A generated novel for a rainy day.
View my_rainy_day_novel.py
# 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 / tracery_count.py
Last active Oct 10, 2018
A python counter for quantifying the number of possible variations for a Tracery grammar
View tracery_count.py
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()) )
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
zachwhalen / nn.sh
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.
View nn.sh
nn() {
# the header template
ft="---
Title: Untitled Note
Template: blog-post
Description: New Note
Date: $(date)
Tags:
---";
@zachwhalen
zachwhalen / friday.py
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.
View friday.py
#/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 / botcode.gs
Created Jun 3, 2016
new doTweet function
View botcode.gs
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 = {