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'
])
You cannot continue, <a href="http://somewhere">click here</a> to fix problem.
@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.');
@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 / loop.php
Created May 28, 2017 16:06
SplFixedArray - infinite loop
<?php
// https://3v4l.org/LDQ6i
// Arrange
$object = new SplFixedArray(2);
$object[0] = 'first-value';
$object[1] = 'second-value';
// Act
foreach ($object as $key1 => $val1) {
@jkuchar
jkuchar / styler-chrome-extension.css
Last active June 16, 2017 15:26
Fira Code Font in GitLab
/* Use Fira Code */
/* in merge requests */
.diff-file .diff-content table,
.diff-file .diff-content table .line_holder td, /* to properly override line-height and font-size */
.file-content.code .line-numbers a, /* to align line numbers with lines of source */
/* in file view */
.file-content.code pre code
{
@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