Skip to content

Instantly share code, notes, and snippets.

View thoov's full-sized avatar
🤔
Is the Kool-Aid man the glass part or the liquid?

Travis Hoover thoov

🤔
Is the Kool-Aid man the glass part or the liquid?
View GitHub Profile
function Promise(promise) {
if (promise instanceof Promise) {
return promise;
} else {
// this is a new promise chain
this.callbacks = [];
}
}
Promise.prototype.then = function(callback_ok, callback_error) {
@thoov
thoov / js_invocation_types.js
Last active December 17, 2015 11:39
Javascript Invocation Types
/*
There are four patterns of invocation in JavaScript:
- the method invocation pattern
- the function invocation pattern
- the constructor invocation pattern
- the apply invocation pattern
The patterns differ in how the bonus parameter this is initialized.
@thoov
thoov / flatten.php
Created November 8, 2011 07:48
Flatten and Inflate n-dimensional arrays in php.
<?php
private function flatten($array, $base = "", $div_char = "/")
{
$ret = array();
if(is_array($array))
{
foreach($array as $k => $v)
{
if(is_array($v))
@thoov
thoov / cookie.js
Created May 21, 2011 18:24
Javascript Cookie Functions