Skip to content

Instantly share code, notes, and snippets.

View Jenkinsfile
node {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm', 'defaultFg': 1, 'defaultBg': 2]) {
wrap([$class: 'TimestamperBuildWrapper']) {
... steps... and other stuff
}
}
}
@mhlavac
mhlavac / AcceptanceTester.php
Created Sep 16, 2016
Codeception retryOnFailure
View AcceptanceTester.php
<?php
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
public function retryOnFailure(callable $callback, int $times = 3)
{
while ($times > 0) {
try {
$callback($this);
View User.php
<?php
class User
{
public function getThis()
{
return $this;
}
public function setThis($that)
{
View UserType.php
<?php
class UserType extends \Symfony\Component\Form\AbstractType
{
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
$builder->add('name', CompoundType::class, [
'inherit_data' => true,
]);
$builder->addEventListener(\Symfony\Component\Form\FormEvents::POST_SET_DATA, function (\Symfony\Component\Form\FormEvent $event) {
@mhlavac
mhlavac / NameType.php
Created May 24, 2016
Symfony2 inherit_data issues and workaround
View NameType.php
<?php
class NameType extends \Symfony\Component\Form\AbstractType
{
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
$builder->add('firstName', 'text');
$builder->add('lastName', 'text');
}
}
@mhlavac
mhlavac / avoid.php
Created Nov 29, 2015
If you see this code... avoid the project! :-)
View avoid.php
$a = getAllCars();
foreach ($a as $a1) {
$b1 = $a1;
$b1['name'] = $a1['name'] . '_';
// ... about 100 lines later...
if ($b1['name'] == $a1['name']) {
save($a2);
} else {
@mhlavac
mhlavac / greeter.php
Last active Aug 29, 2015
Container vs Composite vs Chain
View greeter.php
<?php
interface Greeter
{
public function greet($name);
}
class ChainGreeter implements Greeter
{
private $greeters = [];
@mhlavac
mhlavac / lvm_add_physical_volume.sh
Created Jun 18, 2013
LVM add new physical volume to existing logical volume and extend that logical volume as much as possible.
View lvm_add_physical_volume.sh
#!/bin/sh
if [ `id -u` -ne '0' ]; then
echo "This script must be run as root" >&2
exit 1
fi
drive=$1
volume_group=$2
volume_group_location=$3
@mhlavac
mhlavac / Example.php
Created May 4, 2013
PHPUnit with php core functions
View Example.php
<?php
namespace Example;
class Example
{
public function doSomething()
{
eval('ls -la');
}
}
@mhlavac
mhlavac / devel2013.md
Created Mar 3, 2013
My notes from devel 2013 conference
View devel2013.md

EsteJS - javascriptové aplikace robusně, modulárně a komfortně Daniel Steigerwald

  • Grunt - The JavaScript Task Runner
  • Bower - A package manager for the web
  • Component - Component package manager for building a better web.
  • AngularJS - MVC Javascript framework
  • Sencha, Dojo...

Kinohled.cz za 2 týdny Vojtěch Semecký