Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Zend\Stdlib\Hydrator;
use DOMNode;
use DOMElement;
use DOMXPath;
use Zend\Stdlib\Exception;
use Zend\Stdlib\Hydrator as ZendHydrator;
class DOM extends ZendHydrator\AbstractHydrator implements ZendHydrator\HydratorOptionsInterface {
protected function transmuteTags(DOMNode $contextNode = null)
{
$xpath = new DOMXPath($this);
$tagList = $this->getTagList();
if(!$contextNode) {
$contextNode = $this->documentElement;
}
if($contextNode->hasChildNodes()) {
@TheFrozenFire
TheFrozenFire / codeformatting.css
Last active December 22, 2015 13:19
/r/PHP subreddit styling
/* Code Formatting */
/*------------------------------|
| |
| Line numbered code blocks |
| |
|------------------------------*/
.md pre {
background: url(%%codebackground3%%) top left repeat;
border: 1px solid #99C;
border-left: 31px solid #99C;
try {
if( !process_x() )
throw new Exception;
/* do a lot of other things */
if( !process_y() )
throw new Exception;
var http = require('http');
exports.hooks_queue = function(next, connection) {
var config = this.config.get('http_forward.ini');
var request = http.request(config.receiver, function(response) {
if(response.statusCode == 200) {
next(OK, 'Message delivered to receiver');
} else {
next(DENY, 'Message rejected by receiver: ' + http.STATUS_CODES[response.statusCode]);
}
0
0000: 3,170,640 B
1
0001: 3,399,976 B
2
0002: 3,629,320 B
3
0003: 3,858,696 B
4
0004: 4,087,984 B
@TheFrozenFire
TheFrozenFire / test 1.php
Created December 11, 2013 01:39
Array union experiment
<?php
$b = rand(0, 1);
$c = rand(0, 1);
for($i = 0; $i < 1000000; $i++) {
$a = ['foo' => 1];
if($b) {
$a['bar'] = 2;
}
<?php
class RetryManager
{
protected $callback;
protected $retries = 0;
protected $caughtExceptions = array();
public function execute()
@TheFrozenFire
TheFrozenFire / gist:9b174f23f9f9549d2406
Created May 22, 2014 20:32
Rackspace ARIN IP block allocations
173.45.224.0/19
64.39.0.0/19
209.61.128.0/18
64.49.192.0/18
66.216.64.0/18
162.209.0.0/17
65.61.128.0/18
69.20.0.0/17
162.242.128.0/17
207.97.192.0/18
<?php
namespace Ajp;
class ForwardRequestTest extends PacketTest
{
protected static $packetType = '\Ajp\Packet\ForwardRequest';
protected static $serialized = "\x41\x42\x00\x01\x02...";
public function provideSerializablePacket()
{