Skip to content

Instantly share code, notes, and snippets.

@hakre
hakre / dl-file.php
Created January 2, 2012 21:41
Wordpress login to download uploaded files
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@hakre
hakre / imap-attachment.php
Created April 11, 2012 22:50
Save attachments from imap messages to disk.
<?php
/**
* imap-attachment.php
*
* @author hakre <hakre.wordpress.com>
* @link http://stackoverflow.com/questions/9974334/how-to-download-mails-attachment-to-a-specific-folder-using-imap-and-php
*/
/**
* Utility Class
@hakre
hakre / iconv-l.txt
Created December 2, 2012 12:35
Iconv List of Encodings
ANSI_X3.4-1968 ANSI_X3.4-1986 ASCII CP367 IBM367 ISO-IR-6 ISO646-US ISO_646.IRV:1991 US US-ASCII CSASCII
UTF-8
ISO-10646-UCS-2 UCS-2 CSUNICODE
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
UCS-2LE UNICODELITTLE
ISO-10646-UCS-4 UCS-4 CSUCS4
UCS-4BE
UCS-4LE
UTF-16
UTF-16BE
@hakre
hakre / RandomIterator.php
Created January 7, 2013 16:44
Random Iterator - Picking n Iterations random out of x Iterations (Reservoir sampling)
<?php
/**
* Random Iterator - Picking n Iterations random out of x Iterations (Reservoir sampling)
*
* TODO Preserve Iteration Keys
*
* @author hakre
*/
class RandomIterator implements IteratorAggregate
{
@hakre
hakre / reflection-named-parameter.php
Created December 28, 2011 06:17
Callback Decorator ReflectedCallback
<?php
/**
* Callback Decorator
*
* Providing reflection and invoking
* with named function arguments.
*
* @version 0.0.1
* @see http://stackoverflow.com/q/8649536/367456
@hakre
hakre / iteration-and-recursive-iteration.php
Created September 2, 2012 14:26
Iteration and Recursive Iteration Examples Code
<?php
/*
* Iteration and Recursive Iteration Examples Code
*
* @link http://stackoverflow.com/questions/12077177/how-does-recursiveiteratoriterator-works-in-php
* @author hakre <http://hakre.wordpress.com>
*/
### To have these examples to work, a directory with subdirectories is needed,
### I named mine "tree":
@hakre
hakre / csv-to-xml.php
Created August 16, 2015 12:13
Converting a massive CSV to a specific XML format
<?php
/*
* Converting a massive CSV to a specific XML format
*
* @link http://stackoverflow.com/a/32034227/367456
*/
/**
* Class XmlEncoder
*
@hakre
hakre / simplexml-import.php
Created February 12, 2013 11:23
In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
<?php
/**
* In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
*
* @link http://stackoverflow.com/q/767327/367456
* @link http://eval.in/9568
* @link http://3v4l.org/1sI05
*/
/**
@if (@X)==(@Y) @end /* Harmless hybrid line that begins a JScript comment
::************ Documentation ***********
::REPL.BAT version 5.0
:::
:::REPL Search Replace [Options [SourceVar]]
:::REPL /?[REGEX|REPLACE]
:::REPL /V
:::
::: Performs a global regular expression search and replace operation on
@hakre
hakre / change-admin-url.php
Created November 16, 2010 00:37
Change Admin URL
<?php
/**
* Change Admin URL
*
* Copyright (C) 2010 hakre <http://hakre.wordpress.com/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.