Skip to content

Instantly share code, notes, and snippets.

View ivastly's full-sized avatar
💭
making the world a better place for someone else

Vasily Pyatykh ivastly

💭
making the world a better place for someone else
View GitHub Profile
@ivastly
ivastly / php-reflection-library-example.php
Created February 14, 2021 15:40
Usage of php-reflection library - reading private property of an object in PHP.
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
class ParentClass
{
private $property = 'parent private property';
}
@ivastly
ivastly / run_xhprof_viewer.sh
Last active November 23, 2020 17:13
Run Dockerized XHProf Viewer oneliner
# dumps must be in ./xhprof folder, named like uniqid() . 'appname.xhprof';
# use tideways_xhprof extension to generate them https://github.com/tideways/php-xhprof-extension
docker run --rm -p 81:8080 -v $(pwd)/xhprof:/mnt/files/private/xhprof -d --name xhprof wodby/xhprof
@ivastly
ivastly / ArduinoSignals.ino
Created August 30, 2020 14:42
Paper Signals Arrow Robot Custom behavior
void loop() {
SetActionLEDOn();
if (WiFi.status() == WL_CONNECTED) {
String response = mySignal.getJsonHTTP(ApiHost, "/check_this_minute_hotline.php");
Serial.println(response);
phantom:
address: "1.2.3.4:80" # [Target's address]:[target's port]
ssl: false
header_http: "1.1"
headers:
- "[Host: example.com]"
- "[Connection: close]"
uris:
- "/"
- "/reviews"
<?php declare(strict_types=1);
/**
* @Revs(10000)
* @Iterations(3)
* @Warmup(1)
* @BeforeMethods({"init"})
*/
class LoopConditionalBench
{
@ivastly
ivastly / MethodCallBench.php
Last active January 8, 2020 00:03
benchmark for an empty method call in PHP
<?php declare(strict_types=1);
/**
* @Revs(1000000)
* @Iterations(1000)
* @Warmup(10)
* @BeforeMethods("init")
* @OutputTimeUnit("microseconds", precision=1)
*/
class MethodCallBench
<?php
$bank->withdrawMoney(1000, 'Docler Holding');
$bank->sendMoney(200, 'John');
$bank->sendMoney(200, 'Developer');
$bank->sendMoney(600, 'Miranda');
@ivastly
ivastly / Bank.php
Last active December 11, 2019 19:19
<?php
namespace Ivastly\GoAopHelloWorld\BankingSystem;
use League\CLImate\CLImate;
class Bank
{
/** @var CLImate */
private $climate;
@ivastly
ivastly / index.php
Created December 11, 2019 18:59
initialize AOP
<?php
use Ivastly\GoAopHelloWorld\Aop\ApplicationAspectKernel;
require_once 'vendor/autoload.php';
$applicationAspectKernel = ApplicationAspectKernel::getInstance();
$applicationAspectKernel->init(
[
'appDir' => __DIR__ . '/..',
@ivastly
ivastly / ApplicationAspectKernel.php
Last active December 11, 2019 18:56
ApplicationAspectKernel example
<?php
namespace Ivastly\GoAopHelloWorld\Aop;
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
class ApplicationAspectKernel extends AspectKernel
{
protected function configureAop(AspectContainer $container)