Skip to content

Instantly share code, notes, and snippets.

View fawkesley's full-sized avatar

Paul Fawkesley fawkesley

View GitHub Profile
@fawkesley
fawkesley / gist:9488524
Created March 11, 2014 15:46
Backdrop logstash format
{
"@fields":{
"relativeCreated":344.9680805206299,
"process":12223,
"args":[
],
"module":"log_handler",
"funcName":"set_up_logging",
"message":"backdrop.read.api logging started",
@fawkesley
fawkesley / open_file.py
Last active August 29, 2015 13:58
Transparently open a file with open or gzip.open depending on file extension
import gzip
import logging
from contextlib import contextmanager
@contextmanager
def open_file(filename, *args, **kwargs):
"""
Detect if a file is gzipped and use the appropriate open method.
"""
Alien Language - solution
Google Code Jam 2009 - Qual round
Problem available at
http://code.google.com/codejam/contest/90101/dashboard#s=p0
By Tim Lee, 28/04/14
Input as L D N, followed by D dictionary words, N 'patterns' to decode
"""
@fawkesley
fawkesley / repos.json
Last active August 29, 2015 14:04
Fourth Wall Repos (Sea Level Research)
[
{
"userName": "sealevelresearch",
"repo": "sea-level-api"
},
{
"userName": "sealevelresearch",
"repo": "pilot-planner"
},
{
@fawkesley
fawkesley / ea-measurement-analysis
Created August 18, 2014 12:05
Analysing the EA Measurements website (ie http://apps.environment-agency.gov.uk/river-and-sea-levels/120705.aspx?stationId=5084) - multiple requests give different "latest" time & measurement
Mon Aug 18 12:47:01 BST 2014
datetime(2014, 8, 18, 11, 15, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 0, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 15, tzinfo=<UTC>), measurement=-2.14
datetime(2014, 8, 18, 11, 15, tzinfo=<UTC>), measurement=-2.14
@fawkesley
fawkesley / citybike.json
Created September 11, 2014 19:54
Liverpool Citybike unofficial API example
{
"lastRefreshed": "2014-06-10T10:30:00Z",
"lastChanged": "2014-06-10T10:17:13Z",
"locations": [
{
"latitude": 53.4051319444,
"locationName": "Pier Head Ferry Terminal",
"availableBikes": 3,
"longitude": -2.9971558333,
"availableLocks": 7
@fawkesley
fawkesley / BAD_simples2k.json
Last active August 29, 2015 14:17
Json output of GPG file generated with `echo hello | gpg --s2k-mode=0` and passphrase `foo`. Incorrect decryption of ciphertext!
[
{
"header": {
"packet_type": "SymmetricKeyEncryptedSessionKeyPacket",
"packet_tag": 3,
"packet_format": "old",
"header_octets": {
"octets": "8c:04",
"length": 2
},

Keybase proof

I hereby claim:

  • I am paulfurley on github.
  • I am paulfurley (https://keybase.io/paulfurley) on keybase.
  • I have a public key whose fingerprint is A999 B749 8D1A 8DC4 73E5 3C92 309F 635D AD1B 5517

To claim this, I am signing this object:

@fawkesley
fawkesley / gist:6596fe4166ef7b67ab8e
Created November 20, 2015 13:44 — forked from methane/gist:2185380
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
*PPD-Adobe: "4.3"
*% Adobe Systems PostScript(R) Printer Description File
*% Copyright 2009 Xerox Corporation.
*% PPD File Info
*FileVersion: "5.371.0.0"
*FormatVersion: "4.3"
*LanguageEncoding: ISOLatin1