Skip to content

Instantly share code, notes, and snippets.

View vahid-almasi's full-sized avatar

Vahid Almasi vahid-almasi

  • Berlin, germany
View GitHub Profile
# removing bash warning in mac
export BASH_SILENCE_DEPRECATION_WARNING=1
# show git branch
function ps1() {
local spacing=""
if [ -d .git ]; then
branch_name=$(git rev-parse --abbrev-ref HEAD)
[ ${#branch_name} -gt 10 ] && dots="..." || dots=""
spacing="${branch_name::10}$dots |"
# first start your vpn :) or change your DNS
sudo apt update &&
sudo apt upgrade &&
sudo apt install curl wget make git nginx python-pip vim unrar &&
<?php
class Person {
public function read(BookInterface $book)
{
$book->open();
$book->turnPage();
}
}
<?php
class eReaderAdapter implements BookInterface {
private $reader;
public function __construct(eReaderInterface $reader)
{
$this->reader = $reader;
}
public function open()
{
<?php
class Kindle implements eReaderInterface {
public function turnOn()
{
var_dump('turn the Kindle on');
}
public function pressNextButton()
<?php
interface eReaderInterface {
public function turnOn();
public function pressNextButton();
}
<?php
class Book implements BookInterface {
public function open()
{
var_dump('opening the paper book.');
}
public function turnPage()
{
var_dump('turning the page of the paper book.');
<?php
class CarService
{
protected $cost = 20;
protected $description = 'Basic inspection';
public function getCost()
{
return $this->cost;
<?php
interface CarService
{
public function getCost();
public function getDescription();
}
class BasicInspection implements CarService
<?php
interface CarService
{
public function getCost();
}
class BasicInspection implements CarService
{
public function getCost()