Skip to content

Instantly share code, notes, and snippets.

View choult's full-sized avatar

Christoper Hoult choult

View GitHub Profile
@choult
choult / Benthos HTTP-SSE parser
Last active December 21, 2022 01:06
Generic Benthos HTTP Server-Sent-Events ingest and parser
input:
broker:
copies: 1
inputs:
- http_client:
url: "https://mas.to/api/v1/streaming/public"
stream:
enabled: true
reconnect: true
codec: "delim:\n\n"
@choult
choult / Benthos Mastodon streaming input
Created December 19, 2022 16:09
This Benthos config demonstrates the consumption of Mastodon HTTP Server-Sent Events
input:
broker:
copies: 1
inputs:
- http_client:
url: "https://mas.to/api/v1/streaming/public"
stream:
enabled: true
reconnect: true
codec: lines
<?php
class Timeout extends \RuntimeException {
}
function setRequestTimeout($timeout) {
$start = microtime(true);
register_tick_function(function () use ($start, $timeout) {
print microtime(true) - $start . " ";
@choult
choult / booleans.md
Last active August 29, 2018 10:06
Everything You !(Didn’t Want to Know About Logic OR Were Unafraid to Ask)

Running throughout our code, from high level language through machine code and right down to the very silicon it runs on, the basic building blocks of our world are the humble 'true' and 'false'. But how much do you really know about what are essentially the atoms of computing? In this talk aimed at new and experienced developers alike, Christopher will uncover the truth of the simple boolean, from its history and application in computer science to techniques for simplifying and clarifying your logic to make your code more understandable and efficient.

NB: I'll submit with 'I' instead of 'Christopher' but I prefer the third person for published text

@choult
choult / gist:e0a216472cfee9ed3a295efcdc2a7711
Last active August 29, 2018 10:40
Orchestrating Manoeuvres from the Dark

Whether we’re an industry veteran or a newbie to a company, we all have to deal with the legacy system that No-one Knows, Just Works and Ain’t Broke so Don’t Fix It. But what happens when it does go wrong, or the server falls over, and suddenly that old single point of failure becomes a business priority? In this talk, Christopher will cover a variety of techniques to help you understand the cruft and ensure you can modernize it efficiently and without (much) fear.

@choult
choult / dm.php
Last active August 3, 2016 12:48
Source code to generate random Daily Mail headlines from a JSON file of real DM headlines
<?php
class Word
{
private $word = '';
private $links = [];
public function __construct($word) {
$this->word = $word;
}
@choult
choult / selectize-context.php
Last active March 2, 2017 15:45
Selecting from a selectize.js styled dropdown in Behat
<?php
/**
* {@inheritdoc}
*/
public function selectOption($select, $option)
{
$session = $this->getSession();
$page = $session->getPage();
$field = $page->findField($select);

Graphs are Everywhere

No - not charts! Graphs are a data structure that are more than just the nodes and edges they contain: from mapping networks to representing arithmetic, writing chat-bots to inferring relationships, applying graphs to a problem can quite often provide an elegant solution. In this talk, Christopher will cover the basics of graphs as well as go over a few simple but fun examples of this versatile concept.

Verifying that +choult is my blockchain ID. https://onename.com/choult
function respond(array $data = null, $code, $message, array $headers = array()) {
header('HTTP/1.1 ' . $code . ' ' . $message);
header('Content-type: application/json');
foreach ($headers as $k => $v) {
header("$k: $v");
}
print json_encode($data, JSON_NUMERIC_CHECK);
exit;
}