Skip to content

Instantly share code, notes, and snippets.

<?php
$productListing = new CircuitBreaker(
10,
function($searchKey) {
// $result is given from the api call
return $result;
}
);
<?php
/**
* We're using a message bus, this is
* the fetch-car message handler.
*/
class FetchCarMessageHandler
{
public function handle(Message $msg)
{
<?php
class CircuitBreaker
{
private $maxFailures;
private $service;
private $redisClient;
public function __construct(int $maxFailures, callable $service)
{
<?php
/**
* Assume that we're using a message bus which is able to
* retry failed messages with a custom retry delay.
*/
class FetchCarMessageHandler
{
public function handle(Message $msg)
{

(standup)

Ieri

Oggi

Blocking

Improvements

<?php
public function getAllIds()
{
$expr = $this->_em->getExpressionBuilder();
$rsm = new ResultSetMapping();
$rsm->addScalarResult('id', 'id');
$result = $this->_em->createNativeQuery('
SELECT u.id as id FROM users u
This file has been truncated, but you can view the full file.
{
"posts": [
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
},
{
"userId": 1,
@toretto460
toretto460 / Iterator.php
Created June 25, 2016 15:28
PHP iterable interfaces
<?php
interface Iterator extends Traversable
{
abstract public mixed current ( void )
abstract public scalar key ( void )
abstract public void next ( void )
abstract public void rewind ( void )
abstract public boolean valid ( void )
}
> const strategies = {
first: () => {},
second: () => {},
undefined: () => 'default'
};
> const obj0 = { type: 'first' };
> const obj1 = { };
@toretto460
toretto460 / docker-machine create
Last active November 4, 2015 10:42
/var/log/vnetlib errors
$ docker-machine -D create -d vmwarefusion fusion
Creating SSH key...
Creating VM...
Creating disk '/Users/toretto/.docker/machine/machines/fusion/fusion.vmdk'
Virtual disk creation successful.
Starting fusion...
executing: /Applications/VMware Fusion.app/Contents/Library/vmrun start /Users/toretto/.docker/machine/machines/fusion/fusion.vmx nogui
Waiting for VM to come online...
MAC address in VMX: 00:0c:29:7f:47:32
IP found in DHCP lease table: 192.168.2.129