Skip to content

Instantly share code, notes, and snippets.

Glen Chiacchieri Glench

Block or report user

Report or block Glench

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Glench
Glench / body_reminder.py
Created Apr 26, 2019
A meditation reminder app when I'm using the computer
View body_reminder.py
# 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" ¬
View sad.py
import play
@play.when_any_key_pressed
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)
play.start_program()
@Glench
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
Glench / python-async-callback.py
Last active Jul 3, 2018
An example of how to vary a parameter for an async callback function in python. Hint: don't use lambda functions in loops!
View python-async-callback.py
"""
We want to run a function asychronously and run a
callback function with multiple parameters when it
returns!
In this example, we are pretending we're analyzing
the names and ages of some people. We want to print
out:
jack 0
@Glench
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
Glench / geometric_mean.py
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.
View geometric_mean.py
import operator
def geometric_mean(iterable):
return (reduce(operator.mul, iterable)) ** (1.0/len(iterable))
@Glench
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 http://bookmarklets.org/maker/ with no jQuery (sometimes there are SSL problems)
window.q = document.querySelectorAll.bind(document);
window.qq = document.querySelector.bind(document);
NodeList.prototype.map = 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')) -> ['http://glench.com/', 'closed-source/dictionaryofnumbers/', ...]
if (!func) { func = function(node) { return node;} }
@Glench
Glench / watch_notebooks.py
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
View watch_notebooks.py
import time
from watchdog.observers import Observer
from watchdog.events 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.
@Glench
Glench / nutrimatic wikipedia urlifier.js
Created Jan 12, 2017
Add wikipedia links to search results on Nutrimatic
View nutrimatic wikipedia urlifier.js
document.querySelectorAll('span').forEach(function(span){
var term = span.innerText;
var url = 'https://en.wikipedia.org/w/index.php?title=Special:Search&search='+ term.replace(/\s/g,'+')
span.innerHTML = '<a target="_blank" href="'+ url +'">'+ term +'</a>'
});
You can’t perform that action at this time.