Skip to content

Instantly share code, notes, and snippets.


Jan Pecha janpecha

View GitHub Profile
juzna /
Created Aug 20, 2012
Nette\Object performance tests

Nette\Object performance tests

I guess you already saw a short note Latency Numbers Every Programmer Should Know. I wanted to check how well Nette performs with its magic properties on Nette\Object.

You can see the testing code below together with raw output on my machine.

It show how much time in seconds it took to execute one million iterations of a particular action, thus it is also time in microseconds of one such call. You should compare it to null test, which execute empty iterations.


lexaurin / .gitconfig
Last active Dec 11, 2015
How to manage changelog by git tags? Prefix tags with "v" letter and use this alias:
View .gitconfig
changelog = "!git tag -l v* -n20 | sed -n 'H;${;g;s/\\n[^v]/\\x00/g;p}' | sort -rV | tr \\\\000 \\\\n | less"
JanTvrdik / uuid.php
Last active Feb 14, 2018
PHP Fast and simple UUID v4 generator
View uuid.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;
mibk / BaseQuery.php
Last active Dec 14, 2018
LeanMapperQuery suggested base classes.
View BaseQuery.php
namespace Model\Entity;
use LeanMapperQuery\Entity;
use LeanMapperQuery\IQuery;
use Model\Query\EntityQuery;
class BaseEntity extends Entity
dg / websocket.html
Created Aug 11, 2013
WebSocket communication between PHP and single client
View websocket.html
<!doctype html>
if ("WebSocket" in window) {
var ws = new WebSocket("ws://");
ws.onopen = function() {
ws.onerror = function(e) {
dg / composing.presenters.php
Created May 31, 2018
Composing presenters without inheritance
View composing.presenters.php
// composing presenters without inheritance
// (requires nette/application 2.4.11)
trait RequireLoggedUser
public function injectRequireLoggedUser()
hauke96 /
Last active Sep 16, 2021
Install in vivaldi

Install in vivaldi

This short instruction shows how to install in vivaldi to play e.g. mp4 videos.

I use the ubuntu repository for that but this is just one way to get the file.

1. Download .deb package

Go to and choose the latest chromium-codecs-ffmpeg-extra and download it.

For example: chromium-codecs-ffmpeg-extra_58.0.3029.110-0ubuntu1.1354_amd64.deb

juzna /
Last active Nov 9, 2021
Server Configuration in git

Server Configuration in git

With git you can have anything versioned. You're used to version your code, which is a bunch of files. Your server configuration (on Linux) is also just a bunch of files, so it can be versioned as well.

The idea is simple: create a git repository in /etc/ and commit everytime you change any configuration of your server. Written in code:

cd /etc
git init
git add .
View gist:d98cac53fdfd1a7176609e9687345be7
I have just discovered a great feature of composer:
composer update --lock
It saves a lot of time when you merge branches with composer.lock file changes in both branches.
Just resolve conflict by applying --ours version of the file (or --theirs, it really doesn't matter) and then run
`composer update --lock `.
Composer will do all the dirty work for you and update composer.lock file according to composer.json changes
and install new packages. The rest of packages in composer are not changed.
senko /
Created Aug 18, 2011
Watch current directory and execute a command if anything in it changes
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
# Written by: Senko Rasic <>
# Requires Linux, bash and inotifywait (from inotify-tools package).
# To avoid executing the command multiple times when a sequence of