Skip to content

Instantly share code, notes, and snippets.

View WyriHaximus's full-sized avatar
🐉
Breathing Fire

Cees-Jan Kiewiet WyriHaximus

🐉
Breathing Fire
View GitHub Profile
@WyriHaximus
WyriHaximus / bot.php
Created March 12, 2018 17:17
botman with react/http
<?php
$time = time();
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\Drivers\Web\WebDriver;
use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Factory;
use React\Http\Response;
<?php
$all = await(all([
'site' => $buzz->get('https://www.wyrihaximus.net'),
'blog' => $buzz->get('https://blog.wyrihaximus.net'),
]), Factory::create());
<?php
use ApiClients\Client\Supervisord\AsyncClientInterface;
use ApiClients\Client\Supervisord\Resource\Async\Program;
use ApiClients\Client\Supervisord\Resource\ProgramInterface;
use Psr\Log\LoggerInterface;
use React\EventLoop\LoopInterface;
use Rx\React\Promise;
Promise::fromObservable(
if (!isset($uploadedFile) && $bodyLength > ini_get('upload_max_filesize')) {
$uploadedFile = new UploadedFile(
Psr7\stream_for(''),
0,
UPLOAD_ERR_INI_SIZE,
$this->getFieldFromHeader($headers['content-disposition'], 'filename'),
$headers['content-type'][0]
);
}
<?php declare(strict_types=1);
namespace WyriMaps\XHeaders;
final class Faction
{
public static function headers(): array
{
return [];
}
<?php
use function Clue\React\Block\await;
use React\EventLoop\Factory;
use React\Promise\Deferred;
use function React\Promise\Stream\buffer;
use React\Stream\ThroughStream;
use WyriHaximus\React\Stream\Base64\WritableStreamBase64Encode;
use WyriHaximus\React\Stream\Hash\WritableStreamHash;
<?php
$consoleHandler = new FormattedPsrHandler(StdioLogger::create($loop)->withHideLevel(true));
$consoleHandler->setFormatter(new ColoredLineFormatter(
null,
"[%datetime%] %channel%.%level_name%: %message%",
null,
false,
false
));
<?php declare(strict_types=1);
Promise::fromObservable(unwrapObservableFromPromise($this->github->user($user)->then(function (GithubUser $user) use ($repo) {
return $user->repository($repo);
})->then(function (GithubRepository $repository) {
return resolve($repository->contents());
}))->filter(function ($resource) {
return $resource instanceof FileInterface;
})->filter(function (FileInterface $file) {
return $file->name() === '.travis.yml';
{
"abandoned": [
"1.0.0",
"1.0.1"
]
}