Skip to content

Instantly share code, notes, and snippets.

View bluesmoon's full-sized avatar

Philip Tellis bluesmoon

View GitHub Profile
@bluesmoon
bluesmoon / tests.vega.json
Last active March 25, 2024 01:39
vega-lite spec for unit test gannt chart
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"layer": [
{
"encoding": {
"x2": {
"field": "t_end"
},
"color": {
"field": "status",
@bluesmoon
bluesmoon / boomerang-iframe-loader-v10.1.js
Last active March 20, 2019 14:54
Load boomerang while allowing the caller to control where the iframe is loaded
(function(){
if (window.BOOMR && window.BOOMR.version) { return; }
var dom,doc,where,iframe = document.createElement("iframe"),win = window;
function boomerangSaveLoadTime(e) {
win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime();
}
if (win.addEventListener) {
win.addEventListener("load", boomerangSaveLoadTime, false);
} else if (win.attachEvent) {
@bluesmoon
bluesmoon / loader.html
Last active January 3, 2024 20:40
A CSP compliant non-blocking script loader
<script id="nb-loader-script">
(function(url) {
// document.currentScript works on most browsers, but not all
var where = document.currentScript || document.getElementById("nb-loader-script"),
promoted = false,
LOADER_TIMEOUT = 3000,
IDPREFIX = "__nb-script";
// function to promote a preload link node to an async script node
@bluesmoon
bluesmoon / README.md
Last active September 10, 2019 16:27
This is a loader snippet for boomerang that doesn't use the iframe except for legacy browsers, and does not use document.write

Moved to https://developer.akamai.com/tools/boomerang#mPulseNon-BlockingLoaderSnippet

This is a loader snippet for boomerang (https://github.com/soasta/boomerang) that doesn't use the iframe except for legacy browsers, and does not use document.write

If an iframe is required, it is injected into the page immediately or soon after the script, so you may place the script wherever in the HTML you would like the iframe to show up.

For IE6 & 7, we will fallback to a same-window iframeless dynamic script node. This does mean that the script will be a Single Point of Failure for these two browsers, but given the low combined market share of these two browsers, the choice is between not getting any beacons for these browsers or potentially being a SPoF for users of these browsers.

You MUST include everything, including the `

@bluesmoon
bluesmoon / keybase.md
Created November 21, 2017 04:45
keybase.md

Keybase proof

I hereby claim:

  • I am bluesmoon on github.
  • I am bluesmoon (https://keybase.io/bluesmoon) on keybase.
  • I have a public key ASDj8_i2NS7sgcu7CsOe_zFBFGvFNpbT7WT5VaADDDSreAo

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bluesmoon
bluesmoon / boomerang-1-loaded-event.js
Last active June 13, 2017 17:01
Code to identify when boomerang has loaded
// You can give this function any name, just use the same name on lines 18 & 22 below
function boomerang_loaded_handler(e) {
// Older IE stored the event in window.event global
if(!e) { e = window.event; }
// If there is no event or this is a "propertychange" event and the propertyName is not onBoomerangLoaded,
// then abort
if(!e || (e.hasOwnProperty("propertyName") && e.propertyName !== "onBoomerangLoaded")) {
return;
}
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@bluesmoon
bluesmoon / README.md
Last active February 15, 2022 12:43
Pseudo-Random number generator that follows a Normal or Log-Normal distribution.

Marsaglia-polar.js

This script generates random numbers along a Normal or Log-normal distribution using the Marsaglia polar method.

There are four functions you can use:

  • normalRandom: Generate random numbers that follow a Normal distribution.
  • normalRandomInRange: Generate random numbers that follow a Normal distribution but are clipped to fit within a range
  • normalRandomScaled: Generate random numbers that follow a Normal distribution with a given mean and standard deviation
  • lnRandomScaled: Generate random numbers that follow a Log-normal distribution with a given geometric mean and geometric standard deviation
@bluesmoon
bluesmoon / FSWatcher-test.js
Created September 5, 2012 20:34
only first of multiple fs.FSWatchers will fire on a directory
var fs = require('fs')
fs.watch("./", function(event, filename) { console.log(1, event, filename); });
fs.watch("./", function(event, filename) { console.log(2, event, filename); });
fs.watch("./", function(event, filename) { console.log(3, event, filename); });