Skip to content

Instantly share code, notes, and snippets.

View konradpodgorski's full-sized avatar

Konrad Podgórski konradpodgorski

View GitHub Profile
<?php
writeln("all input data are correct, so all asserts should return true, right?");
assertTwoFloats(20000 / 10000 - 1, 1);
assertTwoFloats(14700 / 10000 - 1, 0.47);
writeln("those don't:");
assertTwoFloats(14600 / 10000 - 1, 0.46);
@konradpodgorski
konradpodgorski / readme.md
Last active December 29, 2015 04:59
Laboratorium Wordpressa with Geek Girls Carrots Przydatne komendy

Laboratorium Wordpressa with Geek Girls Carrots

Poniżej znajduje się ściągawka dla uczestników warsztatu

W poniższej instrukcji występują zwroty

  • wiersz poleceń
  • terminal
  • konsola
@konradpodgorski
konradpodgorski / index.md
Created October 19, 2013 10:05
How to implement a secure choice form field with Symfony

Create Util class for your entity, in my case entity is called 'Brand'

src/KP/Brand/MainBundle/Util/BrandUtil.php

<?php

namespace KP\Brand\MainBundle\Util;

use KP\Brand\MainBundle\Entity\Brand;
<?php
private function getErrorMessages(\Symfony\Component\Form\Form $form) {
$errors = array();
if ($form->hasChildren()) {
foreach ($form->getChildren() as $child) {
if (!$child->isValid()) {
$errors[$child->getName()] = $this->getErrorMessages($child);
}
@konradpodgorski
konradpodgorski / routing.yml
Created September 1, 2013 19:19
WTF of the day :D Why bother to use forms when you can use routing! :> * of course this is not my code.
backend_new_user:
pattern: /admin/new-user/{username}/{password}/{email}
@konradpodgorski
konradpodgorski / config_test.yml
Created July 22, 2013 10:27
SQLite test config
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
web_profiler:
toolbar: false
@konradpodgorski
konradpodgorski / .gitignore_global
Last active December 19, 2015 16:19
.gitignore_global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@konradpodgorski
konradpodgorski / AbstractController
Created June 13, 2013 20:47
Reusable AbstractController with shortcuts for frequently used methods
<?php
namespace KP\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* Class AbstractController
*
* @package KP\MainBundle\Controller