This file contains 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 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 number_format(n) { | |
n += ''; | |
x = n.split('.'); | |
y = x[0]; | |
z = x.length > 1 ? '.' + x[1] : ''; | |
var rgx = /(\d+)(\d{3})/; | |
while (rgx.test(y)) { | |
y = y.replace(rgx, '$1' + ',' + '$2'); | |
} | |
return y + z; |
This file contains 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
/*jslint vars: true, unparam: true, browser: true, white: true */ | |
/*global jQuery */ | |
(function ($) { | |
"use strict"; | |
var onEnter, onLeave, startTimer, stopTimer, remove, getPos; | |
var defaults = { | |
delay: 500, | |
content: null, | |
allowHTML: false // XXX: rename | |
}; |
This file contains 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
// USE: <a href="http://yoursite.com/" rel="copylink">yoursite.com</a> | |
$(document).ready(function () { | |
$(window).on("click", "a[rel=copylink]", function (e) { | |
e.preventDefault(); | |
var href = $(this).prop("href"), | |
txt = $(this).text(); | |
$(this).hide().parent().html('<input type="text" value="' + href + '" data-href="' + href + '" data-txt="' + txt + '" width="20" class="copyinput">'); | |
$(".copyinput").focus().select() | |
}).on("blur", ".copyinput", function () { |
This file contains 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 texterize($s = '') { | |
$s = str_replace(' ', '', $s); | |
$s = str_split($s); | |
$s = array_unique($s); | |
natcasesort($s); | |
return urlencode(implode($s)); | |
} |
This file contains 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
-- The comparison "_CURRENT-ID_" is an integer. | |
--Last Row: | |
SELECT `field1` | |
FROM `tablename` | |
WHERE `id` < '_CURRENT-ID_' | |
ORDER BY `id` DESC | |
LIMIT 1 |
This file contains 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 | |
/* | |
BCRYPT function group | |
*/ | |
function bcrypt_hash($password, $work_factor = 8) { | |
if ($work_factor < 4 || $work_factor > 31) $work_factor = 8; | |
$salt = '$2a$'.str_pad($work_factor, 2, '0', STR_PAD_LEFT).'$'. | |
substr( |
This file contains 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'; |
This file contains 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 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 |
OlderNewer