Skip to content

Instantly share code, notes, and snippets.

View acdha's full-sized avatar

Chris Adams acdha

View GitHub Profile
@acdha
acdha / update_index.py
Last active August 29, 2015 13:55
django-haystack's update_index command extended to activate translations
# encoding: utf-8
"""Haystack's update_index command extended to activate translations
Source: https://gist.github.com/acdha/8697917
See https://github.com/toastdriven/django-haystack/pull/933
"""
from __future__ import absolute_import
from django.utils import translation
@acdha
acdha / ie8.patch
Created February 4, 2014 19:37
Partial Intl.js patch for IE8 support
diff --git a/public_website/static/external/intl/Intl.js b/public_website/static/external/intl/Intl.js
index a86c1f3..65befab 100644
--- a/public_website/static/external/intl/Intl.js
+++ b/public_website/static/external/intl/Intl.js
@@ -25,23 +25,30 @@
}
})(typeof global !== 'undefined' ? global : this, function() {
"use strict";
-var
- Intl = {},
@acdha
acdha / create-github-milestones
Last active August 29, 2015 13:56
Script to create Github milestones for recurring release windows
#!/usr/bin/env python
"""Create date-based release milestones on Github
By default this created milestones of the form 'Public Website – DATE'
If your git config defines github.user / github.password settings these will be used rather than prompting
for credentials. For sanity, !-prefixed github.password entries are supported so you can e.g. query the
OS X keychain rather than hard-coding passwords in a text file.
"""
@acdha
acdha / count-page-domains.js
Last active August 29, 2015 13:56
Count the number of domains used to load a page (see http://www.peterbe.com/plog/number-of-domains)
/* global phantom */
// Inspired by https://gist.github.com/cjoudrey/1341747
"use strict";
var system = require('system'),
webPage = require('webpage');
if (system.args.length != 2) {
console.log('Usage:', system.args[0], 'URL');
phantom.exit(2);
@acdha
acdha / .jshintrc
Last active August 29, 2015 13:56
WDL's JSHint config
{
"maxlen": 110,
"indent": 4,
"strict": true,
"browser": true,
"bitwise": true,
"camelcase": true,
"curly": true,
@acdha
acdha / postactivate
Created March 12, 2014 21:45
Global virtualenvwrapper hooks which add a project's bin directory to the PATH any time you activate a virtualenv
#!/bin/bash
# This hook is run after every virtualenv is activated.
VIRTUALENV_PROJECT_FILE="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME";
if [ -f $VIRTUALENV_PROJECT_FILE ]; then
export VIRTUALENV_PROJECT=$(cat $VIRTUALENV_PROJECT_FILE);
if [ -d "$VIRTUALENV_PROJECT/bin" ]; then
export PATH="$VIRTUALENV_PROJECT/bin":$PATH
fi
<?xml version='1.0' encoding='UTF-8'?>
<jpylyzer xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<toolInfo>
<toolName>jpylyzer.py</toolName>
<toolVersion>1.13.0</toolVersion>
</toolInfo>
<fileInfo>
<fileName>sn99063957_1914-05-06_ed-1_seq-1.jp2</fileName>
<filePath>/Users/cadams/Downloads/jp2-vs-png/sn99063957_1914-05-06_ed-1_seq-1.jp2</filePath>
<fileSizeInBytes>3720460</fileSizeInBytes>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.elasticsearch</string>
<key>ProgramArguments</key>
<array>
@acdha
acdha / testlog.js
Last active August 29, 2015 14:02
Performance test-case for pure-CSS expanding sidebar panel. WebKit, and to a lesser extent Blink, browsers render the sidebar expansion slower than expected, with repeated full invalidate/layout/recalc style cycles during the state change. This isn't too bad on a desktop but is noticeable on a mobile browser: https://cdn.rawgit.com/acdha/63393d9…
// Load testcase & connect WebInspector to an iPhone 4S running iOS 7.1.1
// Start timeline capture
// Expand the sidebar:
document.querySelector('input[type=checkbox]').checked = !document.querySelector('input[type=checkbox]').checked
// Timeline profile: https://www.dropbox.com/s/e4z400rlprkbtau/Screenshot%202014-06-16%2014.47.39.png
// Collapse the sidebar:
@acdha
acdha / qad-image-gallery-page.py
Created June 25, 2014 18:26
Quick and dirty HTML index creation for image galleries (see e.g. http://chris.improbable.org/experiments/opencv/page-image-extraction/211/)