Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Staying home

Chris Adams acdha

🏡
Staying home
View GitHub Profile
@acdha
acdha / update_index.py
Last active Aug 29, 2015
django-haystack's update_index command extended to activate translations
View update_index.py
# 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 Feb 4, 2014
Partial Intl.js patch for IE8 support
View ie8.patch
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 Aug 29, 2015
Script to create Github milestones for recurring release windows
View create-github-milestones
#!/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 Aug 29, 2015
Count the number of domains used to load a page (see http://www.peterbe.com/plog/number-of-domains)
View count-page-domains.js
/* 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 Aug 29, 2015
WDL's JSHint config
View .jshintrc
{
"maxlen": 110,
"indent": 4,
"strict": true,
"browser": true,
"bitwise": true,
"camelcase": true,
"curly": true,
@acdha
acdha / postactivate
Created Mar 12, 2014
Global virtualenvwrapper hooks which add a project's bin directory to the PATH any time you activate a virtualenv
View postactivate
#!/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
View jpylyzer.xml
<?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>
View homebrew.mxcl.elasticsearch.plist
<?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 Aug 29, 2015
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…
View testlog.js
// 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:
View qad-image-gallery-page.py
You can’t perform that action at this time.