Skip to content

Instantly share code, notes, and snippets.

@mylk
mylk / executeWithExponentialBackOff.php
Last active October 15, 2016 14:10
A method that performs exponential backoff on a callback method
<?php
// $this->executeWithExponentialBackOff("self::myMethodName", array("id" => 1), 64);
// in this exmaple myFunctionName() is private and resides in the same class as executeWithExponentialBackOff().
// myFunctionName() has to throw an exception when it fails for the backoff to be performed.
class Foo
{
private function executeWithExponentialBackOff($callback, $parameters, $timeout)
{
@mylk
mylk / RssFeedGeneratorService.php
Created October 16, 2016 15:28
A class that generates an RSS feed from an array of entities
<?php
/*
* Installation (Symfony):
* =======================
* # services.yml
* services:
* # ...
* acme.rss_feed_generator:
* class: Acme\AcmeBundle\Service\RssFeedGeneratorService
@mylk
mylk / chromedriver_downloader.sh
Created December 13, 2020 17:15
Downloads the suitable chromedriver for your Chrome browser version
#!/bin/bash
CHROME_VERSION=`google-chrome-stable --version | awk '{print($3)}' | awk -F '.' '{print($1"."$2"."$3)}'`
CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}"`
echo "Chrome version: ${CHROME_VERSION}"
echo "Suitable chromedriver version: ${CHROMEDRIVER_VERSION}"
echo ""
echo "Downloading chromedriver..."