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 / bug.php
Created April 28, 2017 15:52
github bug example
abstract class JMPRouter implements RouterInterface
{
const HTTP_METHOD_DELETE3 = 'DELETE2';
const HTTP_METHOD2_DELETE = 'DELETEE';
const HTTP_METHOD_GET = 'GET';
const HTTP_METHOD_PUT = 'PUT';
const HTTP_METHOD_POST = 'POST';
const HTTP_METHOD_DELETE = ' DELETE';
const HTTP_METHOD_PATCH = 'PATCH';
@ivastly
ivastly / developer-tools-script.js
Created February 21, 2018 13:02
Script to spy for Whatsapp online status of your contacts even it is turned off in settings!
// just open web.whatsapp.com, navigate to the chat with victim and run this in developer tools. Once he/she becomes online,
// you will be notified in console NOTE if the language of your whatsapp interface is not english, change the 'online' string on line 6 accordingly
setInterval(function () {
if ($('span[title="online"]') !== null) {
console.info("ONLINE: " + (new Date()));
}
}, 20000);
@ivastly
ivastly / app.php
Last active December 10, 2019 00:08
Typical PHP application
<?php
public function createNewUser($newUsername)
{
$start = time();
if (!$this->isGranted('ROLE_ADMIN'))
{
throw new AccessDeniedException();
}
@ivastly
ivastly / app.php
Created December 10, 2019 00:35
Crosscutting conserns
<?php
public function createNewUser($newUsername)
{
$start = time(); // load time calculation
if (!$this->isGranted('ROLE_ADMIN')) // access control
{ // access control
throw new AccessDeniedException(); // access control
} // access control
@ivastly
ivastly / BankingAspect.php
Last active December 11, 2019 18:57
hello-world aspect
<?php
namespace Ivastly\GoAopHelloWorld\Aop;
use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Before;
class BankingAspect implements Aspect
{
@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)
@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 / Bank.php
Last active December 11, 2019 19:19
<?php
namespace Ivastly\GoAopHelloWorld\BankingSystem;
use League\CLImate\CLImate;
class Bank
{
/** @var CLImate */
private $climate;
<?php
$bank->withdrawMoney(1000, 'Docler Holding');
$bank->sendMoney(200, 'John');
$bank->sendMoney(200, 'Developer');
$bank->sendMoney(600, 'Miranda');
@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