Skip to content

Instantly share code, notes, and snippets.

@OllieJones
OllieJones / queue.js
Last active September 17, 2021 15:50
Queue class, super simple, based on Kate Morley's queue code.
'use strict';
/*
Queue.js
A class to represent a queue
Created by Kate Morley - https://code.iamkate.com/ - and released under the terms
of the CC0 1.0 Universal legal code:
@OllieJones
OllieJones / wordpress-hooks.php
Last active March 16, 2022 11:56
Register WordPress Hooks Declaratively
<?php
namespace OllieJones;
use ReflectionClass;
use ReflectionMethod;
/**
* Automatically register WordPress hooks in classes derived from this one.
*
'use strict';
/*globals ebml */
if ( !window.ebml ) window.ebml = {};
ebml.EbmlDecoder = function EbmlDecoder( options ) {
var schema = {
"80": {
@OllieJones
OllieJones / h264tools.js
Created February 4, 2021 16:11
h.264: Create an 'avcC' atom from a sequence of NALUs emitted by MediaRecorder
'use static'
// noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**
* Tools for handling H.264 bitstream issues.
*/
/**
* Handle the parsing and creation of "avcC" atoms.
*/
@OllieJones
OllieJones / DataTableResultSet.cs
Last active March 3, 2023 22:16
C# code for handling Ajax calls for the DataTables.net client table-rendering plugin.
/// <summary>
/// Resultset to be JSON stringified and set back to client.
/// </summary>
[Serializable]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class DataTableResultSet
{
/// <summary>Array of records. Each element of the array is itself an array of columns</summary>
public List<List<string>> data = new List<List<string>>();
@OllieJones
OllieJones / wp_options_length_histogram.sql
Created June 23, 2022 15:59
Display a histogram of WordPress option lengths with histogram buckets approximating the log of lengths
-- Display a histogram of WordPress option lengths,
-- with histogram buckets approximating the log of lengths,
WITH lengths AS (
SELECT LENGTH(option_value) l,
autoload,
option_name
FROM wp_options
),
buckets AS (
SELECT autoload, l, option_name,
@OllieJones
OllieJones / fullquery
Last active September 25, 2023 14:09
Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)
SELECT zip, primary_city,
latitude, longitude, distance
FROM (
SELECT z.zip,
z.primary_city,
z.latitude, z.longitude,
p.radius,
p.distance_unit
* DEGREES(ACOS(LEAST(1.0, COS(RADIANS(p.latpoint))
* COS(RADIANS(z.latitude))