Skip to content

Instantly share code, notes, and snippets.

@zdenekdrahos
zdenekdrahos / TransactionalDispatcher.php
Last active August 29, 2015 14:11
Dispatch Symfony events in transaction. https://coderwall.com/p/zfvjsq
<?php
use Doctrine\ORM\EntityManager;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TransactionalDispatcher
{
/** @var EventDispatcherInterface */
private $dispatcher;
@zdenekdrahos
zdenekdrahos / config.rb
Last active June 8, 2016 10:38
Generate .htaccess in Middleman. https://coderwall.com/p/daflfq
# disable layout
page ".htaccess.apache", :layout => false
# rename file after build
after_build do
File.rename 'build/.htaccess.apache', 'build/.htaccess'
end
<?php
namespace App;
use Latte\Engine;
class LatteWithGlobalVariables extends Engine
{
private $globals = [];
<?php
// app/bootstrap.php
function getService($service, array $config = [])
{
return initApplication($config)->getService($service);
}
function initApplication(array $config)
{
@zdenekdrahos
zdenekdrahos / status.html
Last active February 12, 2018 18:54
Scortes - jQuery, AJAX integration
<html lang=cs><head><meta charset=utf-8 /></head><body>
<ul class="teams">
<li><a href='https://scortes.rozpisyzapasu.cz/api/533A1A/2015/Morašice/status.html'>Muži</a></li>
<li><a href='https://scortes.rozpisyzapasu.cz/api/530C2B/2015/H. Újezd/Morašice/status.html'>Dorost</a></li>
<li><a href='https://scortes.rozpisyzapasu.cz/api/533E2A/2015/Morašice/status.html'>Žáci</a></li>
</ul>
<div id="scortes"></div>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
@zdenekdrahos
zdenekdrahos / bash.sh
Created July 23, 2016 12:34
phpqa - exit code experiments
$ phpqa --tools phpcs
[FileSystem\CleanDir] Cleaned build/
[FileSystem\FilesystemStack] mkdir ["build\/"]
[ParallelExec] /var/phpqa/vendor/bin/phpcs -p --extensions=php --standard=PSR2 --ignore=*/vendor/* "./" --report=checkstyle --report-file="build//checkstyle.xml"
1/1 [============================] 100%
[ParallelExec] '/var/phpqa/vendor/bin/phpcs -p --extensions=php --standard=PSR2 --ignore=*/vendor/* "./" --report=checkstyle --report-file="build//checkstyle.xml"' exited with code 1
[ParallelExec] Exit code 1 Time 0.25s
[phpqa]
+-------+----------------+--------------+--------+-------------+
@zdenekdrahos
zdenekdrahos / MethodAnnotations.php
Created December 22, 2016 14:58
phpstan errors?
<?php
namespace Whatever;
// 10 Call to an undefined method Whatever\Swift_SmtpTransport::setUsername().
// 14 Call to an undefined method Whatever\Swift_SmtpTransport::setUsername().
class MethodAnnotations
{
public function __invoke()
{
@zdenekdrahos
zdenekdrahos / README.md
Last active September 18, 2023 13:22
Docker volumes - www-data Debian/Ubuntu + Alpine

Docker volumes - www-data Debian/Ubuntu + Alpine

Sharing host OS www-data directories as a volume is tricky for Alpine images. User ID (UID) and Group ID (GID) are different.

UID/GID Ubuntu Alpine
33 www-data xfs
82 - www-data
@zdenekdrahos
zdenekdrahos / .gitignore
Last active October 16, 2020 17:36
Toggl time-entries -> JIRA (tempo) worklogs
config.php
*.json
*.log