Skip to content

Instantly share code, notes, and snippets.

Avatar

David King davbo

  • London, UK.
View GitHub Profile
@davbo
davbo / WHY.md
Last active Jun 29, 2019
not-multiprocessing-multiprocessing
View WHY.md

If you're fortunate enough to find yourself on a platform without a SemLockType ¯\(ツ)/¯ and see this:

# python -m multiprocessing
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 163, in _run_module_as_main
  File "/usr/lib/python2.7/runpy.py", line 111, in _get_module_details
  File "/usr/lib/python2.7/multiprocessing/__init__.py", line 84, in <module>
ImportError: /usr/lib/python2.7/lib-dynload/_multiprocessing.so: undefined symbol: SemLockType
@davbo
davbo / main.go
Created Mar 8, 2019
Example of deadlocking the Trillian memory storage backend with a uninitialized log
View main.go
package main
import (
"context"
"fmt"
"github.com/google/trillian/util/clock"
"github.com/google/trillian"
"github.com/google/trillian/server"
"github.com/google/trillian/storage"
@davbo
davbo / popup.css
Last active Oct 13, 2018
access my data 4k extension
View popup.css
body {
margin: 5px 10px 10px;
width: 520px;
font: 17px/1.2 Helvetica, sans-serif;
}
h1 {
color: #53637D;
font: 26px/1.2 Helvetica, sans-serif;
font-size: 200%;
View cred-swap.py
import unittest
import boto3
import credstash
MY_SERVICE = 'my-service'
VALUABLE_SERVICE = 'valuable-service'
class TestCredentialSwap(unittest.TestCase):
def tearDown(self):
@davbo
davbo / blogs.opml.xml
Last active Apr 25, 2016
Programming blogs
View blogs.opml.xml
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Programming blogs</title>
</head>
<body>
<outline text="Developer blogs" title="Developer blogs">
<outline type="rss" text="flak rss" title="flak rss" xmlUrl="http://www.tedunangst.com/flak/rss" htmlUrl="http://www.tedunangst.com/flak/"/>
<outline type="rss" text="Kamal Marhubi" title="Kamal Marhubi" xmlUrl="http://kamalmarhubi.com/blog/feed.xml" htmlUrl="http://kamalmarhubi.com/"/>
@davbo
davbo / preloaded.js
Created May 29, 2013
Replaces any preloaded images with locally cached version
View preloaded.js
define(['underscore'], function(_) {
return {
replace: function (images) {
// Look for the image in our preloaded images and replace
// the path if we find it.
var preload = window.preload || {};
_.each(images, function (val, key) {
if (_.has(preload, val)) {
images[key] = preload[val];
}
@davbo
davbo / preloader.py
Created May 29, 2013
Preloads JSON & images for our University Museums offline JavaScript applicaiton
View preloader.py
import json
import urllib2
import os
import codecs
from urlparse import urlparse
from string import Template
build_dir = os.environ['TARGET_FOLDER']
@davbo
davbo / gist:5670378
Created May 29, 2013
Museums app JSON snippet
View gist:5670378
"slug":"history-of-science",
"website":"http://www.mhs.ox.ac.uk/",
"lng":-1.255504,
"opening_hours":"Tuesday to Friday: 12-5pm; Saturday: 10am-5pm; Sunday: 2-5pm; Monday: Closed",
"_links":{
"items":{
"href":"/museums/history-of-science/items/"
},
"self":{
"href":"/museums/history-of-science/"
@davbo
davbo / nowatch.py
Created Oct 3, 2012
Stop watching WebLearn repos
View nowatch.py
import requests
auth = (USER, PASS)
for repo in requests.get('https://api.github.com/user/subscriptions', params={'per_page': 100}, auth=auth).json:
if repo['name'].startswith('wl-'):
requests.delete('https://api.github.com/user/subscriptions/%s/%s' % (repo['owner']['login'], repo['name']), auth=auth)
@davbo
davbo / places.py
Created Aug 15, 2012
Content negotiation
View places.py
from flask import Blueprint
from .helpers import template_or_json
from .views import ServiceView, register_mimetype
places = Blueprint('places', __name__, template_folder='templates')
@places.route('/')
@template_or_json('places/search.html')
You can’t perform that action at this time.