This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOptions(len) { | |
return Array(len).join().split(",").map(function(c, i) { | |
return i; | |
}); | |
} | |
function getStep(i, len) { | |
return factorial(len) / len * i; | |
} | |
function to(order) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('[ajax-load]').each(function() { | |
var $this = $(this); | |
$this.load($this.attr('ajax-load'), function() { | |
if ($this.attr('ajax-onloaded')) { | |
eval($this.attr('ajax-onloaded')); | |
} | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Timer() { | |
var _this = {}; | |
return extend.bind(this, _this, { | |
timestamp: new Date().getTime(), | |
timeout: -1, | |
delay: 1000, | |
tick: function(timestamp) { | |
var timestamp = timestamp || this.now(); | |
this.timeout = setTimeout(function() { | |
var timestamp = _this.now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend() { | |
var result = arguments[0]; | |
for(var i = 1; i < arguments.length; i++) { | |
for(var key in arguments[i]) { | |
result[key] = arguments[i][key]; | |
} | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ordinal_suffix($n) { | |
$j = $n % 10; | |
$k = $n % 100; | |
if (!($k >= 11 && $k <= 19)) { | |
switch($j) { | |
case 1: | |
return "st"; | |
case 2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function once(fns, callback, args) { | |
var c = 0; | |
var len = fns.length; | |
var results = []; | |
fns.forEach(function(fn, i) { | |
fn.apply(fn, [function(value) { | |
results[i] = value; | |
c++; | |
if (c == len) { | |
callback.apply(callback, results); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sort(rows, key, dir) { | |
if (!key || !rows || typeof rows.sort !== "function" || !rows.length) { | |
return rows; | |
} | |
var dir = dir ? String(dir).toLowerCase() : "up"; | |
if (typeof key === "function") { | |
return rows.sort(key); | |
} else { | |
return rows.sort(function(rowA, rowB) { | |
if (dir === "u" || dir === "up" || dir === "asc") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$profiles = array(); | |
function profile_start($key) { | |
global $profiles; | |
$profiles[$key] = array(); | |
$profiles[$key]["start"] = microtime(true); | |
} | |
function profile_end($key) { | |
global $profiles; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function make_address($info = array(), $line_seperator = "<br>\r\n") { | |
extract($info); | |
$address = ""; | |
if (isset($address_line_1) && $address_line_1) { | |
$address .= $address_line_1; | |
} | |
if (isset($address_line_2) && $address_line_2) { | |
if ($address) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Author: Daniel Wilson <[email protected]> (https://github.com/danielrw7) | |
* Gist: https://gist.github.com/danielrw7/63ee3faffb86613f379a | |
*/ | |
function props($key) { | |
$props = preg_split("/[\\.\\[\\]\\\"]/", trim($key)); | |
$result = array(); |