This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Psy Shell v0.9.9 (PHP 7.2.16 — cli) by Justin Hileman | |
>>> $u = new App\User; | |
=> App\User {#2930} | |
>>> $u->all() | |
=> Illuminate\Database\Eloquent\Collection {#2938 | |
all: [ | |
App\User {#2939 | |
id: 1, | |
name: "ramesh", | |
email: "[email protected]", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
zookeeper: | |
image: wurstmeister/zookeeper | |
ports: | |
- "2181:2181" | |
kafka: | |
image: wurstmeister/kafka | |
ports: | |
- "9092:9092" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* example code gist, | |
*/ | |
Model_A::whereHas('Model_B', | |
function (\Illuminate\Database\Eloquent\Builder $builder) { | |
$builder->upcoming()->where('cancel_reason', Model_B::REASON_NOT_AVAILABLE); | |
})->active(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Str::macro('addressSplitter', function (string $address) { | |
$leadingHouseNumber = '/^([\d-]+[a-z]{0,1}[\d-]?[\d,]?)\ ([a-z\ ]+)$/mi'; | |
$endingWithHouseNumber = '/^([a-z\ ]+)([\d?]+)([\D+?]+[\d+?]?.+)?|([\D+?]+[\d+?]?+)$/mi'; | |
if (preg_match_all($leadingHouseNumber, $address, $matches, PREG_SET_ORDER, 0) | |
&& isset($matches[0][1], $matches[0][2]) | |
) { | |
$result['house_number'] = (int) $matches[0][1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Observable { | |
subscribe(observer: Observer): void; | |
unsubscribe(observer: Observer): void; | |
notify(): void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Observer { | |
update(subject: Subject); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subject implements Observable { | |
private observers: Observer[] = []; | |
subscribe(observer: Observer) { | |
this.observers.push(observer); | |
} | |
unsubscribe(observer: Observer) { | |
this.observers = this.observers.filter((o) => { | |
return o !== observer | |
}) | |
console.log('observer detached...' + observer.constructor.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Score extends Subject { | |
private score: number; | |
public updateScore(score: number) | |
{ | |
this.score = score; | |
console.log('got new score.....'); | |
this.notify(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisplayScore implements Observer { | |
update(subject: Score) { | |
console.log('Display score: ' + subject.getScore()); | |
} | |
} | |
class CliScore implements Observer { | |
update(subject: Score) { | |
console.log('CLI score: ' + subject.getScore()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const score = new Score(); | |
const display = new DisplayScore(); | |
const cli = new CliScore(); | |
score.subscribe(display); | |
score.subscribe(cli); | |
score.updateScore(4); |
OlderNewer