Skip to content

Instantly share code, notes, and snippets.

👌
Rest, Recuperation.. and a backlog of personal projects.

Fergus FergusInLondon

👌
Rest, Recuperation.. and a backlog of personal projects.
Block or report user

Report or block FergusInLondon

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
@FergusInLondon
FergusInLondon / 1.window.js
Last active Apr 28, 2019
Processing Sequential Data w/ "*Sliding Windows*"
View 1.window.js
/**
* 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
@FergusInLondon
FergusInLondon / DockerClient.php
Created Apr 23, 2018
Example Docker Engine API Client using PHP
View DockerClient.php
<?php
class DockerClient {
/** @param resource */
private $curlClient;
/** @param string */
private $socketPath;
@FergusInLondon
FergusInLondon / mpris.py
Last active Nov 4, 2017
Retrieve data from a Media Player in Linux, via dbus. (Uses Python)
View mpris.py
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
@FergusInLondon
FergusInLondon / collection.c
Created May 2, 2017
Dynamic array/container implementation in C - includes iterator. (WIP / Brain-Dump)
View collection.c
#include <string.h> // memcpy
#include <stdlib.h> //
/**
*
*
*/
typedef struct {
uint8_t object_count, iteration_counter, max_count;
uint8_t *indices_in_use;
@FergusInLondon
FergusInLondon / problems.py
Created May 1, 2017
Use dbus to parse system problems
View problems.py
# 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
@FergusInLondon
FergusInLondon / roller.js
Last active Apr 27, 2017
Simple Rolling Average function
View roller.js
/* 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. :)
*/
/**
@FergusInLondon
FergusInLondon / rolling_average.js
Last active Oct 3, 2018
A little JS object for calculating rolling averages, complete with callbacks upon update.
View rolling_average.js
/* 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. :)
*/
@FergusInLondon
FergusInLondon / events.h
Last active Apr 27, 2017
Really simple events/listeners registry in C
View events.h
/**
* Simple little event registry built around the worlds most simplistic
* linked list implementation. Allows you to register a function (void())
* against a integer value, and provides a mechanism for triggering the
* associated functions for an integer.
*
* Not a great deal of use beyond those fun little weekend Arduino type
* projects.
*
* @see example.c
@FergusInLondon
FergusInLondon / base64_encode.c
Last active Apr 17, 2017
Base 64 Encoding in C
View base64_encode.c
#include <stdio.h>
#include <stdlib.h>
#define FIRST_SIX_INDEX (buf[0] & 0xfc) >> 2
#define SECOND_SIX_INDEX ((buf[0] & 0x03) << 4) + ((buf[1] & 0xf0) >> 4)
#define THIRD_SIX_INDEX ((buf[1] & 0x0f) << 2) + ((buf[2] & 0xc0) >> 6)
#define FOURTH_SIX_INDEX buf[2] & 0x3f
char base64_map[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@FergusInLondon
FergusInLondon / shuffler.js
Last active Apr 14, 2017
Simple array shuffler example.
View shuffler.js
/**
* shuffle(array[]) - Shuffles an array via a simplistic
* algo, not too dissimilar to Fisher-Yates.
*
* Ignore the -ahem- "clever" variable swapping one-liner,
* that's all it does.
*
* @param array
* @return array
*/
You can’t perform that action at this time.