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 JSON_to_URLEncoded(element,key,list){ | |
var list = list || []; | |
if(typeof(element)=='object'){ | |
for (var idx in element) | |
JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list); | |
} else { | |
list.push(key+'='+encodeURIComponent(element)); | |
} | |
return list.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
<?php | |
// Bob Jenkins' One-At-A-Time hashing algorithm. | |
function jenkins_hash($key) { | |
$key = (string)$key; | |
$len = strlen($key); | |
for($hash = $i = 0; $i < $len; ++$i) { | |
$hash += ord($key[$i]); | |
$hash += ($hash << 10); | |
$hash ^= ($hash >> 6); |
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
document.addEventListener('copy', function() { | |
//Get the selected text and append the extra info | |
var selection = window.getSelection(), | |
pagelink = '<br /><br /> Read more at: ' + document.location.href, | |
copytext = selection + pagelink, | |
newdiv = document.createElement('div'); | |
//hide the newly created container | |
newdiv.style.position = 'absolute'; | |
newdiv.style.left = '-99999px'; |
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 | |
// Needs PHPExcel | |
// https://phpexcel.codeplex.com/ | |
function excel_to_array($inputFileName,$row_callback=null){ | |
if (!class_exists('PHPExcel')) return false; | |
try { | |
$inputFileType = PHPExcel_IOFactory::identify($inputFileName); | |
$objReader = PHPExcel_IOFactory::createReader($inputFileType); | |
$objPHPExcel = $objReader->load($inputFileName); |
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 | |
// Access a property with no restrictions | |
function stole($object,$property){ | |
$dict = (array)$object; | |
$class = get_class($object); | |
return isset($dict[$property])? | |
$dict[$property]:(isset($dict["\0*\0$property"])? | |
$dict["\0*\0$property"]:(isset($dict["\0$class\0$property"])? | |
$dict["\0$class\0$property"]:null)); |
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
/** | |
* Photo Stack Gallery | |
*/ | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} |
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 | |
/* | |
* Use | |
* event('eventname',function(){ ... }) | |
* to add an event handler for 'eventname' event. | |
* | |
* Trigger an event with | |
* event('eventname') | |
* |
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 Chainable | |
* Wrapper for convenient chaining methods | |
* | |
* @author Stefano Azzolini <lastguest@gmail.com> | |
*/ | |
class Chainable { | |
private $instance = null; |
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 C{static function __callStatic($n,$p){static$_;return($f=&$_[$n])?$f():$f=$p[0];}} | |
C::now(function(){ | |
return new DateTime(); | |
}); | |
var_dump(C::now()); | |
/* |
NewerOlder