Skip to content

Instantly share code, notes, and snippets.

View rcubitto's full-sized avatar

raul rcubitto

View GitHub Profile
@rcubitto
rcubitto / CategoryFactory.php
Last active March 12, 2019 09:41
Model factories chain example
<?php
use Faker\Generator as Faker;
$factory->define(App\Category::class, function (Faker $faker) {
return [
'user_id' => factory(\App\User::class),
];
});
@rcubitto
rcubitto / FileLoggable.php
Last active January 9, 2019 18:52
Class for "logging" data into a buffer in memory and then save all the logs into a file.
<?php
namespace App\Traits;
use App\Facades\FileLogger;
use Carbon\Carbon;
/**
* Makes easier the action of beginning/ending a file log.
*
@rcubitto
rcubitto / carbon_macro_age.php
Created August 23, 2018 15:18
Get the age based on a given date
<?php
\Illuminate\Support\Carbon::macro('age', function ($date) {
return $this->diff($this->parse($date))->format('%y');
});
@rcubitto
rcubitto / monitor.sh
Last active May 29, 2018 17:15
Monitor Nginx, PHP, and MySQL and notify via Slack
#!/bin/bash
info="Services restarted: "
# Nginx
ps -ef | grep nginx | grep -v grep > /dev/null
if [ $? != 0 ]
then
sudo service nginx start > /dev/null
info="$info Nginx, "
@rcubitto
rcubitto / aliases.sh
Last active March 19, 2020 03:45
Aliases
alias reload="source ~/.zshrc"
alias config="code ~/.zshrc"
# git
alias g="git"
alias gs="g status"
alias ga="g add"
alias gc="g commit -m"
alias gac="ga . && gc"
alias gb="g branch"
@rcubitto
rcubitto / heartland_tokenize.php
Created February 16, 2018 18:22
Heartland Tokenize Card
<?php
$card = new \HpsCreditCard;
$card->number = '4111111111111111'; // visa testing card
$card->cvv = '123';
$card->expMonth = '10';
$card->expYear = '2010'; // expired!
$address = new \HpsAddress;
$address->address = '265 Peachtree Center Ave NE';
@rcubitto
rcubitto / lets_encrypt_cert.sh
Created January 23, 2018 23:51
Add SSL to a site using Let's Encrypt
# taken from https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 with a tweak
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
# you should have your site's config file already created. /etc/nginx/sites-avalable/{domain.com}
# allow HTTPS through Firewall
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
@rcubitto
rcubitto / valet-part-2.sh
Created January 10, 2017 12:34
Configure subdomains in Laravel Valet - Part 2
cd ~/.valet/Sites
ln -s example api.example
@rcubitto
rcubitto / valet-part-1.sh
Last active January 10, 2017 12:33
Configure subdomains in Laravel Valet - Part 1
cd /path/to/project
valet link api.example