Skip to content

Instantly share code, notes, and snippets.

@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 & filter each through ./filter.sh
@JanTvrdik
JanTvrdik / .bashrc
Last active June 14, 2022 04:14 — forked from gsomoza/.bashrc
ssh-agent support for Git Bash / MinGW / msys / Windows
# put this in ~/.bashrc
export SSH_AUTH_SOCK=/tmp/.ssh-socket
ssh-add -l > /dev/null
if [ $? = 2 ]; then
rm -f $SSH_AUTH_SOCK
echo Starting new ssh-agent...
eval $(ssh-agent -a $SSH_AUTH_SOCK) > /dev/null
ssh-add && echo "ssh-agent set up successfully with the following keys:" && ssh-add -l
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"
@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 / 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 / bench.php
Last active October 10, 2018 06:41
PHP quick benchmark skeleton
<?php
$runCount = 1000;
$dataSets = [
'setA' => [$runCount, 123],
];
$tests = [
'testA' => function ($count, $n) {
@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 / 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 / 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($_);