Skip to content

Instantly share code, notes, and snippets.

Avatar

Toni Uebernickel havvg

View GitHub Profile
@havvg
havvg / services.yml
Created Oct 17, 2014
TraceableEventDispatcher using service decorator
View services.yml
services:
event_dispatcher:
class: Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
arguments:
- @container
traceable_event_dispatcher:
public: false
class: Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher
decorates: event_dispatcher
@havvg
havvg / CommandContext.php
Created May 30, 2015
BDD: Create User Command
View CommandContext.php
<?php
namespace Trnd\Behat\Context\Console;
use Behat\Behat\Context\Context;
use Mockery\MockInterface;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
View ExampleTaskTest.php
<?php
require_once(dirname(__FILE__) . '/../bootstrap/task.php');
# load fixtures of this plugin
$propelData->loadData(sfConfig::get('sf_plugins_dir') . '/yetAnotherPlugin/data/fixtures');
$limeTest = new lime_test(1, new lime_output_color());
$task = new ExampleTask($dispatcher, $formatter);
$task->run(array(), array());
View database.php
<?php
/**
* Cake database configuration for git repositories.
*
* It automatically detects the current working branch and uses the appropriate database connection.
* Fallback is given by the "default" entry.
*/
class DATABASE_CONFIG {
/**
@havvg
havvg / JsonpFilter.php
Created Dec 15, 2010
A simple JSONP filter for symfony web applications.
View JsonpFilter.php
<?php
class JsonpFilter extends sfFilter
{
public function execute($filterChain)
{
// nothing to do before the action is called
$filterChain->execute();
if (($response = $this->getContext()->getResponse()) instanceof sfWebResponse and ($request = $this->getContext()->getRequest()) instanceof sfWebRequest)
@havvg
havvg / TrafficLights.pde
Created Jan 6, 2011
Basic Arduino sketch implementing two cross linked traffic lights.
View TrafficLights.pde
class TrafficLight
{
/**
* Accessors for traffic lights.
*
* Each of these values define the index, where to find a given part of the respective traffic light.
*/
static const int green = 0;
static const int yellow = 1;
static const int red = 2;
@havvg
havvg / cctrlworker
Created Feb 5, 2011
A simple wrapper for the new cloudcontrol API provided by cctrlapp version 1.0.0, showing current workers and their command line information.
View cctrlworker
#!/bin/bash
APP=$1
for worker in `cctrlapp $APP worker | grep -ve '^Workers' | grep -ve '^ nr\.' | tr -s " " | cut -f3 -d " "`;
do
cctrlapp $APP worker $worker | grep -v "There is no such worker for this app_name/deployment_name."
done;
@havvg
havvg / 004_ExampleMigration.php
Created Feb 12, 2011
an example migration file for sfCloudControlPlugin using sfPropelMigrationsLightPlugin
View 004_ExampleMigration.php
<?php
/**
* Migrations between versions 003 and 004.
*/
class Migration004 extends sfMigration
{
/**
* Migrate up to version 004.
*/
View BaseFormFilterPropel.class.php
<?php
abstract class BaseFormFilterPropel extends sfFormFilterPropel
{
public function setup()
{
parent::setup();
foreach ($this->getFields() as $eachFieldName => $eachFieldType)
{
@havvg
havvg / ExampleTest.php
Created Mar 31, 2011
An adapter implementation used by the sfWebBrowserPlugin for testing purposes.
View ExampleTest.php
<?php
/**
* A simple example test case using the sfTestAdapter.
*
* @author "Toni Uebernickel" <tuebernickel@gmail.com>
*/
class ExampleTest extends PHPUnit_Framework_TestCase
{
/**