Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
JanTvrdik / .bashrc
Last active Sep 9, 2021 — forked from gsomoza/.bashrc
ssh-agent support for Git Bash / MinGW / msys / Windows
View .bashrc
# 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 May 8, 2021
Windows FFmpeg-based H.264 lossless screen recording
View record-screen.ps1
# 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 Jan 4, 2017 — forked from Zenexer/escapeshellrce.md
Security Advisory: PHP's escapeshellcmd and escapeshellarg are insecure
View escapeshellrce.md

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 Jan 3, 2020
Caddy server configuration for PHP, Nette and h5ai
View Caddyfile
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 / README.md
Last active Aug 19, 2019
Papertrail S3 log downloader
View README.md

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 / bench.php
Last active Oct 10, 2018
PHP quick benchmark skeleton
View bench.php
<?php
$runCount = 1000;
$dataSets = [
'setA' => [$runCount, 123],
];
$tests = [
'testA' => function ($count, $n) {
@JanTvrdik
JanTvrdik / uuid.php
Last active Feb 14, 2018
PHP Fast and simple UUID v4 generator
View uuid.php
<?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
Generate TLS certificate signed by root certificate
View generate-root-certificate.sh
#!/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 — forked from Mikulas/README.md
git-nudge
View README.md

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 Mar 21, 2017 — forked from hikari-no-yume/example.php
function chaining for PHP 7
View example.php
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);