Skip to content

Instantly share code, notes, and snippets.

View KaduNovoK's full-sized avatar

Carlos Eduardo Rodrigues dos Santos KaduNovoK

View GitHub Profile

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

Test

Test

@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;
@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 / 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 / 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 / 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 / phone.js
Last active August 29, 2015 14:07
[JQuery] Phone and Cellphone Mask
var $phone = $("#fos_user_registration_form_phone");
var maskOptions = {onKeyPress: function(phone) {
var masks = ['(00) 0000-0000', '(00) 00000-0000'];
mask = phone.match(/^\([0-9]{2}\) 9/g)
? masks[1]
: masks[0];
$phone.mask(mask, this);
}};
$phone.mask('(00) 0000-0000', maskOptions);
@KaduNovoK
KaduNovoK / json_reader.php
Created July 10, 2014 19:58
Proxy and json reader files.
<?php
$url = "http://localhost/labs/0100/02.php?url=http://ip.jsontest.com/";
$jsonContent = file_get_contents($url);
$jsonObject = json_decode($jsonContent);
var_dump($jsonObject);
echo($jsonObject->ip);
@KaduNovoK
KaduNovoK / screen_setup.sh
Created June 25, 2014 10:45
Set my second screen resolution
#!/bin/bash
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA1 "1920x1080_60.00"
xrandr --output VGA1 --mode "1920x1080_60.00"