Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Pecha janpecha

View GitHub Profile
@senko
senko / onchange.sh
Created August 18, 2011 16:52
Watch current directory and execute a command if anything in it changes
View onchange.sh
#!/bin/bash
#
# 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 <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@juzna
juzna / intro.md
Created August 20, 2012 19:19
Nette\Object performance tests
View intro.md

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.

Results

@lexaurin
lexaurin / .gitconfig
Last active December 11, 2015 11:28
How to manage changelog by git tags? Prefix tags with "v" letter and use this alias:
View .gitconfig
[alias]
changelog = "!git tag -l v* -n20 | sed -n 'H;${;g;s/\\n[^v]/\\x00/g;p}' | sort -rV | tr \\\\000 \\\\n | less"
@juzna
juzna / 01-server-config-in-git.md
Last active November 9, 2021 07:27
Server Configuration in git
View 01-server-config-in-git.md

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 .
@dg
dg / websocket.html
Created August 11, 2013 15:54
WebSocket communication between PHP and single client
View websocket.html
<!doctype html>
<script>
if ("WebSocket" in window) {
var ws = new WebSocket("ws://127.0.0.1:31339");
ws.onopen = function() {
console.log('connected');
};
ws.onerror = function(e) {
@mibk
mibk / BaseQuery.php
Last active December 14, 2018 10:36
LeanMapperQuery suggested base classes.
View BaseQuery.php
<?php
namespace Model\Entity;
use LeanMapperQuery\Entity;
use LeanMapperQuery\IQuery;
use Model\Query\EntityQuery;
class BaseEntity extends Entity
{
@milo
milo / github-webhook-handler.php
Last active November 9, 2022 16:40
GitHub Webhook Handler
View github-webhook-handler.php
<?php
/**
* GitHub webhook handler template.
*
* @see https://docs.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check
@geekmanager
geekmanager / make-git-use-sublime.markdown
Last active November 20, 2022 20:47
Making git use Sublime Text for rebase etc
View make-git-use-sublime.markdown

Making git use Sublime Text

First up, let's make Sublime Text 2 available from the command line in terminal, by creating a link to subl which is the launcher from terminal:

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

(added bonus of this approach is when you upgrade to ST3 or change text editor, you can just redirect the symlink).

If there's any chance that bash doesn't check usr/local/bin then use [Launch Sublime Text 2 from Mac OSX Terminal] for more detailed instructions on how to make this happen.

@hauke96
hauke96 / libffmpeg_vivaldi.md
Last active September 16, 2021 10:57
Install libffmpeg.so in vivaldi
View libffmpeg_vivaldi.md

Install libffmpeg.so in vivaldi

This short instruction shows how to install libffmpeg.so 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 http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ 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

@JanTvrdik
JanTvrdik / uuid.php
Last active February 14, 2018 14:11
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;