Skip to content

Instantly share code, notes, and snippets.

@Glench
Glench / generate_all_font.py
Last active January 1, 2016 15:19
Generate a web page of all fonts installed on your Mac. Sample here: http://glench.com/all-fonts.html
import Cocoa
from jinja2 import Template
template = Template(u"""
<html>
<head>
<title>All Fonts Preview</title>
<style>
html, body {
margin: 0;
@Glench
Glench / format_twitter_favorites.js
Last active January 2, 2016 21:59
Format twitter favorites to make better for browsing.
$('.global-nav').remove()
$('.dashboard').remove()
$('.profile-header').remove()
$('#page-container').css({
'padding': 0,
'background': 'none'
})
$('.dogear').css({
display: 'none'
})
@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
@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)$'
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
canvas {
@Glench
Glench / gist:b1a99b5e75d50e162411
Last active August 29, 2015 14:09
Wikipedia visited
var body = document.querySelector('body');
var styleNode = document.createElement('style');
var cssTextNode = document.createTextNode('#content a:visited { color: rgb(41, 229, 41) !important; }');
styleNode.appendChild(cssTextNode);
body.appendChild(styleNode);
var baseUrl = 'http://127.0.0.1:5000';
var wikipedify = function(best_guess) {
return 'https://en.wikipedia.org/wiki/Special:Search/'+best_guess;
};
var makeLink = function(href, text, title) {
return '<a href="'+href+'" target="_blank" title="'+title+'">'+text+'</a>';
};
$('img').each(function(i, img) {
var $img = $(img)
$.get(baseUrl+'?image_url='+window.location.href+img.getAttribute('src')).done(function(data) {
@Glench
Glench / music.txt
Last active August 29, 2015 14:12
artist/title track listing from http://labrosa.ee.columbia.edu/millionsong/
This file has been truncated, but you can view the full file.
Faster Pussy cat<SEP>Silent Night
Karkkiautomaatti<SEP>Tanssi vaan
Hudson Mohawke<SEP>No One Could Ever
Yerba Brava<SEP>Si Vos Querés
Der Mystic<SEP>Tangle Of Aspens
David Montgomery<SEP>Symphony No. 1 G minor "Sinfonie Serieuse"/Allegro con energia
Sasha / Turbulence<SEP>We Have Got Love
Kris Kross<SEP>2 Da Beat Ch'yall
Joseph Locke<SEP>Goodbye
The Sun Harbor's Chorus-Documentary Recordings<SEP>Mama_ mama can't you see ?
import sys
import itertools
from pyquery import PyQuery as pq
def download_and_parse(wikipedia_url):
page = pq(url=wikipedia_url.strip())
key_values = {}
for tr in page('.infobox tr'):
tr = pq(tr)
cells = tr('th,td')
@Glench
Glench / autocomplete.js
Last active August 29, 2015 14:18
allows you to change google's autocomplete to whatever you want >:) type into google to create an autocomplete list, then activate this bookmarklet
javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bfunction%20omgwtfval(term)%20%7Breturn%20'%3Cli%20class%3D%22sbsb_c%20gsfs%22%20dir%3D%22ltr%22%20style%3D%22text-align%3A%20left%3B%22%3E%20%3Cdiv%20role%3D%22option%22%3E%20%3Cdiv%20class%3D%22sbqs_c%22%3E'%20%2B%20term%20%2B%20'%3C%2Fdiv%3E%20%3C%2Fdiv%3E%20%3C%2Fli%3E'%3B%7D%3Bfunction%20omgwtf(val)%20%7B%24('ul.sbsb_b%20li').remove()%3Bvar%20terms%20%3D%20val.split('%5Cn')%3Bterms.forEach(function(term)%20%7B%24('ul.sbsb_b').append(omgwtfval(term))%3B%7D)%3B%7D%3B%24('body').prepend(%24('textarea').attr('id'%2C%20'omgwtf').css(%7Bposition%3A%20'absolute'%2C%20right%3A%2020%2C%20top%3A%2020%2C%20width%3A%20300%2C%20height%3A%20400%2C%20zIndex%3A%201000000%2C%20display%3A%20'block'%7D))%3B%24('%23omgwtf').on('input%20propertychange'%2C%20function()%20%7Bomgwtf(this.value)%3B%24('.mw%2C%20%23footcnt%2C%20%23main').remove()%3B%7D)%7D)(jQuery.noConflict(true))%7Dvar%20s%3Ddocument.createElement(%22script%22)%3Bs.src%3D%22ht