Skip to content

Instantly share code, notes, and snippets.

Dave Hulbert dave1010

Block or report user

Report or block dave1010

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HHVM Constructor arg promotion
$ cat hh.php
<?hh class Foo { public function __construct(private int $num) : void { } }
$ hhvm --version
HipHop VM 2.4.0 (rel)
Compiler: tags/HHVM-2.4.0-0-gc82fcd8e6199c500454b1a8b930a876ef2c1522b
Repo schema: a536a1d1567b1fb5d722c0349a3296d4e8589f96
$ hhvm hh.php
HipHop Fatal error: Parameters modifiers not allowed on methods in /home/base/hh.php on line 1
@dave1010
dave1010 / wp-db.php
Created Feb 27, 2014
wp-db.php.diff
View wp-db.php
<?php
// workaround for HHVM not supporting case-insensitive constants
// http://www.hhvm.com/blog/113/getting-wordpress-running-on-hhvm
if (! defined( 'HHVM_VERSION' )) {
define( 'OBJECT', 'OBJECT', true );
} else {
define('OBJECT', 'OBJECT');
define('Object', 'OBJECT');
@dave1010
dave1010 / hhvm-usort.php
Created Feb 28, 2014
HHVM and PHP usort difference
View hhvm-usort.php
<?php
class T {
public function __construct($v)
{
$this->v = $v;
}
public function __toString()
{
return 'a';
View post-expirator.php.patch
diff --git a/wp-content/plugins/post-expirator/post-expirator.php b/wp-content/plugins/post-expirator/post-expirator.php
index d9536ff..2d2dc4c 100644
--- a/wp-content/plugins/post-expirator/post-expirator.php
+++ b/wp-content/plugins/post-expirator/post-expirator.php
@@ -1264,17 +1264,17 @@ class Walker_PostExpirator_Category_Checklist extends Walker {
$this->disabled = 'disabled="disabled"';
}
- function start_lvl(&$output, $depth, $args) {
+ function start_lvl(&$output, $depth = 0, $args = array()) {
View magic-class-alias.php
<?php
class Magic {public function __call($metod, $args=null){return $this;}}
spl_autoload_register(function($c) {
eval("class $c extends Magic {};");
});
(new Foo)->bar()->baz();
@dave1010
dave1010 / app-routes.php
Last active Aug 29, 2015
laravel hhvm double closure bug
View app-routes.php
<?php
Route::group(['prefix' => 'api/v1'], function() {
Route::group(['prefix' => 'lines'], function(){});
});
View ssltest.py
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@dave1010
dave1010 / monolog-setup.php
Created Apr 22, 2014
Monolog setup for FingersCrossedHandler, RotatingFileHandler, NativeMailerHandler & BufferHandler
View monolog-setup.php
<?php
$logger = new Logger('my logger');
// log DEBUG messages to file when there's at least a NOTICE
$fileHandler = new RotatingFileHandler(ABSPATH . '../logs/log.log', 0, Logger::DEBUG, true, 0777);
$fingersCrossedHandler = new FingersCrossedHandler($fileHandler, Logger::NOTICE, 1000);
$logger->pushHandler($fingersCrossedHandler);
@dave1010
dave1010 / monolog-setup.php
Created Apr 22, 2014
Make sure a Monolog logger can log
View monolog-setup.php
<?php
$handler = new RotatingFileHandler(ABSPATH . '../logs/log.log', 0, Logger::DEBUG, true, 0777);
try {
$record = array(
'message' => (string) "Write test",
'context' => null,
'level' => Logger::DEBUG,
'level_name' => 'DEBUG',
@dave1010
dave1010 / variadics.php
Created Apr 29, 2014
Type hinting in PHP variadics
View variadics.php
<?php
class Bar{}
$bars = [new Bar, new Bar, new Bar];
$ints = [1, 2, 3];
// without variadics
// lots of manual type checking
function oldFoo($bars)
{
You can’t perform that action at this time.