Skip to content

Instantly share code, notes, and snippets.

@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 June 23, 2022 16:17
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 paul@namepros.com 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"
@JanTvrdik
JanTvrdik / Caddyfile
Last active January 3, 2020 09:47
Caddy server configuration for PHP, Nette and h5ai
localhost:80, localhost:443 {
root C:\Projects
log C:\Web\Soft\Caddy\access.log
errors C:\Web\Soft\Caddy\errors.log
tls {
# see https://gist.github.com/JanTvrdik/d22f53604f3bfd78df3863cf1ad87b8a
load C:\Web\Soft\Caddy\certificates
}
@JanTvrdik
JanTvrdik / generate-root-certificate.sh
Last active May 16, 2017 19:08
Generate TLS certificate signed by root certificate
#!/usr/bin/env bash
set -o errexit -o pipefail -o nounset
IFS=$'\n\t'
ROOT="$(dirname $0)/root"
if [[ -f $ROOT.key || -f $ROOT.crt ]]; then
echo "Root certificate already exist"
exit 1
fi
@JanTvrdik
JanTvrdik / record-screen.ps1
Last active October 31, 2021 08:21
Windows FFmpeg-based H.264 lossless screen recording
# https://trac.ffmpeg.org/wiki/Capture/Desktop
# https://ffmpeg.org/ffmpeg-devices.html#gdigrab
# https://trac.ffmpeg.org/wiki/Encode/H.264#LosslessH.264
# WARNING: THE RECORDING WILL STOP WHEN UAC POPUP IS SHOWN
C:\SoftPortable\ffmpeg\bin\ffmpeg `
-f gdigrab -framerate 30 -draw_mouse 1 -i desktop `
-c:v libx264 -qp 0 -pix_fmt yuv444p -preset ultrafast `
"C:\Videos\recording-$(get-date -f yyyy-MM-dd-Hmss).mp4"