Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
@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);
@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
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
<?php
$loop = React\EventLoop\Factory::create();
$logger = new \Zend\Log\Logger();
$writer = new \Zend\Log\Writer\Syslog(array('application' => 'movim'));
$logger->addWriter($writer);
$connector = new Ratchet\Client\Factory($loop);
$buffer = '';
$conn->on('data', function($data, $conn) use (&$buffer) {
$buffer .= $data;
// check to see if the buffer contains any line feeds (detect end of line)
while (false !== ($pos = strpos($buffer, PHP_EOL))) {
// get the first line from the buffer (up to the EOL)
$line = substr($buffer, 0, $pos);
// remove the line from the buffer (advance behind the EOL)