View profiling.py
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. |
View gists.js
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 |
View gitstats.js
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 } | |
} |
View 1.window.js
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 |
View DockerClient.php
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; |
View DependencyTraverser.js
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 */ |
View mpris.py
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 |
View collection.c
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; |
View problems.py
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 <fergus@fergus.london> | |
# | |
# 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 |
View roller.js
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 - <fergus@fergus.london> | |
* | |
* Simple little function for calculating rolling averages, both simple and | |
* weighted. Example can be found on the GitHub Gist, or on my website. | |
* | |
* Do as you please, no rights reserved and no warranties provided. :) | |
*/ | |
/** |
NewerOlder