Skip to content

Instantly share code, notes, and snippets.

View jverdeyen's full-sized avatar

Joeri Verdeyen jverdeyen

View GitHub Profile
@jverdeyen
jverdeyen / gist:9651422
Created March 19, 2014 21:11
ArrayAccess, Iteratable and countable object
<?php
namespace xxx\AppBundle\Model\User\Search;
class UserSearch implements \ArrayAccess, \IteratorAggregate, \Countable
{
private $data = [];
public function &__get ($key)
@jverdeyen
jverdeyen / bash_prompt.sh
Last active August 29, 2015 14:01
bash_prompt
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
@jverdeyen
jverdeyen / gist:482019064e65b7b5dfe5
Created September 29, 2014 11:23
FormValidationController.php
/**
* @Route("/validator", name="route_name")
*/
public function validationAction(Request $request)
{
$object = new typeOfObject();
$form = $this->container->get('form.factory')->create(new ObjectFormType(), $object);
$form->submit($request);
$violations = $this->container->get('validator')->validate($object);
@jverdeyen
jverdeyen / gist:9075b2b736bcac08ef86
Created December 5, 2014 14:28
Symfony2 validate form without submit
$errors = $this->get('validator')->validate($user, array('user'));
foreach ($errors as $error) {
$form->get($error->getPropertyPath())->addError(new FormError($error->getMessage()));
}
@jverdeyen
jverdeyen / RoboFile.php
Created January 27, 2015 07:16
Robo: Starting WebDriver in Docker container, starting PHP server, running acceptance tests
<?php
public function testWebdriver($args = '', $opt = ['test|t' => null])
{
$test = $opt['test'] ? ':'.$opt['test'] : '';
$container = $this->taskDockerRun('davert/selenium-env')
->detached()
->publish(4444,4444)
->env('APP_PORT', 8000)
->run();
@jverdeyen
jverdeyen / gist:f9e0bb97f5172b05a58a
Created February 13, 2015 09:51
Package Control.sublime-settings
{
"in_process_packages":
[
],
"installed_packages":
[
"Alignment",
"AndyPHP",
"Behat Features",
"GitGutter",
@jverdeyen
jverdeyen / how_do_you_write_php.md
Last active August 29, 2015 14:15
How do you write this PHP function?

A function which has an object and a locale as parameter.

  • The object holds an array of translations ->getTranslations() and ->getTranslation($locale) are available
  • Locale is a dead simple string of 2 chars
  • The function has access to an array of locales ordered by priority
  • The locale parameter should be priority #1, otherwise the array of priorities is used to get the correct locale.

class Testing {
parameters:
...
mailer_transport: smtp
mailer_host: 'localhost:1025'
mailer_user: null
mailer_password: null
@jverdeyen
jverdeyen / ubuntu.preseed
Last active August 29, 2015 14:16
ubuntu.preseed
# Webfolks KVM preseed
d-i debian-installer/splash boolean false
### Keyboard selection ###
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/variantcode string
### Locale ###
d-i debian-installer/locale string en_US.UTF-8