Skip to content

Instantly share code, notes, and snippets.

@nickkraakman
nickkraakman / exponential-backoff.php
Last active September 28, 2024 00:07
API call with max number of retries and exponential backoff in PHP
<?php
$retries = 0; // Init the retries variable
$maxRetries = 5; // Means we try max 6 times
$retry = false; // Should we retry or not?
$initialWait = 1.0; // Initial wait time in seconds
try {
do {
// If it is not the first try, calculate exponential backoff and wait
@greg-randall
greg-randall / index.php
Last active December 1, 2022 15:42 — forked from vsoch/index.php
Generate RSS feed for files in a directory folder. Put this file in a folder with files, modify the $allowed_ext variable to customize your extensions, and $feedName, and $feedDesc. Then navigate to the folder on the web to see the xml feed.
<?php
header("Content-type: text/xml");
$feed_name = "My Audio Feed";
$feed_description = "Feed for the my audio files in some server folder";
$base_url = strtok('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '?'); //gets the current page's url. strips off the url's parameters
$allowed_extensions = array('mp4','mp3');
?>
<?php echo '<?xml version="1.0"?>'; //we have to use php to output the "<?" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@hirak
hirak / 01_benchmark.md
Last active July 4, 2020 06:07
performance of "composer update" download meta.json phase

"composer update" benchmark

composer update is ...

  1. download https://packagist.org/p/*.json phase
  2. resolve dependencies phase
  3. download package.zip phase

In Asia(Japan, China, etc), far from packagist.org(French?), RTT is terrible. So it spends long time for "1. download meta.json phase". This is the benchmark for it. I think packagist.org should use CDN like CloudFlare.