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
// learnreact.com
// http://codepen.io/anon/pen/QdBYBK
const Greetings = ({ Tag, age, name, ...restProps }) => {
let element = null
const handleClick = () => alert(element.tagName)
return (
<Tag
@pedroborges
pedroborges / Alert.vue
Created December 16, 2015 19:35 — forked from martinlindhe/Alert.vue
jasmine + karma for vue test
<style>
.Alert {
padding: 2em;
}
.Alert-Success {
border: 10px solid green;
}
.Alert-Error {
border: 10px solid red;
}

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

@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}"}();
}
@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;
}
# 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 / 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:

<?php
class Collection {
protected $collection;
public function add($item)
{
if (is_array($item))
{
/* 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(), '-', '');
@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;