This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
from math import radians, sin, cos, atan2, sqrt, degrees | |
# Point is a convenience wrapper to hold the co-ordinates belonging to | |
# a particular "point" - i.e. the base station location, or the remote | |
# device location. | |
# | |
# Units: lat, long = radians. alt = meters. | |
Point = namedtuple('Point', ['lat', 'lon', 'alt']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
profiling.py - standard library backed context managers for performance profiling | |
To use these context managers, ensure that the appropriate environment variable is | |
set - i.e. 'PROFILING_ENABLED'. The default directory for outputting profiling data | |
is the *current directory* - i.e `.` - although this too can be overidden via the | |
environment - specifically `PROFILING_DIRECTORY`. | |
Due to the quirk in the design of `pathlib`, passing an absolute path to one of the | |
context managers will override the output directory associated with that trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getGithubGists(username) { | |
const gists = await require('axios').get( | |
`https://api.github.com/users/${username}/gists` | |
) | |
return gists.data.map(({html_url, description, created_at, files}) => { | |
return { | |
url: html_url, | |
files: Object.keys(files), | |
description, created_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const run = require('util').promisify(require('child_process').exec) | |
async function getGitStats() { | |
const {stdout: refHash } = await run('git rev-parse HEAD') | |
const {stdout: message } = await run(`git log --format=%B -n 1 ${refHash}`) | |
const {stdout: branch } = await run('git rev-parse --abbrev-ref HEAD') | |
return { refHash, message, branch } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A (very over-engineered, yet still impressively scruffy) implementation of a | |
* Sliding Window (adjacent, overlapping, and buffered.) for the processing of | |
* sequential data. | |
* | |
* Written very hurriedly one evening, to support a blog post. | |
* | |
* @param {array} data | |
* @param {int|Number} width | |
* @param {array?} accumulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DockerClient { | |
/** @param resource */ | |
private $curlClient; | |
/** @param string */ | |
private $socketPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require("lodash"); | |
const fixtures = require("./fixtures.js"); | |
/** | |
* Simple object capable of demonstrating how to build a dependency tree | |
* from a POM-like structure; using BFS (queue based). | |
*/ | |
function DependencyTraverser(targetObject = {}) | |
{ | |
/** Queue containing dependencies to process */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dbus | |
class MediaPlayer: | |
"""Recieves state from a MediaPlayer using dbus.""" | |
player_properties = False | |
def __init__(self, player_name): | |
# Get an instance of the dbus session bus, and retrieve | |
# a proxy object for accessing the MediaPlayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> // memcpy | |
#include <stdlib.h> // | |
/** | |
* | |
* | |
*/ | |
typedef struct { | |
uint8_t object_count, iteration_counter, max_count; | |
uint8_t *indices_in_use; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fergus In London - https://fergus.london <[email protected]> | |
# | |
# Uses the org.freedesktop.problems dbus channel to read out reported problems. | |
# | |
# Requires pydbus from pip. | |
# Requires python-gobject and glib installed on your distro. | |
# | |
import sys | |
import argparse | |
from pydbus import SystemBus |
NewerOlder