Skip to content

Instantly share code, notes, and snippets.

View mhlavac's full-sized avatar

Martin Hlavac mhlavac

View GitHub Profile
@mhlavac
mhlavac / ipmrp_cviceni_3_priklad_1.m
Created February 19, 2013 18:40
První příklad z 3. cvičení předmětu IpmrP - Pokročilé metody v rozhodování
clc
clear all
valuesCount = 10;
values = [];
valuesFound = 0;
highestInterval = input('Zadej horni interval: ');
lowestInterval = input('Zadej dolni interval: ');
for x = 1:valuesCount
@mhlavac
mhlavac / PHP_UK_Conference_2013.md
Created March 3, 2013 09:12
My notes from PHP UK Conference 2013
@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ý

@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 / 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 / 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 / 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 / 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');
}
}
<?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) {
<?php
class User
{
public function getThis()
{
return $this;
}
public function setThis($that)
{