Skip to content

Instantly share code, notes, and snippets.

View bluesmoon's full-sized avatar

Philip Tellis bluesmoon

View GitHub Profile
@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 / 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 / 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 / gist:69587
Created February 24, 2009 14:33
TMPL_VAR usage
<TMPL_VAR name="foo" default="bar" escape="html|url|js|none">
// Constructor
HTML.Template({
tmpl_str: tmpl,
OR
file_url: foo,
file_type: tmpl|js,
});
// Setting
HTML.Template.param({
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.