Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
<?php
/*
* Dump XML (DOMNode) as Tree.
*
* @link http://stackoverflow.com/q/684227/367456
*/
abstract class IteratorDecoratorStub implements OuterIterator
{
private $iterator;
@xeoncross
xeoncross / whois.php
Created June 5, 2012 17:24 — forked from agarzon/whois.php
WHOIS with PHP including .ve domains
<?php
function whois($domain) {
// fix the domain name:
$domain = strtolower(trim($domain));
$domain = preg_replace('/^http:\/\//i', '', $domain);
$domain = preg_replace('/^https:\/\//i', '', $domain);
$domain = preg_replace('/^www\./i', '', $domain);
$domain = explode('/', $domain);
$domain = trim($domain[0]);
@xeoncross
xeoncross / example.php
Created June 25, 2012 19:40 — forked from anothergituser/ioc.php
PHP 5.3 Lightweight IOC container
<?php
require_once 'ioc.php';
class Material {
private $materialName = null;
public function __construct() {
}
<?php
/**
* Database Base Model class
*/
class Model {
// Hold raw properties for save() which take precedence over regular properties
// used in combination with set_raw() as in set_raw('somefield', 'CURDATE()')
// Will allow you to pass in raw SQL, so use with caution
@xeoncross
xeoncross / quicksilver_score.php
Created July 16, 2012 18:38 — forked from dwoodard/quicksilver_score.php
Quicksilver string ranking algorithm in PHP
<?
// Quicksilver Score
//
// A port of the Quicksilver string ranking algorithm
// (re-ported from Javascript to PHP by Kenzie Campbell)
// http://route19.com/logbook/view/quicksilver-score-in-php
//
// score("hello world","axl") //=> 0.0
// score("hello world","ow") //=> 0.6
@xeoncross
xeoncross / github-oauth.php
Created July 25, 2012 18:40 — forked from indeyets/php-github.php
GitHub OAuth + API test
<?php
/**
* Github v3 API and OAuth classes
*/
class GitHubAuth
{
const AUTH_URL = 'https://github.com/login/oauth/authorize';
const ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token';
private $app_id;
@xeoncross
xeoncross / gist:3207688
Created July 30, 2012 15:17 — forked from blar/gist:3201381
RecursiveDOMIterator
<?php
class RecursiveDOMIterator extends RecursiveArrayIterator {
public function __construct($node) {
parent::__construct(iterator_to_array($node->childNodes));
}
public function getChildren() {
return new self($this->current());
}
public function hasChildren() {
@xeoncross
xeoncross / class.googlevoice.php
Created August 2, 2012 16:00 — forked from Bren2010/class.googlevoice.php
An IRC bot that texts you. God help us.
<?PHP
/*
Version 0.2
License This code is released under the MIT Open Source License. Feel free to do whatever you want with it.
Author lostleon@gmail.com, http://www.lostleon.com/
LastUpdate 05/28/2010
*/
class GoogleVoice
{
public $username;
@xeoncross
xeoncross / parss_rss.php
Created August 7, 2012 03:01 — forked from longkey1/parss_rss.php
Parse rss or atom feeds
<?php
function parseRss($feedUrl) {
$result = array();
// "@" is for error handling
$feed = @simplexml_load_file($feedUrl);
//atom
if (isset($feed->entry)) {
$result['title'] = (string)$feed->title;
$result['link'] = (string)$feed->link->attributes()->href;
@xeoncross
xeoncross / twitterexport.php
Created August 9, 2012 19:10 — forked from rutger1140/twitterexport.php
Export all your tweets
<?php
/**
* This script will allow the export of complete user time-lines from the twitter
* service. It joins together all pages of status updates into one large XML block
* that can then be reformatted/processed with other tools.
*
* @since 10/13/08
*
* @copyright Copyright © 2008, Adam Franco
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)