Skip to content

Instantly share code, notes, and snippets.

View pedroborges's full-sized avatar
🏠
Working from home

Pedro Borges pedroborges

🏠
Working from home
  • Brazil
View GitHub Profile
@pedroborges
pedroborges / rm-docker-images.sh
Created January 28, 2014 16:58
Removes all Docker containers then all its images.
#!/bin/bash
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
@pedroborges
pedroborges / config.hdf
Created February 1, 2014 19:12
HHVM config.hdf for Laravel
Server {
Port = 80
SourceRoot = /var/www/public/
}
VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
@pedroborges
pedroborges / enum.php
Created February 3, 2014 12:42
An alternative to ENUM in DB.
// Taken from: https://laracasts.com/forum/88-how-do-you-handle-enums
class OrderStatus implements Enum
{
const FRAUD = -2;
const CANCELLED = -1;
const UNPAID = 0;
const RECEIVED = 1;
const PARTIALLY_SHIPPED = 10;
const SHIPPED = 20;
/* Generate unique values with the UUID() function. */
UPDATE table SET column = UUID();
/* Optionally strip the hyphens from the values. */
UPDATE table SET column = REPLACE(UUID(), '-', '');
<?php
class Collection {
protected $collection;
public function add($item)
{
if (is_array($item))
{
@pedroborges
pedroborges / phpspec_cheatsheet.md
Last active April 23, 2016 09:27
From Marcello Duarte's PhpSpec 2.0 ilustrated by examples slides (http://pt.slideshare.net/marcello.duarte/phpspec-20-ilustrated-by-examples)

PhpSpec 2.0 Cheat Sheet

Object: $result ($this)

Expectation: should or shouldNot

Matcher: Be...()

Types of Matchers:

# Fix encoding error with Jekyll
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Fix Ruby Gems path
if which ruby >/dev/null && which gem >/dev/null; then
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
@pedroborges
pedroborges / gist:11330542
Created April 26, 2014 20:43
Optimize SQL queries when updating a bunch of records at once. (From: https://laracasts.com/forum/1442-best-way-to-update-400-database-rows)
<?php
$checked = [];
$unchecked = [];
foreach($input as $id => $enabled)
{
if ($enabled) $checked[] = $id;
else $unchecked[] = $id;
}
@pedroborges
pedroborges / sample.php
Last active August 29, 2015 14:01
Invoking methods dynamically using foreach,
<?php
// Inside some class...
$names = ['Event', 'Exception', 'Routing'];
foreach ($names as $name)
{
$this->{"method{$name}"}();
}

Sobre o Laravel Forge

O Forge é um projeto pessoal do Taylor, resultado de 9 meses de trabalho. O plano inicial era lançá-lo em Dezembro de 2013, próximo do lançamento da versão 4.1 do Laravel.

Desenvolver o Forge levou mais tempo do que a versão inicial do Laravel, que levou 3 meses — se não me engano. O Taylor achava que apenas ele usaria o Laravel.

Ele gastou cerca de 18h por semana, às vezes menos. 2h por noite + 4h extras no final de semana. Sua esposa dorme por volta das 22h e ele trabalha até meia-noite. Geralmente ele dorme até 7:45h. Ele disse que precisa de pelo menos 7h de sono para render bem.

O change log da versão 4.1 do Laravel é [4x ma