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 | |
/* | |
consider decomposing the characters to "capture" more "obscure" characters such as ṩ | |
- http://www.php.net/manual/en/normalizer.normalize.php#92592 | |
*/ | |
/** | |
* Normalize a string to only contain alphanumeric characters and dashes. | |
* |
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 | |
if (!empty($argv[1])) { | |
// directory given by CLI argument: list.php /foo/bar | |
$dir = $argv[1]; | |
} elseif (!empty($_GET['dir'])) { | |
// directory given by HTTP: /list.php?dir=/foo/bar | |
$dir = $_GET['dir']; | |
} else { | |
// no directory given, use the one list.php is in |
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
/* | |
* adds "remove" event triggered when a DOMNode is removed, | |
* allowing to register DOM elements to be removed when a | |
* given other element is removed from dom. | |
* | |
* (last tested with jQuery 1.4.4) | |
*/ | |
(function($,undefined){ | |
// register node to be removed when the base node is removed |
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
/* | |
* allow to pass a RegExp to remove class | |
* Example: | |
* $('.foobar).removeClass(/some-pattern-[a-z]+/g); | |
*/ | |
var $removeClass = $.fn.removeClass; | |
$.fn.removeClass = function(className) { | |
if (className.constructor.name === "RegExp") { | |
return $removeClass.call(this, function() { | |
return (this.className.match(className) || []).join(' '); |
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
/* | |
* cheap Biolab auto-firing cheat | |
* Shoot 10x per second without hitting the c key | |
* simply run this in your console | |
*/ | |
window.setInterval(function() { | |
// fire the "c" keydown event | |
var evt = document.createEvent("KeyEvents"); | |
evt.initKeyEvent("keydown", 1, 1, null, false, false, false, false, 67, 0); | |
document.dispatchEvent(evt); |
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 | |
// Watermark with Imagick | |
// load images | |
$image = new Imagick("image.jpg"); | |
$watermark = new Imagick("watermark.png"); | |
// translate named gravity to pixel position | |
$position = gravity2coordinates($image, $watermark, 'lowerRight', 5, 5); | |
// compose watermark onto image |
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 | |
// extracting attributes | |
// http://stackoverflow.com/questions/7776469/preg-match-with-name-being-last-in-input | |
$expected = array( | |
'value' => 'joe', | |
'type' => 'hidden', | |
'name' => 'firstname', | |
); |
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 | |
mb_internal_encoding('UTF-8'); | |
/** | |
* multibyte string compatible range('A', 'Z') | |
* | |
* @param string $start Character to start from (included) | |
* @param string $end Character to end with (included) | |
* @return array list of characters in unicode alphabet from $start to $end |
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 | |
class FileDownload | |
{ | |
public static $_response_status = array( | |
200 => 'OK', | |
201 => 'Created', | |
204 => 'No Content', | |
206 => 'Partial', | |
207 => 'Multi-Status', // WTF ?? |
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
// regarding http://stackoverflow.com/questions/7887157/constructing-regular-expressions-to-match-numeric-ranges | |
function IntRangeTest(expression) { | |
var tests = []; | |
/* | |
possible expressions: | |
"*" - any integer | |
"0,3-4" - 0 or between 3 and 4 | |
"0,-10--4" - 0 or between -10 and -4 |
OlderNewer