Skip to content

Instantly share code, notes, and snippets.

@holtkamp
holtkamp / RequestThrottler.php
Created April 9, 2018 11:54
Configurable RequestThrottler useful when communicating with an throttled API
<?php
use Illuminate\Support\Collection;
use Psr\Log\LoggerInterface;
class RequestThrottler
{
/**
* @var LoggerInterface
*/
private $logger;
@holtkamp
holtkamp / submit-form-to-iron-mq.html
Last active March 31, 2016 09:02
Scalable form processing with scalable message queues: submit HTML form directly to IronMQ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scalable form processing with scalable message queues</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"></script>
</head>
<body>
<h1>Scalable form processing with scalable message queues</h1>
@holtkamp
holtkamp / di.caches.php
Last active January 9, 2016 14:47
PHP-DI cache configuration with dynamic namespaces that result in specific MongoCollections
<?php
return array(
MongoClient::class => object()->constructor(get('setting.mongodb.url'), $options = array()),
MongoDB::class => object()->constructor(get(MongoClient::class), get('setting.mongodb.database')),
'*' . MongoCollection::class => function (ContainerInterface $container, RequestedEntry $e) {
$namespace = str_replace(MongoCollection::class, '', $e->getName());
return new MongoCollection($container->get(MongoDB::class), $name = $namespace);
},
'*chainCachesCollection' => function (ContainerInterface $container, RequestedEntry $e) {
$namespace = str_replace('chainCachesCollection', '', $e->getName());
Verifying that +holtkamp is my blockchain ID. https://onename.com/holtkamp
@holtkamp
holtkamp / resetPropertiesInClassHierarcy.php
Last active August 29, 2015 14:22
Reset all (public, protected, private) properties of a class hierarchy in a bottom-up approach
<?php
/**
* Use reflection to reset all properties in the hierarchy of the current object.
*
* Because lower level classes, might define / override their own property values, we need to reset in the proper
* order: from parent to child
*
* @return void
*/