Skip to content

Instantly share code, notes, and snippets.

View tregoning's full-sized avatar

John Tregoning tregoning

View GitHub Profile
@tregoning
tregoning / osThemePref.js
Created January 30, 2024 17:32
Helper module for interacting with OS level theme preferences
/**
* OS theme preference related helper functions & live binding
* - liveUserOSThemePref: live binding to the user's OS theme preference
* - getCurrentOSTheme: returns the current OS theme preference
* - setOSThemeChangeCallback: sets a callback function to be called when the OS theme preference changes
*/
let userOSThemePref;
let themeChangeCallback;
export {userOSThemePref as liveUserOSThemePref};
@tregoning
tregoning / docker-compose.yml
Created June 7, 2020 21:22
Minimalistic setup for Elastic on Docker
version: '3.7'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1 # Latest version at: https://www.docker.elastic.co/
container_name: elasticsearch
environment:
- xpack.security.enabled=false
- discovery.type=single-node
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" viewBox="0 0 20 4">
<path fill="none" stroke="#000000" stroke-width="1" class="st0" d="M0,3.5 c 5,0, 5, -3, 10, -3 s 5,3, 10, 3 c 5,0, 5, -3, 10, -3 s 5,3, 10, 3" />
<style type="text/css">
.st0 {
animation: shift 0.3s linear infinite;
}
@keyframes shift {
from {
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" viewBox="0 0 20 4">
<path fill="none" stroke="#000000" stroke-width="1" class="st0" d="M0,3.5 c 5,0, 5, -3, 10, -3 s 5,3, 10, 3 c 5,0, 5, -3, 10, -3 s 5,3, 10, 3" />
<style type="text/css">
.st0 {
animation: shift 0.3s linear infinite;
}
@keyframes shift {
from {
@tregoning
tregoning / percentileOfScore.js
Created March 18, 2019 17:02
percentileOfScore similar to Python's scipy.stats.percentileofscore(kind='mean') - #js #javascript #stats #percentile
/**
* @see [https://en.wikipedia.org/wiki/Percentile_rank]
* @param {array} data - list of values
* @param {number } value - value that we need fo find percentile rank for
* @returns {number} - returns the percentile rank/score for the provided value
*/
export const percentileOfScore = (data, value) => {
if (!data.length) {
@tregoning
tregoning / fetchImage.js
Last active March 14, 2019 00:19
preload image as a promise #img #promise
/**
* Returns a promise once an image has been preloaded successfully
*
* @param {String} url
*
* @returns {Promise}
*/
const fetchImage = (url) => new Promise((resolve, reject) => {
const img = new Image();
@tregoning
tregoning / highstock.js
Created July 1, 2016 06:49
Highstock v4.2.5 release (with patch applied for symmetricalLog)
/*
Highstock JS v4.2.5 (2016-05-06)
(c) 2009-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(L,ga){typeof module==="object"&&module.exports?module.exports=L.document?ga(L):ga:L.Highcharts=ga(L)})(typeof window!=="undefined"?window:this,function(L){function ga(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+a;if(b)throw Error(c);L.console&&console.log(c)}function xb(a,b,c){this.options=b;this.elem=a;this.prop=c}function z(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=c&&typeof c==="object"&&
Object.prototype.toString.call(c)!=="[object Array]"&&d!=="renderTo"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a<c;a++)d=e(d,b[a]);return d}function K(a,b){return parseInt(a,b||10)}function Ca(a){return typeof a==="string"}function ea(a){return a&&typeof a==="object"}function Ja(a){return Object.prototype.toString.
@tregoning
tregoning / highstock-all.js
Created July 1, 2016 06:43
Highstock-all v4.2.5 release (with patch applied for symmetricalLog)
/*
Highstock JS v4.2.5 (2016-05-06)
(c) 2009-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(L,ga){typeof module==="object"&&module.exports?module.exports=L.document?ga(L):ga:L.Highcharts=ga(L)})(typeof window!=="undefined"?window:this,function(L){function ga(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+a;if(b)throw Error(c);L.console&&console.log(c)}function xb(a,b,c){this.options=b;this.elem=a;this.prop=c}function z(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=c&&typeof c==="object"&&
Object.prototype.toString.call(c)!=="[object Array]"&&d!=="renderTo"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a<c;a++)d=e(d,b[a]);return d}function K(a,b){return parseInt(a,b||10)}function Ca(a){return typeof a==="string"}function ea(a){return a&&typeof a==="object"}function Ja(a){return Object.prototype.toString.
@tregoning
tregoning / highstock.src.js
Created July 1, 2016 06:40
Highstock v4.2.5 release (with patch applied for symmetricalLog)
This file has been truncated, but you can view the full file.
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
/**
* @license Highstock JS v4.2.5 (2016-05-06)
*
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {