Skip to content

Instantly share code, notes, and snippets.

View xthiago's full-sized avatar

Thiago Rodrigues (xthiago) xthiago

View GitHub Profile
@xthiago
xthiago / AppKernel.php
Last active August 29, 2015 14:13 — forked from merk/AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
// ....
protected function getKernelParameters()
<?php
class LayoutExtension extends \Twig_Extension
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'yolo';
@xthiago
xthiago / coalesce-retornar-um-valor-ao-inves-de-null.md
Last active August 29, 2015 14:05
SQL COALESCE - Retornar um valor ao invés de NULL

Ao invés de fazer uma querie enorme com CASE-THEN-ELSE, usar a função COALESCE. Ela retorna o primeiro argumento NOT NULL.

Isso:

SELECT CASE WHEN evento.realizado_em IS NULL THEN '' ELSE evento.realizado_em END FROM TableA

Vira isso:

<?php
namespace My\Custom\Doctrine2\Function;
/**
* RandFunction ::= "RAND" "(" ")"
*/
class Rand extends FunctionNode
{
public function parse(\Doctrine\ORM\Query\Parser $parser)
@xthiago
xthiago / .bashrc
Created April 23, 2014 11:21 — forked from git-cd/.bashrc
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\$ '
@xthiago
xthiago / limpar-logs.sh
Created March 12, 2014 19:09
Script para apagar logs e tmp
#! /bin/sh
# apaga tmp
find /tmp/ -type f -print -delete
# apaga logs compactados
find /var/log/ -type f -iname *.gz -print -delete
# zera conteudo dos logs
find /var/log/ -type f -print -exec truncate -s 0 {} \;
@xthiago
xthiago / gist:8454196
Created January 16, 2014 12:27
Exibir no bash o nome do branch do git (colorido)
function git_branch_name() {
git branch 2>/dev/null | grep -e '^*' | sed -E 's/^\* (.+)$/(\1) /'
}
function show_colored_git_branch_in_prompt() {
PS1="\[\033[01;32m\]\u@\h:\[\033[01;34m\]\w\[\033[31m\]\$(git_branch_name)\[\033[m\]$ "
}
show_colored_git_branch_in_prompt
Vagrant::Config.run do |config|
config.vm.customize do |vm|
vm.name = "PHP dev"
vm.memory_size = 512
end
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu32"
# Assign this VM to a host only network IP, allowing you to access it