Skip to content

Instantly share code, notes, and snippets.

@hakre
hakre / CurlDebug.php
Created November 2, 2014 16:14
curl debug drop-in class
<?php
/**
* Class CurlDebug
*
* drop-in class to add verbose information to curl requests and to display trouble-shooting information
*
* @author hakre <http://hakre.wordpress.com/>
* @link http://stackoverflow.com/a/14436877/367456
*/
class CurlDebug
@hakre
hakre / decode-input-stream-example.php
Last active August 29, 2015 14:04
Example: Decode an Input Stream with PHP filters
<?php
/**
* Example: Decode an Input Stream with PHP filters
*
* decode-input-stream-example.php
*
* @link https://gist.github.com/hakre/d34239bb237c50e728fd
* @link http://stackoverflow.com/q/25051578/367456
*/
@hakre
hakre / StreamNotifyPrinter.php
Last active March 4, 2022 17:23
StreamNotifyPrinter - Print out PHP Stream Notifications to target channel (default: STDERR).
<?php
/**
* StreamNotifyPrinter
*
* @author hakre <http://hakre.wordpress.com>
* @version 0.0.2
* @example http://stackoverflow.com/a/24711469/367456
* @link https://gist.github.com/hakre/8ba2c0d49b7baf062acd
*/
@hakre
hakre / HiddenFilesAndFolderFilterIterator.php
Created April 20, 2014 11:18
Filter recursive directory traversal and file listing in PHP with RecursiveDirectoryIterator
<?php
/**
* Class HiddenFilesAndFolderFilterIterator
*
* Under *Nix hidden files and directories start with a dot ("."). This RFI does not traverse
* hidden directories and filters hidden files from RecursiveDirectoryIterator listing.
*/
class HiddenFilesAndFolderFilterIterator extends RecursiveFilterIterator
{
@hakre
hakre / spl_autoload_register_psr0.php
Created December 26, 2013 17:36
spl_autoload_register() just with added PSR-0 support
<?php
/**
* spl_autoload_register() just with added PSR-0 support
*
* The support is added, that means, for each classname first of all
* by the priority given in the include-path directive, a per-directory
* test is done for the full-classname based file and then sub-directories
* are traversed.
*
* PHP 5.3 Namespace Separators are always mapped to a directory to
@hakre
hakre / RecursiveSimpleXMLIterator.php
Created October 31, 2013 14:19
RecursiveSimpleXMLIterator
<?php
/**
* Class RecursiveSimpleXMLIterator
*
* RecursiveIterator for SimpleXMLElement
*/
class RecursiveSimpleXMLIterator extends IteratorIterator implements RecursiveIterator
{
function __construct(SimpleXMLElement $xml) {
parent::__construct($xml);
@hakre
hakre / duri.php
Created September 30, 2013 09:50
duri - data:// URI based, non-javascript anonymous redirect script
<?php
/**
* duri - data:// URI based, non-javascript anonymous redirect script
*
* Redirects tested to ...
* ... work with:
* - Firefox (23.0.1)
* - Chrome (29.0.1547.76 m)
* - Google URL shortener <http://goo.gl/>
* ... not work with: