Skip to content

Instantly share code, notes, and snippets.

View oleg-andreyev's full-sized avatar
🎯
Focusing

Oleg Andreyev oleg-andreyev

🎯
Focusing
  • Riga, Latvia
View GitHub Profile
@oleg-andreyev
oleg-andreyev / hf.php
Created February 22, 2020 19:26
Haversine formula
/**
* Calculates the geodesic distance between two points specified by radian latitude/longitude using the
* Haversine formula (hf)
*/
function hf($lat1, $lng1, $lat2, $lng2)
{
$R = 6371e3;
$lng1 = deg2rad($lng1);
$lat1 = deg2rad($lat1);
@oleg-andreyev
oleg-andreyev / WithConsecutive.php
Created July 20, 2023 14:50
WithConsecutive polyfill
<?php
/**
Usage: ->with(...WithConsecutive::create(...$withCodes))
*/
declare(strict_types=1);
namespace App\Tests;
cca0def37dad:/app# SPX_ENABLED=1 SPX_FP_LIVE=1 SPX_METRICS=wt,zm,zmac,zmab,zmfb php test.php
*** SPX Report ***
Global stats:
Called functions : 2.0M
Distinct functions : 3
Wall time : 1.78s
cca0def37dad:/app# SPX_ENABLED=1 SPX_FP_LIVE=1 SPX_METRICS=wt,zm,zmac,zmab,zmfb php test.php
*** SPX Report ***
Global stats:
Called functions : 2.0M
Distinct functions : 3
Wall time : 1.95s