Skip to content

Instantly share code, notes, and snippets.

View KaduNovoK's full-sized avatar

Carlos Eduardo Rodrigues dos Santos KaduNovoK

View GitHub Profile
@KaduNovoK
KaduNovoK / ps1
Created October 15, 2014 13:46
ps1 - ubuntu terminal
PS1='\[\033[0;37m\][\t]\[\033[0;32m\][\u]\[\033[31m\][\h]`git branch 2>/dev/null | grep \* | head -1 | sed "s/\* //g" | awk "{ print \"[ \"\\\$1 \" ]\" }"` \[\033[1;33m\]\w\a\[\033[0m\]\n\$ '
@KaduNovoK
KaduNovoK / UserRepository.php
Created October 20, 2014 18:06
Exemplo de uso do Query Builder em outras Queries do mesmo Repositório
<?php
// some code...
/**
* Query Builder to get all users with age > $age
*
* @param int $age
*
* @return Doctrine\ORM\QueryBuilder $qb
@KaduNovoK
KaduNovoK / rightway-symfony
Created October 27, 2014 17:33
symfony 2 - best practices
01 - Always use Composer to install Symfony
test: $ composer --version
install: $ curl -sS https:://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
02 - Creating a application
$ cd projects/
$ composer create-project symfony/framework-standard-edition blog/
$ cd blog/
@KaduNovoK
KaduNovoK / AnyRepository.php
Created November 6, 2014 13:22
DateTime use sample into symfony2 with Doctrine
<?php
//... some code
public function findByFieldIntoInterval(\DateTime $earlyDate, \DateTime $lateDate)
{
$qb = $this->createQueryBuilder('e');
$qb->where($qb->expr()->between('e.field', ':earlyDate', ':lateDate'));
@KaduNovoK
KaduNovoK / FibonacciCommand.php
Created March 12, 2015 18:21
Symfony console
<?php
namespace HunterBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;

Test

Test

TDD Resume

  1. Red
  2. Green
  3. Refactor (but stay green!)

Step by step

1. Write the smallest and simplest test possible

Each function should test just one use case