Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
<?php
var_dump(array_rand(array()) === null);
@clue
clue / gist:8645729
Last active January 4, 2016 16:09
redis benchmark
host:~$ redis-server --version
Redis server v=2.6.13 sha=00000000:0 malloc=jemalloc-3.3.1 bits=64
host:~$ echo "port 1338" | redis-server -
host:~$ redis-benchmark -p 1338 -q
PING_INLINE: 156250.00 requests per second
PING_BULK: 185185.19 requests per second
SET: 192307.69 requests per second
GET: 188679.25 requests per second
INCR: 192307.69 requests per second
LPUSH: 200000.00 requests per second
@clue
clue / TimeoutConnector.php
Last active April 6, 2017 12:36
TimeoutConnector skeleton
<?php
namespace React\SocketClient;
use React\SocketClient\ConnectorInterface;
use React\EventLoop\LoopInterface;
use React\Promise\Timer;
class TimeoutConnector implements ConnectorInterface
{
$retry = function ($request, $next) {
return $next($request)->then(null, function ($error) use ($request, $next) {
// the $next failed. discard $error and retry once again:
return $next($request);
});
};
$runner = new MiddlewareRunner(array(
$retry,
function ($request, $next) {
<?php
$loop = React\EventLoop\Factory::create();
$loop->addSignal(SIGINT, function () use ($loop) {
echo 'CTRL+C caught';
// cleanup...
// cleanup...
$loop->removeSignal(SIGINT);
});
@clue
clue / gist:ed235ad8d50087d098e4de5fd370b25e
Created February 26, 2018 22:47 — forked from that0n3guy/gist:9754047
laptop routeprint and ipconfig all
C:\Users\lappy>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : lappy-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
<?php
namespace React\Socket;
use Evenement\EventEmitter;
use React\EventLoop\LoopInterface;
use InvalidArgumentException;
use RuntimeException;
final class FdServer extends EventEmitter implements ServerInterface
<?php
namespace Clue\React\Foo;
use Evenement\EventEmitter;
use React\Stream\ReadableStreamInterface;
use React\Stream\WritableStreamInterface;
use React\Stream\Util;
class MagicBytesSplitter extends EventEmitter implements ReadableStreamInterface