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
acdha / simple_cors_server.py
Last active Mar 3, 2020
Python 3: serve the current directory as HTTP while setting CORS headers for XHR debugging
View simple_cors_server.py
#!/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', '*')
View bs4-prettify.py
#!/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,
unicode_literals)
View iiif-presentation-2.0-example.json
{
"@context": "http://iiif.io/api/presentation/2/context.json",
"@id": "http://www.example.org/iiif/book1/manifest",
"@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": "http://www.example.org/license.html",
"logo": "http://www.example.org/logos/institution1.jpg",
"metadata": [
@acdha
acdha / test.c
Last active Sep 8, 2015
Proof that https://twitter.com/MarcosBL/status/641110424193232897 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
acdha / congress.gov.log
Last active Sep 3, 2015
Simple test of image optimization savings
View congress.gov.log
Optimizing https://www.congress.gov/img/congress_gov_logo2.png
Original: 8654
optipng: 8652
advpng: 8216
zopflipng: 8215
Final: 8215 94.93% (439 bytes saved)
Optimizing https://congress.gov/img/sprite_congress.png
Original: 8137
optipng: 6857
@acdha
acdha / baseline.txt
Last active Apr 28, 2018 — forked from jmcnamara/bench_excel_writers.py
Benchmark of several Python Excel writing modules
View baseline.txt
Versions:
python : 2.7.1
openpyxl : 2.2.5
pyexcelerate: 0.6.6
xlsxwriter : 0.7.3
xlwt : 1.0.0
Dimensions:
Rows = 10000
@acdha
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 https://github.com/wikimedia/mediawiki-extensions-NavigationTiming/ */
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(window.chrome.loadTimes)) {
@acdha
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="http://content.wdl.org/536/thumbnail/1438262714/616x510.jpg">
<source type="video/mp4" src="http://dl.wdl.org/536/service/536.mp4">
<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=http://dl.wdl.org/536/service/536.flv&amp;thisCC=&amp;thisBg=http://content.wdl.org/536/thumbnail/1438262714/308x255.jpg">
<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>
</object>
@acdha
acdha / get-unicode-blocks.py
Created Jun 12, 2015
Ways to get the name of a Unicode block for a character in Python
View get-unicode-blocks.py
#!/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.