Skip to content

Instantly share code, notes, and snippets.

@mingalevme
mingalevme / AppServiceProvider.php
Last active April 13, 2023 05:21
Laravel Sentry Data Sanitizer
<?php
namespace App\Providers;
use App\Helpers\SentrySanitizeDataOnBeforeSendListener;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Foundation\CachesConfiguration;
use Sentry\Event as SentryEvent;
use Sentry\EventHint as SentryEventHint;
use Sentry\Laravel\ServiceProvider as SentryServiceProvider;
@mingalevme
mingalevme / GenerateAccessToken.php
Last active September 15, 2022 10:01
Example of Generating Apple SignIn Access Token (based on Laravel/Lumen Command)
<?php
declare(strict_types=1);
namespace App\Console\Commands\Apple;
use App\Console\Command;
use App\Helpers\Jwt;
use Carbon\Carbon;
use GuzzleHttp\ClientInterface as GuzzleClient;
@mingalevme
mingalevme / Dockerfile
Last active February 8, 2023 06:52
PHP 7.4 Docker + Xdebug + Composer
FROM php:7.4
RUN apt-get -y update && \
apt-get install -y zip libzip-dev && docker-php-ext-install zip && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
php -r "unlink('composer-setup.php');" && \
pecl install xdebug && docker-php-ext-enable xdebug
@mingalevme
mingalevme / Dockerfile
Last active December 20, 2022 08:48
PHP 5.4 Docker + Xdebug + Composer
FROM php:5.4
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y zlib1g-dev libzip-dev unzip && \
curl --insecure "https://getcomposer.org/download/latest-2.2.x/composer.phar" > "/usr/local/bin/composer" && \
chmod a+x "/usr/local/bin/composer" && \
cd /opt && \
curl --insecure -O https://xdebug.org/files/xdebug-2.4.1.tgz && \
tar -xvf xdebug-2.4.1.tgz && \
cd xdebug-2.4.1 && \
phpize && \
#!/usr/bin/env sh
filename="${1:--}"
if [ "$filename" = "-" ]; then
filename="/dev/stdin"
fi
grep_options=( -Po )
if [[ "$OSTYPE" == "darwin"* ]]; then
@mingalevme
mingalevme / php-fpm_exporter.Dockerfile
Last active July 8, 2021 08:58
hipages/php-fpm_exporter with
#
# docker build --target php-fpm_exporter -t php-fpm_exporter .
#
FROM golang:alpine AS builder
RUN apk add --update git
WORKDIR /php-fpm_exporter
RUN true && \
git config --global user.email "user@example.com" && \
git clone 'https://github.com/hipages/php-fpm_exporter.git' . && \
git remote add stanxing https://github.com/stanxing/php-fpm_exporter.git && \
@mingalevme
mingalevme / logger.go
Created March 31, 2021 10:02
Go (golang) logger interface (logrus)
package log
import (
"context"
"github.com/sirupsen/logrus"
"time"
)
type Fields logrus.Fields
#!/usr/bin/env bash
PROJECT_CODE_NAME=${PROJECT_CODE_NAME:?}
PG_VERSION_FROM=${PG_VERSION_FROM:?}
PG_VERSION_TO=${PG_VERSION_TO:?}
ILLUMINATE_PROJECT_USERNAME="${ILLUMINATE_PROJECT_USERNAME:-$PROJECT_CODE_NAME}"
PGHOST=${PGHOST:-127.0.0.1}
@mingalevme
mingalevme / php-redis-custom-flags.sh
Created March 1, 2020 11:46
Installing PHP Redis extension inside PHP-Alpine-based Docker container
NPROC=$(getconf _NPROCESSORS_ONLN)
mkdir -p /usr/src/php/ext
cd /usr/src/php/ext
pecl bundle redis
docker-php-ext-configure redis --enable-redis-igbinary --enable-redis-lzf
docker-php-ext-install -j${NPROC} redis
cd -
class GoogleMapsQueryArgsDeserializer
{
public static function deserialize(string $input): array
{
$params = explode('!', trim($input, '!'));
foreach ($params as $i => $param) {
$params[$i] = urldecode($param);
}