Skip to content

Instantly share code, notes, and snippets.

Glench / scratch_fullscreen_cover.js
Last active Apr 14, 2020
Set Scratch UI to black
View scratch_fullscreen_cover.js
// sets everything but stage to black on full-screened
const stage = document.querySelector('[class^="stage_stage-bottom-wrapper"]')
const rect = stage.getBoundingClientRect();
const pageHeight = document.documentElement.scrollHeight;
var leftCover = document.createElement('div');
Glench /
Last active Jan 27, 2020
An example of how to vary a parameter for an async callback function in python. Hint: don't use lambda functions in loops!
We want to run a function asychronously and run a
callback function with multiple parameters when it
In this example, we are pretending we're analyzing
the names and ages of some people. We want to print
jack 0
Glench /
Created Apr 26, 2019
A meditation reminder app when I'm using the computer
# This Python file uses the following encoding: utf-8
import subprocess
import time
breathing_time = 30 # seconds
interval_between_breathing = 25 * 60 # seconds
applescript = """
display dialog "Breathe and make a home of your body" ¬
import play
def do(key):
text = play.new_text(':(', y=play.screen.bottom)
text.start_physics(x_speed=play.random_number(-20,20), y_speed=100, bounciness=.3)
Glench / categories.txt
Last active Dec 31, 2018
Wikipedia categories ordered by number of pages (5 page minimum), 2018-12-31
View categories.txt
Living people 887246
Year of birth missing (living people) 70369
American films 48785
Association football midfielders 45613
Place of birth missing (living people) 43381
English-language films 40342
Association football defenders 35650
Taxonomy articles created by Polbot 32839
Association football forwards 32393
English Football League players 23766
Glench / calendar_facts.json
Created Dec 18, 2017
XKCD #1930 Calendar Facts Tracery script
View calendar_facts.json
"origin":["Did you know that #start# #next# because of #reason#? Apparently #fact#"],
"start":["the #springfall# equinox", "the #wintersummer# #solsticeolympics#", "the #earliestlatest# #sunrisesunset#", "daylight #saving# time", "Leap #dayyear#", "Easter", "the #moontype# Moon", "Toyota Truck Month", "Shark Week"],
"next":["happens #relativetime# every year", "drifts out of sync with the #synctypes#", "might #happen# this year"],
"springfall":["spring", "fall"],
"wintersummer": ["winter", "summer"],
"solsticeolympics": ["solstice", "olympics"],
"earliestlatest": ["earliest", "latest"],
"sunrisesunset": ["sunrise", "sunset"],
"saving": ["saving", "savings"],
Glench /
Created Jan 24, 2013
Geometric mean function for python. Takes the nth root of all values in an iterable multiplied together. There might be some issues with this.
import operator
def geometric_mean(iterable):
return (reduce(operator.mul, iterable)) ** (1.0/len(iterable))
Glench / js_helpers_bookmarklet.js
Last active Oct 17, 2017
Utility functions for injecting into webpages to do scraping and fun things.
View js_helpers_bookmarklet.js
// Use with no jQuery (sometimes there are SSL problems)
window.q = document.querySelectorAll.bind(document);
window.qq = document.querySelector.bind(document); = function(func, debug) {
// A very useful function for reading and modifying a bunch of nodes on a web page.
// example usage: q('a').map(node => node.getAttribute('href')) -> ['', 'closed-source/dictionaryofnumbers/', ...]
if (!func) { func = function(node) { return node;} }
Glench /
Created Mar 23, 2013
a python script that watches the current directory for changes to ipython notebooks, compiles them to html, and uploads them via scp to a server. an experiment in real-time coding for teaching python to new programmers
import time
from watchdog.observers import Observer
from import FileSystemEventHandler
import envoy
import os
import datetime
class NotebookConverterHandler(FileSystemEventHandler):
def on_modified(self, event):
if event.src_path.endswith('.ipynb'):
View bubble_fan.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.