Skip to content

Instantly share code, notes, and snippets.

View stringertheory's full-sized avatar

Mike Stringer stringertheory

View GitHub Profile
@stringertheory
stringertheory / feeds.toml
Created March 20, 2024 22:32
configuration for "RSS Please" for Letterform Archive news
[[feed]]
title = "Letterform Archive"
filename = "letterform-archive.rss"
user_agent = "Mozilla/5.0 RSS Please https://rsspls.7bit.org/"
[feed.config]
url = "https://letterformarchive.org/news/"
item = "article.post"
heading = ".post__title"
link = "h2 a"
@stringertheory
stringertheory / understanding-word-vectors.ipynb
Created February 20, 2024 22:38 — forked from aparrish/understanding-word-vectors.ipynb
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<style>
html {
font-size: 2rem;
/* font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif; */
font-family: Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif;
}
@keyframes rainbow_animation {
0% {
background-position: 0%
}
@stringertheory
stringertheory / threes_simulation.py
Last active June 26, 2023 14:00
A quicky python script to simulate random pushes in the Threes game at threesjs.com, as described in http://datascopeanalytics.com/what-we-think/2014/03/13/are-you-really-any-good-at-threes
# standard library
import sys
import random
import time
# need to pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
@stringertheory
stringertheory / email_to_self.js
Created November 24, 2021 17:31
code for a bookmarklet to email stuff to myself
(function() {
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
{
"hello world": [[0, 10], [20, 30], [50, 60], [90, 10], [10, 90], [0, 10]],
"boogety boo": [[0, 50], [10, 30], [50, 60], [90, 10], [50, 90], [0, 10], [0, 20], [10, 30], [20, 40], [0, 50]]
}
@stringertheory
stringertheory / skittles.py
Last active April 19, 2019 21:49
A test of whether skittles are uniformly distributed (using data from https://github.com/possibly-wrong/skittles)
import sys
import collections
import random
N_TRIALS = 100000
FLAVORS = ['Strawberry', 'Orange', 'Lemon', 'Apple', 'Grape']
def chisquared(values):
mean = sum(values) / float(len(values))
@stringertheory
stringertheory / repeat.py
Created January 27, 2019 17:11
How many times to repeat something before it sinks in with a group of people?
import random
import collections
n = 100
p_attend = 0.5
p_listen = 0.5
n_to_remember = 2
people = list(range(n))
random.shuffle(people)
@stringertheory
stringertheory / lenient_url_scrub.py
Created September 29, 2018 14:29
replacing a python scrubadub regex filter for URL matching that doesn't require protocol
import re
import scrubadub
class UrlFilth(scrubadub.filth.url.UrlFilth):
regex = re.compile(r'''
(?P<protocol>
(https?:\/\/(www\.)?|www\.)? # protocol http://, etc
)(?P<domain>
@stringertheory
stringertheory / ugh.py
Created July 5, 2017 02:34
first words of cookywook's tweets
import os
import tweepy
auth = tweepy.OAuthHandler(os.getenv('TW_CKEY'), os.getenv('TW_CSECRET'))
auth.set_access_token(os.getenv('TW_ATOKEN'), os.getenv('TW_ASECRET'))
api = tweepy.API(auth)
for tweet in api.user_timeline(screen_name='cookywook', count=40):