Skip to content

Instantly share code, notes, and snippets.

View lotharthesavior's full-sized avatar

Sávio Resende lotharthesavior

View GitHub Profile
@lotharthesavior
lotharthesavior / client.php
Created May 20, 2022 02:22
OpenSwoole Timer syncing multiple workers data
<?php
Co\run(function() {
go(function () {
var_dump(file_get_contents('http://localhost:9502/requestA'));
});
go(function () {
var_dump(file_get_contents('http://localhost:9502/requestB'));
@lotharthesavior
lotharthesavior / client.php
Last active May 25, 2022 04:32
PHP OpenSwoole Atomic forcing one worker to wait for another
<?php
Co\run(function() {
go(function() {
echo "==========================================" . PHP_EOL;
echo file_get_contents('http://localhost:8282/requestA') . PHP_EOL;
echo "==========================================" . PHP_EOL;
});
@lotharthesavior
lotharthesavior / script.php
Last active June 4, 2022 00:55
Finding the first available time for 2 users
<?php
/**
Give the data is this:
[
{
"name":"Joe",
"meetings":[
@lotharthesavior
lotharthesavior / openmetrics.php
Created June 19, 2022 13:50 — forked from johanjanssens/openmetrics.php
Openswoole - getMetrics()
<?php
/**
* Extracted from https://github.com/openswoole/swoole-src/blob/f191c0b0a98e9b97f5c81d4877f450c863e6c36d/ext-src/php_swoole_library.h#L6999
*
* Changes:
*
* - Added 'service' label
* - Added additional label support
*
@lotharthesavior
lotharthesavior / openswoole-redis-pubsub.php
Last active September 16, 2022 03:00
OpenSwoole Redis PubSub Test 1
<?php
Co::set(['hook_flags' => SWOOLE_HOOK_TCP]);
Co\run(function()
{
// refresh
$redis0 = new Redis();
$redis0->connect('127.0.0.1', 6379);
$redis0->flushDB();
<?php
// app/Http/Controllers/TutoringController.php
use App\Models\Student;
use Illuminate\Http\Request;
class TutoringController extends Controller
{
public function updateRecommendations(Student $student)