Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
@clue
clue / 2018-04-13 getting-started-with-reactphp-workshop-phpyorkshire.md
Last active December 16, 2023 12:33
Getting started with ReactPHP – Pushing real-time data to the browser (PHPYorkshire)

Think about "PHP" for a few seconds… What came to mind? It’s very likely you thought about your average product catalog, a blogging platform or how the platform is inferior to things like Node.js. But wait, it’s 2018! What if I told you PHP’s huge ecosystem has way more to offer and PHP is not inferior at all to its evil cousin Node.js?

Hands-on workshop given at PHPYorkshire (2018-04-13)

Getting started with ReactPHP – Pushing real-time data to the browser

In this hands-on tutorial you will learn about the core concepts of async PHP and why you too should care about ReactPHP being a real thing. The workshop has a strong focus on sparking the idea that PHP can be way faster and more versatile than you probably thought. Bring along an open mind and through lots of interesting examples and live demos learn why what sounds crazy at first might soon be a valuable addition in your toolbox.

You’re already familiar with PHP and want to learn what ReactPHP is all about? Then this tutorial is for you! We will

query {
organization(login: "reactphp") {
repositories(ownerAffiliations: OWNER, privacy: PUBLIC, first: 100) {
nodes {
nameWithOwner
defaultBranchRef {
name
}
refs(refPrefix: "refs/heads/", first: 10) {
nodes {
@clue
clue / 2018-07-12 non-blocking-io-for-the-masses-webengdus.md
Last active February 10, 2022 11:17
Non-blocking I/O for the masses (WebEngDUS)

I/O is everywhere. I/O is slow. There's no denying it. Using traditional blocking I/O calls can thus be seen as a huge contributor to slow applications. This talk discusses how non-blocking I/O can help in building high performance, event-driven, reactive, concurrent, single-threaded applications (bingo). Don't worry, no need to install Node.js and npm install half the internet. Let's build high-performance applications from scratch with whatever language you're most comfortable with!

20 minutes talk at @WebEngDUS (2018-07-12)

Slides

The slides are available on https://speakerdeck.com/clue/non-blocking-io-for-the-masses-webengdus.

These slides were used as part of a presentation at @WebEngDUS. The full presentation took around 20 minutes including live demonstration and a short Q/A followed by some very nice discussions.

@clue
clue / hello.sql
Last active January 26, 2022 10:34
SELECT
users.name,
groups.name AS `group`
FROM
URL('https://gist.github.com/clue/dde9700e9be30db2abd3c763833aa631/raw/962e5d6a337a9bf14e1816f548ea996358c235f8/users.json') AS users,
URL('https://gist.github.com/clue/dde9700e9be30db2abd3c763833aa631/raw/962e5d6a337a9bf14e1816f548ea996358c235f8/groups.json') AS groups
WHERE users.`group` = groups.id
ORDER BY `group` DESC
@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 / 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
@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 / 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";
function main(): PromiseInterface {
return $this->query(1);
}
function query(page): PromiseInterface {
return $this
->makeAQuery(page)
->then($result) {
@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);