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
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
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
@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;
@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 / vif.php
Created February 22, 2020 19:25
Vincenty inverse formula for ellipsoids
/**
* Calculates the geodesic distance between two points specified by radian latitude/longitude using
* Vincenty inverse formula for ellipsoids (vif)
*/
function vif($lng1, $lat1, $lng2, $lat2)
{
$lng1 = deg2rad($lng1);
$lat1 = deg2rad($lat1);
$lng2 = deg2rad($lng2);
$lat2 = deg2rad($lat2);
@oleg-andreyev
oleg-andreyev / ref.yaml
Created January 9, 2020 22:26
APIP YAML reference
<FQCN>:
shortName: <string>
description: <string>
iri: <string>
itemOperations:
get:
method: GET
produces: ~
summary: ~
description: ~
# Follow https://gist.github.com/oleg-andreyev/05fae22548ccdff8deebde144c4cbe7f
# nproc alias https://gist.github.com/oleg-andreyev/053b90ef33d2c29446ef466a2817d01c
function is_osx {
local uname=$(uname)
if [ "$uname" = "Darwin" ]; then
return 0
else
return 1
@oleg-andreyev
oleg-andreyev / install-php7.4-macos-mojave.sh
Last active March 11, 2020 18:06
install php 7.4snapshot on MacOS Majova using brew and phpenv
# Follow https://gist.github.com/oleg-andreyev/05fae22548ccdff8deebde144c4cbe7f
# nproc alias https://gist.github.com/oleg-andreyev/053b90ef33d2c29446ef466a2817d01c
# avoid brew cleanup
export HOMEBREW_NO_INSTALL_CLEANUP=1
# icu4c must be >= 64.0
brew install icu4c bison@3.4 krb5 oniguruma libedit
export PATH="/usr/local/opt/icu4c/bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/bison/bin:/usr/local/opt/krb5/bin:/usr/local/opt/krb5/sbin:/usr/local/opt/openssl@1.1/bin:$PATH"
@oleg-andreyev
oleg-andreyev / gist:8d809dea15dcb7becdc3a45cff2c3841
Created June 22, 2019 21:33
macOS-php-732-bug-timelib_get_time_zone_info
curl -L https://raw.githubusercontent.com/phpenv/phpenv-installer/master/bin/phpenv-installer | bash
PHP_BUILD_EXTRA_MAKE_ARGUMENTS="-j$(nproc)" phpenv install 7.3.2
git clone https://github.com/oleg-andreyev/MinkSelenium2Driver -b fix-master-build
cd MinkSelenium2Driver
composer install
docker run -p 4444:4444 -v /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:2.53.1
php -dmemory_limit=3G -S localhost:8002 -t ./vendor/mink/driver-testsuite/web-fixtures
phpenv local 7.3.2
@oleg-andreyev
oleg-andreyev / nproc-alias.sh
Created April 15, 2019 22:45
nproc alias on macOS
alias nproc="sysctl -n hw.physicalcpu"