Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
@clue
clue / 2019-07-11 announcing-reactphp-lts.md
Last active September 22, 2019 20:05
Announcing full stable ReactPHP LTS release
<?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
@clue
clue / 2019-08-28 introducing-reactphp-stdio.md
Last active September 22, 2019 20:04
Introducing event-driven console I/O with ReactPHP
@clue
clue / gist:86c3cbdc10ecf49d444f61768034856a
Created February 17, 2020 09:50 — forked from davor010/gist:41ddf289c4155bce8daa8960d4cf885b
using transformer in between (mysql, clickhouse)
$promise = new React\Promise\FulfilledPromise(1);
$transformer = new ThroughStream(function ($data) {
return array('id' => $data['id'], 'stocknummer' => $data['id'], 'dealer_id' => $data['id'], '_vnr' => 1, '_checksum' => sha1(json_encode($data)), '_timestamp' => date('Y-m-d h:i:s'));
});
//try to change in Client class add _vnr, _checksum and _timestamp
$source->pipe($transformer)->pipe($stream);
//$source->pipe($stream);
function main(): PromiseInterface {
return $this->query(1);
}
function query(page): PromiseInterface {
return $this
->makeAQuery(page)
->then($result) {
@clue
clue / test.php
Last active May 7, 2021 12:39 — forked from carliedu/test.php
Get the result of file exist/no exits
<?php
use app\clFilesystem;
use React\MySQL\Factory;
require __DIR__ . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$file = "teste.txt";
@clue
clue / coroutines.md
Last active November 14, 2021 13:49
Generator-based coroutines returning Generator vs wrapping in Promises using coroutine helper in Framework X
AcmeDemo
├── src/
│   ├── Book.php
│   ├── BookRepository.php
│   └── BookLookupController.php
├── vendor/
├── app.php
├── composer.json
@clue
clue / fibers.md
Created June 9, 2021 17:42
Fibers make async APIs look like sync APIs – because this example is in fact synchronous from a caller's perspective (fetch, wait, transform, return)
AcmeDemo
├── src/
│   ├── Book.php
│   ├── BookRepository.php
│   └── BookLookupController.php
├── vendor/
├── app.php
├── composer.json
@clue
clue / promises.md
Last active October 20, 2021 13:39
Promise-based async APIs in Framework X
AcmeDemo
├── src/
│   ├── Book.php
│   ├── BookRepository.php
│   └── BookLookupController.php
├── vendor/
├── app.php
├── composer.json
└── composer.lock