Skip to content

Instantly share code, notes, and snippets.

View dryan's full-sized avatar
Black Lives Matter

Dan Ryan dryan

Black Lives Matter
View GitHub Profile
@dryan
dryan / git-report.py
Created October 31, 2012 04:26
Compare to git objects
#!/usr/local/bin/python
import optparse, sys, os
try:
import git
except ImportError:
print 'You need gitpython. `pip install gitpython`'
sys.exit(os.EX_UNAVAILABLE)
@dryan
dryan / git-report.py
Created October 11, 2012 04:23
Shell script for formatting the output of `git whatchanged` into a simple list of commit messages
#!/usr/local/bin/python
import optparse, sys, os
try:
import git
except ImportError:
print 'You need gitpython. `pip install gitpython`'
sys.exit(os.EX_UNAVAILABLE)
@dryan
dryan / demo.html
Created April 21, 2012 03:24
Utility function for translatable strings in JavaScript. See demo.html for usage examples.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Translation Demo</title>
<meta charset="utf-8">
</head>
<body>
<p id="hello"></p>
<h1>Usage</h1>
<p>Create an object called <code>translations</code> attached to the <code>window</code> object. That object should have a key for each language you want to support that points to an object containing key/value pairs for all of your strings.</p>
@dryan
dryan / lint_urls.py
Created February 13, 2012 05:02
Crawl a website or subdirectory then lint the matching URLs
#!/usr/bin/env python
# coding=utf-8
# script for crawling a website or subdirectory and linting all the associated URLs
# only lints URLs that begin with the base URL, which is the first argument you pass
# an optional second argument will append a string to each URL as its linted, i.e., "?source=dryan" adds that string to each URL
import optparse, csv, sys, os, re, shutil, json, urllib, urlparse
from time import sleep
from BeautifulSoup import BeautifulSoup, SoupStrainer
@dryan
dryan / insertcss.js
Created May 20, 2011 20:48
Method for inserting dynamic CSS via JavaScript/jQuery
/*
Based on work by Aaron Gustafson <http://easy-designs.net>
Requires jQuery
*/
(function($) {
$('<style id="inline-css" media="screen"></style>').appendTo('head');
var style = $('#inline-css').get(0);
@dryan
dryan / gist:949947
Created April 30, 2011 20:00
oembed errors.py
======================================================================
ERROR: test_internal_media_aggregation (oembed.tests.tests.models.ModelTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/dryan/Sites/chattarati_data/libs/oembed/tests/tests/models.py", line 94, in test_internal_media_aggregation
category1 = Category.objects.get(pk=1)
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/django/db/models/query.py", line 344, in get
num = len(clone)
@dryan
dryan / backbutton.py
Created March 25, 2011 05:51
save the current URL to the session for use in a back button in a template
request.session.__setitem__('directory_url', request.get_full_path())
@dryan
dryan / cards.css
Created December 13, 2010 06:39
Some of the CSS for animating the cards for the wikiHow Chrome app
#main article {
-webkit-transition-property: left, visibility, top, -webkit-transform, opacity, z-index, margin-top, margin-left;
-webkit-transition-duration: 0.5s, 0.5s, 0.5s, 0.5s, 0, 0, 0.5s, 0;
-webkit-transition-delay: 0, 0, 0, 0.25s, 0, 0.5s, 0.25s, 0;
-webkit-transform: scale(0.67415);
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
}
#main article.primary,
@dryan
dryan / supports3d.js
Created December 13, 2010 06:31
JavaScript function to detect 3D CSS transform support
function supports3d() {
// borrowed from modernizr
var div = document.createElement('div'),
ret = false,
properties = ['perspectiveProperty', 'WebkitPerspective'];
for (var i = properties.length - 1; i >= 0; i--){
ret = ret ? ret : div.style[properties[i]] != undefined;
};
// webkit has 3d transforms disabled for chrome, though
@dryan
dryan / chromebug.html
Created November 21, 2010 22:23
@font-face rendering issue with text-rendering: optimizeLegibility and certain characters
<!DOCTYPE html>
<html>
<head>
<title>Chrome Font Rendering Issue with Text Shadow and Entity Character</title>
<link href='http://fonts.googleapis.com/css?family=IM+Fell+English|Neuton|Reenie+Beanie|IM+Fell+English+SC' rel='stylesheet' type='text/css'>
<style>
body { width: 500px; margin: 0 auto; font-family: Neuton, Georgia, serif; text-shadow: 0 0 1px rgba(0,0,0,0.1); text-rendering: optimizeLegibility; }
h1 { font-size: 24px; font-weight: normal; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">