Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
@lyrixx
lyrixx / symfony-and-melody.php
Last active August 29, 2015 14:13
Symfony in a single file, for melody
<?php
<<<CONFIG
packages:
- "symfony/symfony: 2.7.x-dev@dev"
CONFIG;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
@masak
masak / gist:943237
Created April 26, 2011 21:39
Trying out CQRS and ES for a day
Last Friday, Jonathan Worthington and I (Carl Mäsak) decided to get our feet
wet with CQRS and event sourcing. The toy project we settled on: a simple but
realistic web site for two-player board games.
In this post, I summarize how things went.
## Architect meets domain expert
Since there were only the two of us, I took the role of the domain expert, and
Jonathan took the role of the architect. He expertly teased a model out of
@MrBretticus
MrBretticus / gist:1923936
Created February 27, 2012 13:56
What I learnt, or my notes, from "In The Brain of Greg Young: CQRS and Event Sourcing - the Business Perspective"
Notes based on Greg Young's business perspective presentation
http://skillsmatter.com/podcast/agile-testing/greg-young-cqrs-event-sourcing-the-business-perspective
With a standard structural model we make assumptions of what the business may or may not want in the future. How can we presume to know what to track and what to discard.
CQRS/ES benefits:
* Captures behaviour explicitly, events carry the intent of users.
* We can derive any possible model about data that may be required.
* Allows domain experts and users to look at today in any way they may want to.
@jmikola
jmikola / RouterRequestContextPass.php
Created March 6, 2012 07:47
A cure for "localhost" appearing in absolute URL's when rendering a template from the Symfony2 CLI
<?php
namespace Application\ExerciseBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Overrides the default host for the Router's RequestContext service.
*
@masak
masak / five-rules.txt
Created March 9, 2012 20:26
Five CQRS rules
1. Your application consists of three parts. Information always flows
"clockwise": clients, write side, read sides. Clients send Commands
to write side. Write side publishes Events to read sides. Read sides
reply to Queries for client.
2. The interesting logic is all in the write side, but your design may
consist *only* of the totality of Commands, Events, and Queries.
3. Each Command or Event has exactly one aggregate that it's acting on,
identified by unique aggregate ID. There need not be a one-to-one
@jmikola
jmikola / Document.php
Created May 18, 2012 15:51
Doctrine MongoDB ODM flush benchmark
<?php
use Doctrine\ODM\MongoDB\Mapping\Annotations as Mongo;
/** @Mongo\Document(collection="documents") */
class Document
{
/** @Mongo\Id */
public $id;
@nickleefly
nickleefly / CR_LF.md
Last active December 19, 2015 10:09
Linux command oneline sed oneline, awd oneline, perl oneline The Carriage Return and Line Feed Characters -- How They Affect Text Files On Different Platforms How do I convert between Unix and Windows text files?

Permalink

danielmiessler.com | study | crlf

If you're like I used to be, you always have trouble remembering the difference between how Windows and Linux terminate lines in text files. Does Windows add the extra stuff, or does Linux? What exactly is the extra stuff? How do I get the stuff out?

Well, hopefully by the end of this you'll be taken care of once and for all.

The Characters

@jaymecd
jaymecd / GitSetup.md
Last active December 25, 2015 02:09
GIT setup

Global git setup

$ curl -sSL https://gist.github.com/jaymecd/6900705/raw/gitconfig | sudo tee /etc/gitconfig

$ curl -sSL https://gist.github.com/jaymecd/6900705/raw/gitignore | sudo tee /etc/gitignore
<?php
namespace Psr\Log;
interface Loggable
{
public function getContext();
}
class Car implements Loggable
@dbu
dbu / ImageType.php
Created March 12, 2013 11:03
i needed a form type that determines based on the bound data if it should be required or not (to make file upload required if we create a new entity, but optional when editing the entity with the file. as this happens in a embedded sonata, i have no way of knowing the actual data when creating the form in the form builder. this is what i came up…
<?php
class ImageType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['required_auto'] && ! $options['required']) {
$builder->addEventListener(\Symfony\Component\Form\FormEvents::PRE_SET_DATA, array($this, 'determineRequired'));
}