Skip to content

Instantly share code, notes, and snippets.

Philip Tellis bluesmoon

View GitHub Profile
@bluesmoon
bluesmoon / boomerang-iframe-loader-v10.1.js
Last active Mar 20, 2019
Load boomerang while allowing the caller to control where the iframe is loaded
View boomerang-iframe-loader-v10.1.js
(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 Jan 23, 2019
A CSP compliant non-blocking script loader
View loader.html
<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 Mar 22, 2019
This is a loader snippet for boomerang that doesn't use the iframe except for legacy browsers, and does not use document.write
View README.md

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 <script> node with exactly the same id attribute. Replace "YOUR-API-KEY-GOES-HERE" with your actual API key (in quotes)

View 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:

View writing-custom-ijulia-widgets.ipynb
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 Jun 13, 2017
Code to identify when boomerang has loaded
View boomerang-1-loaded-event.js
// 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;
}
View user-timing-rum.js
// 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 Mar 30, 2019
Pseudo-Random number generator that follows a Normal or Log-Normal distribution.
View README.md

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 Sep 5, 2012
only first of multiple fs.FSWatchers will fire on a directory
View FSWatcher-test.js
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); });
@bluesmoon
bluesmoon / test-cipher.js
Created Jul 26, 2012
Test Node.js Cipher implementation.
View test-cipher.js
crypto=require("crypto");
assert=require("assert");
data = [
// 0. Short key, short data, ascii data, hex output
{ k: "abcde", d: "foobar", enc_in: "ascii", enc_out: "hex" },
// 1. Long key, short data, ascii data, hex output
{ k: "abcdefabcdefabcdeabcdefabcdefabcdeabcdefabcdefabcdeabcdefabcdefabcdef", d: "foobar", enc_in: "ascii", enc_out: "hex" },
// 2. Long key, long data, ascii data, hex output
You can’t perform that action at this time.