Skip to content

Instantly share code, notes, and snippets.

if (!window.BakeCookies) {
window.BakeCookies = {
set: (function () {
var days;
return function BakeCookies_set(name, value, expires) {
if ((expires != null) && !(expires instanceof Date)) {
switch (typeof (expires)) {
case "number":
days = expires;
@wthit56
wthit56 / gist:4427983
Last active December 10, 2015 11:29
Reusing objects to avoid Garbage Collection
// run here (use the data-uri below as an address):
// data:text/html;ascii,<script src="https://gist.github.com/raw/4427983/9bd86a469ad84effee2daffad03909a25d4200a2/gistfile1.js" type="text/javascript"></script>
var Reusable = (function () {
// used to cache any clean objects for reuse
var clean = [];
function Reusable(value) {
console.group("creating new object");
var _ = this;
@wthit56
wthit56 / gist:4427971
Last active December 10, 2015 11:29 — forked from anonymous/gist:4427822
// run here (use the data-uri below as an address):
// data:text/html;ascii,<script src="https://gist.github.com/raw/4427971/cef83fed8b6de8bfbb9fa3ae461b724fff87c057/gistfile1.js" type="text/javascript"></script>
// The technique used here is based on an article by Ashley Gullen: http://netm.ag/SWI0E5
// Array#slice returns an array with the seleted range of items.
// Because a new array is created every time you use this method, however,
// all these arrays are in memory, which means the JavaScript GC (Garbage Collection)
// has to collect up all of these unused arrays and throw them away.
// In performance-critical situations, such as in a game-loop that needs to run within