Skip to content

Instantly share code, notes, and snippets.

View jkuchar's full-sized avatar

Jan Kuchař jkuchar

View GitHub Profile
@jkuchar
jkuchar / 5-icu-with-xml.php
Created March 26, 2020 14:26
5-icu-with-xml
<?php
translate('cannotContinue', [
'linkFix' => Html::el('a')->href('https://somewhere')
])
@jkuchar
jkuchar / 4-icu-with-xml.php
Last active March 26, 2020 14:23
4-icu-with-xml.php
<?php
$link = Html::el('a')->href('https://somewhere');
translate('cannotContinue', [
'linkStart' => $link->startTag(),
'linkEnd' => $link->endTag(),
])
@jkuchar
jkuchar / 3-icu.php
Last active March 26, 2020 14:06
3-icu-with-xss.php
<?php
translate('cannotContinue', [
'link' => 'https://somewhere'
])
@jkuchar
jkuchar / 2-gettext.php
Last active March 26, 2020 13:53
How (not) to do localization
<?php
echo translate("You cannot continue,")
echo '<a href="http://somewhere">';
echo translate('click here');
echo '</a>';
echo translate('to fix problem.');
You cannot continue, <a href="http://somewhere">click here</a> to fix problem.
@jkuchar
jkuchar / cleanup-docker.sh
Last active April 1, 2019 16:22
Docker daemon: clean garbage
# @link https://gist.github.com/jkuchar/499cde5952caab68dcdbe6a28dd9309f
# @link http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
# @link http://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/
#
# This will reclaim space and inodes used by stopped containers, dangling images and dangling volumes.
# I use this in GitLab CI multi runner with Docker version 1.13.0; should work with Docker >1.9.0
# Currently I run this script every day in cron.
echo "Containers cleanup: removing exited containers"
docker rm -v $(docker ps -a -q -f status=exited)
<?php
namespace jkuchar\Doctrine\DBAL\Driver\PDOPgSql;
use Doctrine\DBAL\Driver\PDOPgSql\Driver as DoctrineOriginalDriver;
/**
* Adds ability to set search path to PostgreSQL driver
* @package App\Doctrine
@jkuchar
jkuchar / regexp
Created September 8, 2018 17:00
How to find all calls to link generator in Nette?
Use this regexp for example in PHPStorm:
(link\(|redirect\(|forward\(|n:href|\{plink |\{link )
@jkuchar
jkuchar / Pozvání uživatele do systému.php
Created September 4, 2018 19:46
Ukázka scénářových testů
<?php
// 1. prepare invitation
$identityProvider->becomeAdmin();
$invitation = $accounts->prepareInvitation(EmailAddress::of('double-usage@example.com'), 7);
// 2. check invitation code (OK)
$identityProvider->becomeGuest();
$tempIdentity = $accounts->authenticateWithTemporaryToken(
$invitation->getTemporaryAuthenticationToken()
);
@jkuchar
jkuchar / dockerfile
Created March 28, 2017 10:16
How to cache npm, yarn, bower and composer into /cache folder in GitLab CI
# NPM: cache
RUN npm config set cache /cache/.npm
# bower: cache
ENV bower_storage__packages /cache/.bower/packages
ENV bower_storage__registry /cache/.bower/registry
ENV bower_storage__links /cache/.bower/links
# YARN cache
RUN yarn config set cache-folder /cache/yarn