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 / 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 / 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 / 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>
@ricardoaugusto
ricardoaugusto / mysqlworkbench.sh
Last active December 10, 2019 19:38
Link mysqldump on macOS Catalina (requires MySQL Workbench)
ln -s /Applications/MySQLWorkbench.app/Contents/MacOS/mysql /usr/local/bin/mysql
ln -s /Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump /usr/local/bin/mysqldump
@ricardoaugusto
ricardoaugusto / html_scrapper.py
Created March 20, 2020 14:21
Python 3 HTML scrapper
from urllib.request import urlopen
link = 'https://example.net'
f = urlopen(link)
output = f.read()
print(output)