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 base64url_encode($data) { | |
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | |
} | |
function base64url_decode($data) { | |
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); | |
} |
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
_.once($.fn.slideUp.bind($div, $.fn.remove.bind($div))); | |
// vs | |
_.once(function() { | |
$div.slideUp($.fn.remove.bind($div)); | |
}); | |
// vs |
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
jQuery.prototype.fromObject = function(object) { | |
if (object instanceof jQuery) { | |
return object; | |
} | |
return $(object); | |
} | |
function handlejQueryObject(jQuery object) { | |
// object will always be a jquery rep of the body element |
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
/** | |
* This function allows you to prefill "parts" of a functions | |
* arguments. | |
* | |
* @param {Function} func The function to call | |
* @param {mixed} An argument | |
* @param {mixed} ... | |
* | |
* @return {Function} Function with arguments that're prefilled | |
* |
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() { | |
/** | |
* Little script that allows you to call requirejs.config multiple times. | |
*/ | |
/** | |
* Stores the actual config that gets passed into requirejs.config | |
* @type {Object} | |
*/ |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Templating</title> | |
</head> | |
<body> | |
<div id="Item" class="template"> | |
<li class="item"> |
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 | |
/** | |
* Search an array of regular expressions for the indexes that match a needle | |
* | |
* @param string $needle The needle | |
* @param array $haystack The array of regular expressions to search | |
* @param boolean $all Should it return all indexes or just the first one | |
* @return mixed boolean: false if no matches are found and $all | |
* equals false | |
* |
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
/** | |
* Growing and fading numbers | |
*/ | |
* { padding: 0; margin: 0; } | |
html, body { height: 100%; overflow: hidden; } | |
.number { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50% -50%); |
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 | |
define('DS', DIRECTORY_SEPARATOR); | |
/** | |
* Recursive glob | |
*/ | |
function recursive_glob($pattern, $flags = 0) { | |
$files = glob($pattern, $flags); | |
foreach (glob(dirname($pattern) . DS . '*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |