Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
JanTvrdik / docker-credential-shipmonk-ecr-login
Created November 26, 2025 16:33
Bash implementation of Docker credential helper for AWS ECR (without any storage)
#!/usr/bin/env bash
set -euo pipefail
# Bash implementation of Docker credential helper for AWS ECR (without any storage)
# https://docs.docker.com/reference/cli/docker/login/#credential-helper-protocol
if [ "$1" == "get" ]; then
SERVER_URL=$(cat)
# Extract region from URL format: *.dkr.ecr.REGION.amazonaws.com
@JanTvrdik
JanTvrdik / TransactionManager.php
Last active November 6, 2025 12:03
Retryable Transaction Implementation for Doctrine ORM
<?php declare(strict_types = 1);
namespace ShipMonk\QueryGuard\Framework\DoctrineOrm;
use Closure;
use Doctrine\DBAL\Exception\RetryableException;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\OptimisticLockException;
<?php declare(strict_types = 1);
namespace App\Tests;
use Closure;
use PHPUnit\Framework\Assert;
use ReflectionClass;
use ReflectionFiber;
use ReflectionFunction;
use ReflectionGenerator;
@JanTvrdik
JanTvrdik / uuid.php
Last active February 14, 2018 14:11
PHP Fast and simple UUID v4 generator
<?php
function generateUuidWithoutDashes(): string
{
$uuidBin = random_bytes(16);
$uuidBin &= "\xFF\xFF\xFF\xFF\xFF\xFF\x0F\xFF\x3F\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
$uuidBin |= "\x00\x00\x00\x00\x00\x00\x40\x00\x80\x00\x00\x00\x00\x00\x00\x00";
$uuidHex = bin2hex($uuidBin);
return $uuidHex;
@JanTvrdik
JanTvrdik / README.md
Last active April 10, 2025 06:26
Papertrail S3 log downloader

Papertrail S3 log downloader

  1. Get Your Papertrail token from https://papertrailapp.com/account/profile
  2. Profit!
# download logs from last 30 days
PAPERTRAIL_TOKEN=9X4cddgwe53fAbbsYh4 papertrail-download-daily.sh 30

# download logs from last 30 days &amp; filter each through ./filter.sh
@JanTvrdik
JanTvrdik / README.md
Last active May 3, 2017 11:51 — forked from Mikulas/README.md
git-nudge

git-nudge

Same as git push, but suppresses GitHub branch protection for admins on pushed branches.

Installation

Put this file to any location in your $PATH and make it executable.

@JanTvrdik
JanTvrdik / example.php
Created March 21, 2017 08:40 — forked from hikari-no-yume/example.php
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
@JanTvrdik
JanTvrdik / escapeshellrce.md
Created January 4, 2017 10:05 — forked from Zenexer/escapeshellrce.md
Security Advisory: PHP's escapeshellcmd and escapeshellarg are insecure

Paul Buonopane [email protected] at NamePros
PGP: https://keybase.io/zenexer

I'm working on cleaning up this advisory so that it's more informative at a glance. Suggestions are welcome.

This advisory addresses the underlying PHP vulnerabilities behind Dawid Golunski's [CVE-2016-10033][CVE-2016-10033], [CVE-2016-10045][CVE-2016-10045], and [CVE-2016-10074][CVE-2016-10074]. It assumes prior understanding of these vulnerabilities.

This advisory does not yet have associated CVE identifiers.

Summary

@JanTvrdik
JanTvrdik / dynamicReturnTypeMeta.json
Created August 10, 2016 08:40
dynamicReturnTypeMeta.json for Nette & Mockery
{
"methodCalls": [
{
"class": "\\Mockery",
"method": "mock",
"position": 0,
"mask": "\\Mockery\\MockInterface|%s"
},
{
"class": "\\Nette\\DI\\Container",
@JanTvrdik
JanTvrdik / update-ca-bundle.sh
Last active June 12, 2016 20:59
PHP CA bundle updater
#!/usr/bin/env bash
set -o errexit -o pipefail -o nounset
IFS=$'\n\t'
ROOT_CRT="$(dirname $0)/root/root.crt"
CA_BUNDLE="$(dirname $0)/ca-bundle.pem"
echo -n "Downloading CA bundle... "
wget -q -O "$CA_BUNDLE" https://curl.haxx.se/ca/cacert.pem
echo "done"