Skip to content

Instantly share code, notes, and snippets.

hakre hakre

View GitHub Profile
@hakre
hakre / HiddenFilesAndFolderFilterIterator.php
Created Apr 20, 2014
Filter recursive directory traversal and file listing in PHP with RecursiveDirectoryIterator
View HiddenFilesAndFolderFilterIterator.php
<?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 / decode-input-stream-example.php
Last active Aug 29, 2015
Example: Decode an Input Stream with PHP filters
View decode-input-stream-example.php
<?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 / CurlDebug.php
Created Nov 2, 2014
curl debug drop-in class
View CurlDebug.php
<?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 / domblaze2.php
Created Jul 14, 2015
DOMBLAZE II XMLNS
View domblaze2.php
<?php
/**
* DOMBLAZE II is just with XMLNS support
*
* @link http://stackoverflow.com/a/26327033/367456
*/
/* DOMBLAZE II XMLNS */ $doc->registerNodeClass("DOMElement", "DOMBLAZE");
class DOMBLAZE extends DOMElement
View 3v4l.org_fttGI.php
<?php
/**
* Example: SimpleXML tell apart a single element and a list of elements with a single element
*
* @link https://hakre.wordpress.com/2013/02/12/simplexml-type-cheatsheet/
* @libk http://stackoverflow.com/a/14829309/367456
*/
$buffer = <<<XML
<root>
View special-background.php
<?php
/**
* Special Background Wordpress Plugin
*
* @-wp-header Plugin Name: Special Background
* @-wp-header Plugin URI: http://wordpress.stackexchange.com/questions/972/
* @-wp-header Description: Example to show how to add a special background using exiting background admin page in core.
* @-wp-header Version: 0.2
* @-wp-header Author: Mike Schinkel, hakre
* @-wp-header Author URI: http://mikeschinkel.com/custom-wordpress-plugins/
View admin_page_demo.php
<?php
/**
* Register an Admin Page - Example
*
* NOTE: MU Plugin.
*
* @author hakre <http://hakre.wordpress.com/>
* @link http://wordpress.stackexchange.com/questions/1778/admin-config-screen-without-menu
*/
View is_serialized.php
<?php
/**
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
/**
You can’t perform that action at this time.