Skip to content

Instantly share code, notes, and snippets.

View jverdeyen's full-sized avatar

Joeri Verdeyen jverdeyen

View GitHub Profile
<?php
define('TEST_KEY', 'are_we_glued');
$redis = new Redis();
try {
$redis->connect('localhost', 6379);
$redis->set(TEST_KEY, 'yes');
$glueStatus = $redis->get(TEST_KEY);
if ($glueStatus) {
$testKey = TEST_KEY;
echo "Glued with the Redis key value store:" . PHP_EOL;
@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
parameters:
...
mailer_transport: smtp
mailer_host: 'localhost:1025'
mailer_user: null
mailer_password: null
@jverdeyen
jverdeyen / deployer_defaults_main.yml
Last active December 29, 2021 16:16
Ansible role to push deploy key onto Gitlab instance
---
deployer_user: deploy
deployer_group: deploy
deployer_groups: ['admin']
deployer_user_ssh_key_file: .ssh/id_rsa
deployer_gitlab_api: https://[gitlab-domain]/api/v3/
deployer_gitlab_token: [gitlab-token-for-specific-user]
deployer_gitlab_key_title: "{{ ansible_hostname }}_deployer"
@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 {
@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 / 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: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 / 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);