Skip to content

Instantly share code, notes, and snippets.

View zacharydenton's full-sized avatar

Zach Denton zacharydenton

View GitHub Profile
@zacharydenton
zacharydenton / gist:573665ffba4708b68437
Created December 18, 2014 23:04
app specific globals
javascript:(function(){var standardGlobals=["top","window","location","external","chrome","document","inlineCSS","target","width","height","canvas","data","DOMURL","img","svg","ctx","url","w","a","speechSynthesis","webkitNotifications","localStorage","sessionStorage","applicationCache","webkitStorageInfo","indexedDB","webkitIndexedDB","crypto","CSS","performance","console","devicePixelRatio","styleMedia","parent","opener","frames","self","defaultstatus","defaultStatus","status","name","length","closed","pageYOffset","pageXOffset","scrollY","scrollX","screenTop","screenLeft","screenY","screenX","innerWidth","innerHeight","outerWidth","outerHeight","offscreenBuffering","frameElement","clientInformation","navigator","toolbar","statusbar","scrollbars","personalbar","menubar","locationbar","history","screen","postMessage","close","blur","focus","ondeviceorientation","ondevicemotion","onunload","onstorage","onresize","onpopstate","onpageshow","onpagehide","ononline","onoffline","onmessage","onhashchange","onbeforeu
@zacharydenton
zacharydenton / models.py
Created February 18, 2011 02:27
Geodesic Distance Between Points in GeoDjango
from itertools import tee, izip
from django.contrib.gis.db import models
from django.contrib.gis.measure import Distance
from geopy.distance import distance as geopy_distance
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
@zacharydenton
zacharydenton / functions.php
Created January 24, 2011 18:43
BuddyPress Album author template tags
<?php
function bp_album_get_author_userdata() {
global $pictures_template;
$author_userdata = get_userdata($pictures_template->picture->owner_id);
return $author_userdata;
}
function bp_album_get_the_author() {
$author_userdata = bp_album_get_author_userdata();
return $author_userdata->display_name;
@zacharydenton
zacharydenton / FLAC anomalies...
Created January 18, 2011 17:30
FLAC anomalies...
This works:
flac -dc -- "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/08. The Journey.flac" | sox -t wav - -b 16 -t wav - rate 44100 dither | flac --best -T "TITLE=The Journey" -T "ALBUM=S.F. Sorrow" -T "ALBUM=The Pretty Things" -T "TRACKNUMBER=08" -T "GENRE=" -T "DATE=1968-12" -o "/home/zdenton/test/The Pretty Things - S F Sorrow [16-44] (FLAC)/08. The Journey.flac" - 2>&1
This doesn't:
flac -dc -- "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac" | sox -t wav - -b 16 -t wav - rate 44100 dither | flac --best -T "TITLE=Old Man Going" -T "ALBUM=S.F. Sorrow" -T "ALBUM=The Pretty Things" -T "TRACKNUMBER=12" -T "GENRE=" -T "DATE=1968-12" -o "/home/zdenton/test/The Pretty Things - S F Sorrow [16-44] (FLAC)/12. Old Man Going.flac" - 2>&1
The latter stops at around 99% and says:
-: WARNING: skipping unknown sub-chunk '��/' (use --keep-foreign-metadata to keep)
-: ERROR: unexpected EOF
@zacharydenton
zacharydenton / loop.php
Created December 21, 2010 15:26
BuddyPress Album+ Loop
<div id="photos">
<?php bp_album_query_pictures('per_page=5'); ?>
<?php if ( bp_album_has_pictures() ) : ?>
<ul class="thumb">
<?php while ( bp_album_has_pictures() ) : bp_album_the_picture(); ?>
<li>
<a href="<?php bp_album_picture_middle_url(); ?>" title="<?php bp_album_picture_title(); ?>">
<img src='<?php bp_album_picture_thumb_url() ?>' alt="<?php bp_album_picture_desc(); ?>" />
</a>
</li>
@zacharydenton
zacharydenton / gist:741565
Created December 15, 2010 02:59
Munchausen numbers in Ruby, C, Python, and Clojure.
We couldn’t find that file to show.
@zacharydenton
zacharydenton / translate.py
Created December 10, 2010 16:38
A command line translation program using Python and the Google Translate API.
#!/usr/bin/env python
import sys
import json
import urllib
import urllib2
import argparse
def translate(target, text):
api = "https://www.googleapis.com/language/translate/v2?"
api_key = "AIzaSyBgBlJCogk_1Hd_7WaLQgLVbQss0_dvNUc"
@zacharydenton
zacharydenton / compressor.sh
Created December 7, 2010 01:28
Convert a music collection to MP3. Usage: ./compressor.sh source_dir output_dir
#!/usr/bin/env bash
# converts all .flac files to .mp3 and copies them to the
# OUT directory; copies all .mp3 files to the OUT directory.
LAMEOPTS="-V0 --quiet"
if [ "$#" -ne 2 ]
then
echo "usage: $0 MUSIC_DIR OUTPUT_DIR"
exit 1