Skip to content

Instantly share code, notes, and snippets.

View Crell's full-sized avatar

Larry Garfield Crell

View GitHub Profile
<?php
class BigPipeResponse extends StreamedResponse {
public function __construct(Response $response) {
$this->mainResponse = $response;
$this->setStatusCode($response->statusCode());
$this->headers->set($response->headers->all());
$this->mainBody = $response->getContent();
}
@Crell
Crell / AccessedPolicy.php
Last active August 29, 2015 14:26
Expiry cache extension
<?php
class AccessedPolicy implements PolicyInterface {
public function __construct($access_count) { /*...*/ }
}
<?php
namespace Crell\IcicleTest;
use Icicle\Http\Message\RequestInterface;
use Icicle\Http\Message\Response;
class Router
function toJsonResponse(ApiProblem $problem, ResponseInterface $response)
{
$body = $response->getBody();
$body->rewind();
$body->write($problem->asJson($this->pretty));
return $this->toResponse($problem, $response)
->withHeader('Content-Type', 'application/problem+json')
->withBody($body);

Keybase proof

I hereby claim:

  • I am Crell on github.
  • I am crell (https://keybase.io/crell) on keybase.
  • I have a public key whose fingerprint is F230 376C 8EAE 38F8 B02B 879A 4FC0 2402 604A 0773

To claim this, I am signing this object:

function the_real_all(ServerRequestInterface $req, callable $next) {
$action = $req->getAttribute('_action');
$args = $req->getAttribute('_arguments);
$result = $action(...$args);
if (! $result instanceof ResponseInterface) {
$responder = resolve_responder(get_class($result));
$result = $responder($result);
}
<?php
use Aerys\Host;
use Aerys\Router;
use Kelunik\Demo\Chat;
use function Aerys\root;
use function Aerys\websocket;
// route /ws to the websocket endpoint
// you can add more routes to this router
$ php -d ffi.enable=preload -d opcache.preload="dummy-preload.php" dummy-test.php
PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'DUMMY' in /home/crell/temp/php-ffi-test/dummy.php:11
Stack trace:
#0 /home/crell/temp/php-ffi-test/dummy.php(11): FFI::scope()
#1 /home/crell/temp/php-ffi-test/dummy-test.php(7): Dummy->__construct()
#2 {main}
thrown in /home/crell/temp/php-ffi-test/dummy.php on line 11
echo "Installing Additional Plugins"
cd plugins
file="../plugins.txt"
while read -r line; do
[ "$line" = "\#*" ] && continue
git clone --depth=1 $line
done < grep -v -- "^#" "$file"
cd ..
enum Option {
case None = new class {};
case Some = new class($val) {
public function __construct(private $val) {}
public function value() { return $val; }
};
public function value{} { throw new TypeError; }
}