Skip to content

Instantly share code, notes, and snippets.

View ricardoaugusto's full-sized avatar
🥽
Focusing

Ricardo Augusto ricardoaugusto

🥽
Focusing
View GitHub Profile
@ricardoaugusto
ricardoaugusto / distance-between-two-points.php
Last active May 7, 2016 13:46
Haversine Distance between two points ( latitude, longitude )
<?php
/**
* Distance between two points
*
* @param float $lat1 Latitude 1
* @param float $lng1 Longitude 1
* @param float $lat2 Latitude 2
* @param float $lng2 Longitude 2
* @param string $unit [mi|km] miles|kilometers
@ricardoaugusto
ricardoaugusto / builder.php
Last active May 10, 2017 17:14
Builder Design Pattern
abstract class AbstractPageBuilder {
abstract function getPage();
}
abstract class AbstractPageDirector {
abstract function __construct(AbstractPageBuilder $builder_in);
abstract function buildPage();
abstract function getPage();
}
@ricardoaugusto
ricardoaugusto / decorator.php
Created May 10, 2017 17:14
Decorator Design Pattern
class Book {
private $author;
private $title;
function __construct($title_in, $author_in) {
$this->author = $author_in;
$this->title = $title_in;
}
function getAuthor() {
return $this->author;
}
<?php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'homestead' == gethostname() ? 'localhost' : '127.0.0.1'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'port' => env('DB_PORT', 'homestead' == gethostname() ? null : 33060),
'charset' => 'utf8mb4',
@ricardoaugusto
ricardoaugusto / hasManyThrough.php
Last active April 9, 2020 14:07
Laravel HasManyThrough explanation
class Current extends Model
{
public function final()
{
return $this->hasManyThrough(
'App\Final',
'App\Intermediate',
'intermediate_id', // Foreign key on Intermediate
'final_id', // Foreign key on Final
'id', // Local key on Current
@ricardoaugusto
ricardoaugusto / fix.md
Created March 11, 2018 12:34
Increases the upload size on Laravel Nginx installation, fixes the 413 request entity too large and PostTooLargeException

Edit the file php.ini (or PHP FPM if on Forge):

memory_limit = 512M

post_max_size = 20M

upload_max_filesize = 20M
@ricardoaugusto
ricardoaugusto / customize-laravel-notification-email.md
Last active October 16, 2019 20:16
Customize Laravel 5.6 notification email
  1. Run php artisan make:notification MyResetPassword to create a Notification Class MyResetPassword at app/Notifications
  2. add use App\Notifications\MyResetPassword; to the User model
  3. Add this method to User model:
public function sendPasswordResetNotification($token)
{
    $this->notify(new MyResetPassword($token));
}
@ricardoaugusto
ricardoaugusto / sketchRenameLayerStyle.workflow
Created July 31, 2018 21:09
Rename Layer Styles on Sketch app
on run {input, parameters}
activate application "Sketch"
repeat 9 times
tell application "System Events"
key code 76
key code 123 using {command down}
key code 124 using {shift down, option down}
key code 124 using {shift down}
@ricardoaugusto
ricardoaugusto / find-kill.sh
Created December 3, 2019 11:13
Find and kill a process locking port 8000 on macOS Terminal
sudo lsof -i tcp:8000
kill -9 PID
@ricardoaugusto
ricardoaugusto / gist:d480754e3ddab8c6af25742377959e1e
Created December 4, 2019 14:37
Make Git forget a file that was tracked and now is ignored
git update-index --assume-unchanged <file>