Skip to content

Instantly share code, notes, and snippets.

<?php
$hot_mess =
array(
5 => 5,
3 => array(
12,
12 => array(
'name' => 1
),
32 => array(
<?php
$hot_mess =
array(
5 => 5,
3 => array(
12,
12 => array(
'name' => 1
),
32 => array(
<?php
function get($base, $offset, $default = NULL) {
return (create_function('$base,$default', 'return isset($base' . $offset . ') ? $base' . $offset . ' : $default;'))($base, $default);
}
<?php
/**
* Placeholder data type.
*/
class _ {}
/**
* Implements partial application.
*
# CONKY
# A comprehensive conky script, configured for use on
# Ubuntu / Debian Gnome, without the need for any external scripts.
#
# Based on conky-jc and the default .conkyrc.
# INCLUDES:
# – tail of /var/log/messages
# – netstat connections to your computer
#
# — Pengo ([email protected])
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$request = microtime(TRUE);
function get($base, $offset, $default = NULL) {
$func = create_function('$base, $default', 'return isset($base' . $offset . ') ? $base' . $offset . ' : $default;');
return $func($base, $default);
}
$get_results = array();
for($i = 0 ;$i<100000;$i++) {
<?php
class _ {}
function get($data, array $offsets, $default, $lens = 'prop') {
$results = call_user_func(call_user_func_array('pipe', array_map(function($offset) use($lens){
return partial($lens, (new _), $offset);
},$offsets)), $data);
return is_a($results, '_') ? $default : $results;
}
function partial(callable $fn, ...$start) {
return function (...$args) use ($fn, $start) {
<?php
class _ {}
function compose(callable $fn, ...$start) {
return pipe($fn, ...array_reverse($start));
}
function filter(callable $fn, $data) {
return array_filter((array)$data, function ($v, $k) use ($fn, $data) {
return $fn($v, $k, $data);
}, ARRAY_FILTER_USE_BOTH);
}
<?php
/**
* Data type to signify a placeholder.
*/
class PlaceHolder {}
class_alias('PlaceHolder', '_');
/**
* Recursive array filter.
*
<?php
/**
* Data type to signify a placeholder.
*/
class PlaceHolder {}
class_alias('PlaceHolder', '_');
/**
* Recursive array filter.
*