Skip to content

Instantly share code, notes, and snippets.

View bluesmoon's full-sized avatar

Philip Tellis bluesmoon

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// Constructor
HTML.Template({
tmpl_str: tmpl,
OR
file_url: foo,
file_type: tmpl|js,
});
// Setting
HTML.Template.param({
@bluesmoon
bluesmoon / gist:69587
Created February 24, 2009 14:33
TMPL_VAR usage
<TMPL_VAR name="foo" default="bar" escape="html|url|js|none">
@bluesmoon
bluesmoon / gist:774939
Created January 11, 2011 19:08
Measure page generation time using boomerang
<?php
$t_serverstart = microtime(true);
// rest of page generation goes in here
$t_serverend = microtime(true);
?>
<script type="text/javascript">
BOOMR.plugins.RT.setTimer("t_pagegen", <?php echo $t_serverend - $t_serverstart; ?>);
</script>
@bluesmoon
bluesmoon / stddev-fast
Created April 25, 2012 15:57
Fast calculation of stddev
Datum: x
Size: n
Mean: m
variance = sum((x-m)^2)/n
= (x0-m)^2 + (x1-m)^2 + (x2-m)^2 ...
----------------------------------
n
@bluesmoon
bluesmoon / test-cipher.js
Created July 26, 2012 19:47
Test Node.js Cipher implementation.
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
@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); });
@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 / 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: