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 partial(fn) { // `fn` is the original function | |
// `args_a` are the arguments (barring `fn`) of the first call. | |
var args_a = Array.prototype.slice.call(arguments, 1); | |
// Now, we return a new function, with the first set of arguments already applied. | |
return function partialApplicator() { | |
// `args_b` are the arguments applied at the second call | |
var args_b = Array.prototype.slice.call(arguments); | |
// Now, concatenate both Arrays and apply them to the original function |
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
var Return; | |
function slugify(){ | |
var O = Array.prototype.slice.call(arguments), | |
t = [], | |
x = 0, | |
i; | |
for (i in O){ | |
if (O.hasOwnProperty(i) && typeof O[i] === "string"){ |
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 listOrArray(Arr) { | |
var List = Array.prototype.slice.call(arguments, 1), | |
i; | |
// If `List` is not empty, assume there are more module objects sent as List Arguments | |
if (List.length > 0) { | |
List.unshift(Arr); | |
Arr = List; | |
} else { | |
// No List args in sight, treat the first arg `Arr` as an array and loop through it. |
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
window.onhashchange = doChange; | |
window.onload = doChange; | |
function doChange() { | |
var _hash = window.location.hash.replace("#!", ""); | |
console.log(_hash); | |
} |
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
// ------------ Tests | |
var s0, | |
s1; | |
// Ordered Array mode | |
s0 = sprint("This is %s %s call, using an %s in order", "a", "function", "array"); | |
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
var MyLib = { | |
vars: { | |
var1: 'value1', | |
var2: 'value2' | |
}, | |
func1: function () { | |
return this.vars.var1; | |
}, | |
func2: function () { | |
alert("This is func2"); |
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
#001F52 |
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 | |
session_start(); | |
/** | |
Setp 1. Get the query string variable and set it in a session, then remove it from the URL. | |
*/ | |
if (isset($_GET['to']) && !isset($_SESSION['to'])) { | |
$_SESSION['to'] = urldecode($_GET['to']); | |
header('Location: http://yoursite.com/path/to/ref-mask.php');// Must be THIS script | |
exit(); |
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 styleNumber(number, precision) { | |
if (number.toString().length >= 4) { | |
var place = 1; | |
if (precision !== undefined && precision === 1) { | |
place = 10; | |
} else if (precision === 2) { | |
place = 100; | |
} | |
number = ((number / 100) / 10) * place; | |
number = Math.round(number) / place + ' k'; |
NewerOlder