Skip to content

Instantly share code, notes, and snippets.

Chris Adams acdha

Block or report user

Report or block acdha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dump-wikipedia-links
acdha /
Last active Mar 3, 2020
Python 3: serve the current directory as HTTP while setting CORS headers for XHR debugging
#!/usr/bin/env python3
# encoding: utf-8
"""Use instead of `python3 -m http.server` when you need CORS"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
#!/usr/bin/env python
# encoding: utf-8
"""Attempting to mop up Thomas XML
`pip install requests beautifulsoup4 html5lib lxml`
from __future__ import (absolute_import, division, print_function,
View iiif-presentation-2.0-example.json
"@context": "",
"@id": "",
"@type": "sc:Manifest",
"attribution": "Provided by Example Organization",
"description": "A longer description of this example book. It should give some real information.",
"label": "Book 1",
"license": "",
"logo": "",
"metadata": [
acdha / test.c
Last active Sep 8, 2015
Proof that will segfault in a program which passes “clang -Werror -Weverything -pedantic”
View test.c
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <float.h>
static int isNegative(float arg) {
char *p = (char*) malloc(20);
sprintf(p, "%f", arg);
return p[0] == '-';
acdha /
Last active Sep 3, 2015
Simple test of image optimization savings
Original: 8654
optipng: 8652
advpng: 8216
zopflipng: 8215
Final: 8215 94.93% (439 bytes saved)
Original: 8137
optipng: 6857
acdha / baseline.txt
Last active Apr 28, 2018 — forked from jmcnamara/
Benchmark of several Python Excel writing modules
View baseline.txt
python : 2.7.1
openpyxl : 2.2.5
pyexcelerate: 0.6.6
xlsxwriter : 0.7.3
xlwt : 1.0.0
Rows = 10000
acdha / ga-time-to-first-paint.js
Created Aug 19, 2015
Record time to first paint on Chrome/IE using Google Analytics user timing
View ga-time-to-first-paint.js
(function ($) {
'use strict';
/* Based on */
function recordTimeToFirstPaint() {
// Use Chrome's loadTimes or IE 9+'s msFirstPaint to record the time to render in milliseconds:
var firstPaintTime, timingSource;
if ('chrome' in window && $.isFunction( {
acdha / wdl-video-snippet.html
Last active Aug 29, 2015
Simple demonstration of HTML5 video with Flash and warning message fallback
View wdl-video-snippet.html
<video id="player" itemprop="video" controls preload="auto" poster="">
<source type="video/mp4" src="">
<object id="videoPlayer" type="application/x-shockwave-flash" data="/static/swf/video/videoPlayer.706e405e7ad9.swf" width="320" height="278">
<param name="movie" value="/static/swf/video/videoPlayer.706e405e7ad9.swf">
<param name="flashvars" value="thisVideo=;thisCC=&amp;thisBg=">
<param name="quality" value="best">
<p class="text-danger">This item is currently unavailable in a format which may be viewed on your device</p>
acdha /
Created Jun 12, 2015
Ways to get the name of a Unicode block for a character in Python
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import requests
You can’t perform that action at this time.