Skip to content

Instantly share code, notes, and snippets.

@Glench
Glench / categories.txt
Last active December 31, 2018 14:23
Wikipedia categories ordered by number of pages (5 page minimum), 2018-12-31
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 / calendar_facts.json
Created December 18, 2017 19:03
XKCD #1930 Calendar Facts Tracery script
{
"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 January 24, 2013 18:59
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
Glench / js_helpers_bookmarklet.js
Last active October 17, 2017 22:15
Utility functions for injecting into webpages to do scraping and fun things.
// 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;} }
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 January 12, 2017 20:10
Add wikipedia links to search results on Nutrimatic
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>'
});
@Glench
Glench / gist:8508781
Created January 19, 2014 18:19
get wikipedia titles in a file
curl http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-all-titles-in-ns0.gz | gunzip | sed 's/_/ /g' | grep -v '(redirect)$'
@Glench
Glench / adjacent_us_states.json
Created October 17, 2012 15:10
JSON US State Adjacency List
{
"WA": [
"ID",
"OR"
],
"DE": [
"MD",
"PA",
"NJ"
],
>>> class X():
... pass
...
>>> x = X()
>>> x
<__main__.X instance at 0x106911908>
@Glench
Glench / all_caesar_ciphers.py
Created January 19, 2014 05:46
Get all the caesar ciphers for a given string.
# print all caesar ciphers
# python caesar.py word
import sys
for offset in range(1,26):
word = ''
for letter in sys.argv[1].lower():
num_of_letter = ord(letter)
new_num = num_of_letter + offset