Skip to content

Instantly share code, notes, and snippets.

View mkusher's full-sized avatar
🥃
Ballmer's peak searching

Aleh Kashnikaў mkusher

🥃
Ballmer's peak searching
View GitHub Profile
<?php
namespace EC\Domain;
class Good
{
private $type;
private $price;
private $name;
private $sizes;
<?php
interface EventEmitter
{
public function emit(Event $e);
public function on(Event $e, callable $callback);
}
<?php
interface Chef
{
public function cook();
}
class TrueItalianChef implements Chef
{
public function cook()
<?php
interface Logger
{
public function log(string $message, int $level = 0): void;
}
@mkusher
mkusher / handler-class.ts
Last active December 28, 2016 10:50
Handler example
export class SomeHandler {
constructor(private http: Http) { }
@afterEvery(SomeCommand)
async handleSomeCommand(action: SomeCommand, dispatch: Dispatch) {
const withData = await this.http.get("/");
dispatch(someEventHappened(withData));
}
}
@mkusher
mkusher / cucumber.ts
Last active December 20, 2016 11:33
TypeScript typings example for cucumber
import { World } from "support/World";
export namespace cucumber {
type Step = RegExp|string;
interface StepCallback extends Function {
(this: World, ...args: any[]): void|Promise<any>;
}
export interface Feature {
Given(step: Step, callback: StepCallback): void;
When(step: Step, callback: StepCallback): void;
declare module "react-redux" {
export type Connect<State> = {
<P>(
mapStateToProps?: MapStateToPropsWithKnownState<State>,
mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject,
mergeProps?: MergeProps,
options?: Options
): ComponentConstructDecorator<P>;
}
interface MapStateToPropsWithKnownState<State> {
@mkusher
mkusher / return-true.php
Last active August 29, 2016 15:54
Return true to win
<?php
namespace ReturnTrue;
// inspired by http://alf.nu/ReturnTrue
function transitive($a, $b, $c) {
return $a == $b && $a == $c && $b != $c;
}
function peano($a) {
return $a++ !== $a && $a++ === $a;
@mkusher
mkusher / spec.php
Last active September 15, 2016 10:31
<?php
use Mkusher\Co;
use React\EventLoop\Factory;
use React\Promise;
use Webmozart\Assert\Assert;
require dirname(__DIR__) . '/vendor/autoload.php';
$loop = Factory::create();