Skip to content

Instantly share code, notes, and snippets.

View joaorobertopb's full-sized avatar
💻
Coding

João Roberto P. Borges joaorobertopb

💻
Coding
View GitHub Profile
@joaorobertopb
joaorobertopb / install-screenfetch.md
Last active January 12, 2019 17:18
Install screenfetch on Ubuntu

1 - Download the latest version from: wget -O screenfetch-dev https://git.io/vaHfR

2 - Rename the screenfetch-dev to screenfetch file: mv screenfetch-dev screenfetch

3 - Apply execution permission: chmod +x screenfetch

4 - Move the screenfetch to bin directory:

@joaorobertopb
joaorobertopb / install-docker-ubuntu-18-04.sh
Last active January 11, 2019 17:46
Install docker on Ubuntu 18.04
#!/bin/sh
# Update the apt package list.
sudo apt-get update -y
# Install Docker's package dependencies.
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
@joaorobertopb
joaorobertopb / dip-solid-example.php
Created January 5, 2019 20:18
Exemplo de código PHP que utiliza o Dependecy Inversion Principle do SOLID.
<?php
interface DBConnectionInterface
{
public function connect();
}
class MySQLConnection implements DBConnectionInterface
{
@joaorobertopb
joaorobertopb / dependency-injection-example.php
Last active January 5, 2019 19:05
Exemplo de código PHP com injeção de dependência via construtor.
<?php
use MySQLConnection;
class PasswordReminder
{
private $dbConnection;
public function __construct(MySQLConnection $dbConnection)
{
@joaorobertopb
joaorobertopb / acouple-code.php
Last active January 5, 2019 20:12
Exemplo de código PHP com alto nível de acoplamento.
<?php
use MySQLConnection;
class PasswordReminder
{
private $dbConnection;
public function __construct()
{
@joaorobertopb
joaorobertopb / isp-solid-example.php
Created January 5, 2019 03:32
Exemplo de código PHP que usa o princípio de segregação das interfaces do SOLID.
<?php
interface Aves
{
public function setLocalizacao($longitude, $latitude);
public function renderizar();
}
interface AvesQueVoam extends Aves
{
@joaorobertopb
joaorobertopb / isp-solid-violate.php
Last active January 5, 2019 03:20
Exemplo de código PHP que viola o princípio de segregação das interfaces do SOLID.
<?php
interface Aves
{
public function setLocalizacao($longitude, $latitude);
public function setAltitude($altitude);
public function renderizar();
}
class Papagaio implements Aves
@joaorobertopb
joaorobertopb / lsp-solid-example.php
Created January 5, 2019 01:23
Exemplo em PHP da utilização do princípio SOLID de substituição de Liskov.
<?php
class A
{
public function getNome()
{
echo 'Meu nome é A';
}
}
@joaorobertopb
joaorobertopb / lsp-solid-violate.php
Created January 4, 2019 20:21
Exemplos em PHP de violação do princípio de Liskov do SOLID.
<?php
# - Sobrescrevendo um método que não faz nada...
class Voluntario extends ContratoDeTrabalho
{
public function remuneracao()
{
// não faz nada
}
}
@joaorobertopb
joaorobertopb / ocp-solid-example.php
Created January 4, 2019 03:10
Exemplo em PHP da utilização do princípio Aberto-Fechado ( Open-Closed ) do SOLID
<?php
interface Remuneravel
{
public function remuneracao();
}
class ContratoClt implements Remuneravel
{
public function remuneracao()