Skip to content

Instantly share code, notes, and snippets.

View mhlavac's full-sized avatar

Martin Hlavac mhlavac

View GitHub Profile
@mhlavac
mhlavac / Jenkinsfile
Created November 22, 2016 13:22
Jenkinsfile
node {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm', 'defaultFg': 1, 'defaultBg': 2]) {
wrap([$class: 'TimestamperBuildWrapper']) {
... steps... and other stuff
}
}
}
@mhlavac
mhlavac / AcceptanceTester.php
Created September 16, 2016 09:39
Codeception retryOnFailure
<?php
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
public function retryOnFailure(callable $callback, int $times = 3)
{
while ($times > 0) {
try {
$callback($this);
<?php
class User
{
public function getThis()
{
return $this;
}
public function setThis($that)
{
<?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 12:23
Symfony2 inherit_data issues and workaround
<?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 November 29, 2015 18:26
If you see this code... avoid the project! :-)
$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 August 29, 2015 14:24
Container vs Composite vs Chain
<?php
interface Greeter
{
public function greet($name);
}
class ChainGreeter implements Greeter
{
private $greeters = [];
@mhlavac
mhlavac / lvm_add_physical_volume.sh
Created June 18, 2013 05:10
LVM add new physical volume to existing logical volume and extend that logical volume as much as possible.
#!/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 21:17
PHPUnit with php core functions
<?php
namespace Example;
class Example
{
public function doSomething()
{
eval('ls -la');
}
}
@mhlavac
mhlavac / devel2013.md
Created March 3, 2013 10:12
My notes from devel 2013 conference

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ý