Skip to content

Instantly share code, notes, and snippets.

View borislav-angelov's full-sized avatar

Borislav Angelov borislav-angelov

View GitHub Profile
<?php
class AWSV4 {
private $accessKeyID = null;
private $secretAccessKey = null;
private $regionName = null;
private $serviceName = null;
private $httpMethodName = null;
private $canonicalURI = "/";
@borislav-angelov
borislav-angelov / wp_http_debug.php
Last active August 29, 2015 14:18
WP HTTP Debug
<?php
add_action( 'http_api_debug', 'viper_http_api_debug', 10, 5 );
public function viper_http_api_debug( $response, $type, $class, $args, $url ) {
$output = 'Request URL: ' . var_export( $url, true );
$output .= 'Request Args: ' . var_export( $args, true );
$output .= 'Request Response : ' . var_export( $response, true );
echo $output;
<?php
$dir = "C:\\";
$start = microtime(true);
function recursive_readdir($dir) {
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
if ($filename != '.' && $filename != '..') {
if (is_dir($dir . $filename)) {
<?php
$dir = "C:\\temp\\";
$start = microtime(true);
function recursive_readdir($dir) {
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
if ($filename != '.' && $filename != '..') {
<?php
$i = 0;
while (true) {
echo $i . " abc \n";
time_sleep_until( time() + 10);
$i++;
}
<?php
<?php
abstract class Ai1ec_Event_Callback_Abstract {
protected $_registry = null;
protected $_registry_name = null;
protected $_method = null;
public function __construct(
<?php
class Ai1ec_Event_Dispatcher {
public function register(
$hook,
Ai1ec_Event_Callback_Abstract $entity,
$priority = 10,
$accepted_args = 1
) {
class Ai1ec_Event_Dispatcher {
public function register(
$hook,
Ai1ec_Event_Callback_Abstract $entity,
$priority = 10,
$accepted_args = 1
) {
if ($entity instanceof Ai1ec_Event_Callback_Filter) {
<?php
$dispatcher = new Ai1ec_Event_Dispatcher();
$callback_filter = new Ai1ec_Event_Callback_Filter( $this->_registry, 'model.settings', 'modify2' );
$dispatcher->register( 'title', $callback_filter, 19, 2 );
$callback_filter2 = new Ai1ec_Event_Callback_Filter( $this->_registry, 'model.settings', 'modify' );
$dispatcher->register( 'title', $callback_filter2, 17, 2 );
<?php
$callback = new Ai1ec_Core_Callback( $this->_registry, 'model.settings', 'test' );
$dispatcher = new Ai1ec_Core_Dispatcher();
$dispatcher->register('my-custom-action', $callback, 10, 2);
do_action('my-custom-action', 100, 200);