Instantly share code, notes, and snippets.

View CsvResponse.php
namespace App\Responses;
use Nette\Application;
use Nette\Http;
View vhost.conf
# Proxy for local running .NET application on port 5000
# a2enmod proxy proxy_http proxy_wstunnel
<VirtualHost *:443>
View Crypt.php
* Copyright (c) 2015 Miloslav Hůla (
namespace Milo;
final class Crypt
View fid-remove.js
(function (w, timeout) {
setTimeout(function () {
var url = w.location.toString();
if (w.history && w.history.replaceState && url.indexOf('_fid=') !== -1) {
w.history.replaceState({}, null, /[?&]_fid=[^&]+$/.test(url)
? url.replace(/[?&]_fid=[^&]+/, '')
: url.replace(/([?&])_fid=[^&]+&/, '$1')
}, timeout || 2000);
View PersistentUploadControl.php
namespace App\Controls;
use App\Model\Entities;
use Nette\DirectoryNotFoundException;
use Nette\Forms;
use Nette\Http;
use Nette\Utils\Html;
View post-merge
# Save as .git/hooks/post-merge
# Set execute bit like: chmod ug+x .git/hooks/post-merge
echo -n "HOOK [Purge cache]: "
if [ -d "$purgePath" ]; then
View Bootstrap3Renderer.php
namespace Milo\NetteForms\Rendering;
use Nette\Forms;
use Nette\Forms\Controls;
* Simple Bootstrap3 renderer for Nette Framework forms.

This is reaction to article Using local packges as composer dependencies.

The described technique bothers for two main things (mentioned on the article end):

  • after every dependency package change (even one single character) you have to commit changes
  • after that you have to call composer update (on big project, you have to wait few seconds for autoload.php is created)

My best technique is:

  • create project by composer with all dependencies
  • drop developed dependencies from composer.json and run composer update (or just delete them in vendor folder)
  • clone all dependencies into project/libs-dev/... subdirecotries (or link them by file system links)
View github-webhook-handler.php
* GitHub webhook handler template.
* @see
* @author Miloslav Hůla (
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check

How to keep a Nette addon compatibility with Nette Framework 2.0, 2.1 and 2.2? Here is my fight description:

  1. Nette 2.0 Nette\Utils\PhpGenerator\ClassType vs Nette 2.1+ Nette\PhpGenerator\ClassType strict errors and Nette\Config\CompilerExtension vs. Nette\DI\CompilerExtension. This was a difficult one:
  • Create abstract BC\Extensions like this,
  • and Nette version-dependent loader like this.
  • A target extension will inherit one of them as class Extension extends BC\Extension and
  • the Composer will class-mapping different folder and hard load version-dependent loader like this.
  1. IBarPanel is solved in the same way as 1)