Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* XObjects - XPath based Objects for SimpleXMLElement
*
* @author hakre <http://hakre.wordpress.com/credits/>
*/
/**
* Class XListIterator
*/
@hakre
hakre / uni-hamburg-guest-wlan.sh
Created September 21, 2013 19:08
Rough script to connect to Wlan Uni-Hamburg via wpa-supplicant in shell (no Internet Browser required)
#!/bin/bash
#
# edit /etc/wpa_supplicant/wpa_supplicant.conf:
#
# network={
# ssid="GUEST"
# psk="rrz-wlan"
# }
#
echo "Connecting to WPA/WPA2 network uni-hamburg.de"
@hakre
hakre / WP_Query_Posts_Iterator.php
Last active December 22, 2015 19:39
WP_Query_Posts_Iterator - External Iterator for posts of WP_Query
<?php
/**
* Class WP_Query_Posts_Iterator
*
* External Iterator for posts of WP_Query.
*/
class WP_Query_Posts_Iterator implements iterator {
/**
* @var WP_Query
*/
@hakre
hakre / advanced-interface-example.php
Created July 29, 2013 10:14
Advanced PHP Interface Example: Traversable and Countable extended
<?php
/**
* Advanced PHP Interface Example: Traversable and Countable extended
*
* As Traversable is an internal interface but PHP interfaces allow to extend
* from multiple interfaces, it is possible to create your own internal
* type (here based on Traversable) and base another non-internal sub-type
* on it (here based on IteratorAggregate).
*
* @link http://wpkrauts.com/2013/how-to-build-flexible-php-interfaces/
@hakre
hakre / PlistXMLParser.php
Created July 5, 2013 09:08
Base Class for a Plist XML Parser
<?php
/**
* Class PlistXMLParser
*/
class PlistXMLParser
{
const NODE_STRING = 'string';
const NODE_INTEGER = 'integer';
const NODE_DATE = 'date'; # NOTE: not implemented
const NODE_TRUE = 'true'; # NOTE: not implemented
<?php
if (!function_exists('http_build_url'))
{
define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
@hakre
hakre / 34657.php
Created June 23, 2013 17:47
Extending DOMElement; Keep PHP Objects in Memory - http://stackoverflow.com/a/17262180/367456
<?php
/**
* Extending DOMElement
*
* @linnk http://stackoverflow.com/q/17260190/367456
*/
/**
* Class ElementFactory
*
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.webserviceX.NET/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">
<s:element name="GetQuote">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string" />
</s:sequence>
</s:complexType>
<?php
/**
* PHP XML to dynamic table
*
* @link http://stackoverflow.com/q/16997835/367456
*/
require('.../Iterator-Garden/src/autoload.php'); // for DecoratingIterator - use development branch