Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Kuchař jkuchar

View GitHub Profile
View 5-icu-with-xml.php
<?php
translate('cannotContinue', [
'linkFix' => Html::el('a')->href('https://somewhere')
])
@jkuchar
jkuchar / 4-icu-with-xml.php
Last active Mar 26, 2020
4-icu-with-xml.php
View 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 Mar 26, 2020
3-icu-with-xss.php
View 3-icu.php
<?php
translate('cannotContinue', [
'link' => 'https://somewhere'
])
View 1.html
You cannot continue, <a href="http://somewhere">click here</a> to fix problem.
@jkuchar
jkuchar / 2-gettext.php
Last active Mar 26, 2020
How (not) to do localization
View 2-gettext.php
<?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 Sep 8, 2018
How to find all calls to link generator in Nette?
View regexp
Use this regexp for example in PHPStorm:
(link\(|redirect\(|forward\(|n:href|\{plink |\{link )
View Pozvání uživatele do systému.php
<?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
SplFixedArray - infinite loop
View loop.php
<?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 Jun 16, 2017
Fira Code Font in GitLab
View styler-chrome-extension.css
/* 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 Mar 28, 2017
How to cache npm, yarn, bower and composer into /cache folder in GitLab CI
View dockerfile
# 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
You can’t perform that action at this time.