Skip to content

Instantly share code, notes, and snippets.

View morales2k's full-sized avatar
🏠
Working from home

Jorge Morales morales2k

🏠
Working from home
View GitHub Profile
@morales2k
morales2k / googlebot-ipv4.txt
Last active March 20, 2024 20:32
Cloudflare WAF rule to match GoogleBot & Special Crawlers IpV4 and IpV6
(ip.src in {192.178.5.0/27 34.100.182.96/28 34.101.50.144/28 34.118.254.0/28 34.118.66.0/28 34.126.178.96/28 34.146.150.144/28 34.147.110.144/28 34.151.74.144/28 34.152.50.64/28 34.154.114.144/28 34.155.98.32/28 34.165.18.176/28 34.175.160.64/28 34.176.130.16/28 34.22.85.0/27 34.64.82.64/28 34.65.242.112/28 34.80.50.80/28 34.88.194.0/28 34.89.10.80/28 34.89.198.80/28 34.96.162.48/28 35.247.243.240/28 66.249.64.0/27 66.249.64.128/27 66.249.64.160/27 66.249.64.192/27 66.249.64.224/27 66.249.64.32/27 66.249.64.64/27 66.249.64.96/27 66.249.65.0/27 66.249.65.160/27 66.249.65.192/27 66.249.65.224/27 66.249.65.32/27 66.249.65.64/27 66.249.65.96/27 66.249.66.0/27 66.249.66.128/27 66.249.66.160/27 66.249.66.192/27 66.249.66.32/27 66.249.66.64/27 66.249.66.96/27 66.249.68.0/27 66.249.68.32/27 66.249.68.64/27 66.249.69.0/27 66.249.69.128/27 66.249.69.160/27 66.249.69.192/27 66.249.69.224/27 66.249.69.32/27 66.249.69.64/27 66.249.69.96/27 66.249.70.0/27 66.249.70.128/27 66.249.70.160/27 66.249.70.192/27 66.249.70.224/27
@morales2k
morales2k / pueblos.php
Last active October 19, 2021 21:32
Puerto Rico municipalities in a Laravel config friendly format.
<?php
return [
'adjuntas' => [
'label' => 'Adjuntas',
],
'aguada' => [
'label' => 'Aguada',
],
'aguadilla' => [
@morales2k
morales2k / pueblos.php
Created August 30, 2021 22:20
Puerto Rico municipalities in a Laravel config friendly format. With snake_cased array keys with a label entry for display on each item in the array.
<?php
return [
'adjuntas' => [
'label' => 'Adjuntas',
],
'aguada' => [
'label' => 'Aguada',
],
'aguadilla' => [
@morales2k
morales2k / .bashrc
Created August 19, 2021 17:28
.bashrc loadnvmrc function Add after nvm init inside your bashrc or bash_profile file. (for linux based nvm executable)
# place this after nvm initialization!
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
@morales2k
morales2k / posts_from_page.php
Last active November 18, 2020 17:06
Get Facebook public posts from a page. This requires facebook's php sdk, and a properly registered app.
<?php
function make_links($text, $class='', $target='_blank'){
return preg_replace('!((http\:\/\/|ftp\:\/\/|https\:\/\/)|www\.)([-a-zA-Zа-яА-Я0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?!ism', '<a class="'.$class.'" href="//$3" target="'.$target.'">$1$3</a>', $text);
}
define("APP_ID", 'xxxxxxxxxxxxxxxxxxx');
define("APP_SECRET",'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define("PAGE_ID",'elnuevodia');
$config = array(
'appId' => APP_ID,
@morales2k
morales2k / .profile
Created December 17, 2019 14:07
Clear laradock workspace laravel project cache without keeping the terminal bound inside the workspace at the end.
alias cddocker='cd ~/laradock' #path to your laradock folder
# Get on your workspace move to the laravel directory and invoke artisan commands to clear
# caches without keeping your terminal inside the workspace at the end.
function wipe-caches() {
( cddocker && docker-compose exec --user laradock workspace bash -c "cd laravel && php artisan config:clear && php artisan cache:clear" )
}
@morales2k
morales2k / .profile
Last active November 6, 2019 13:28
Little bash script you can pass args to and test cors headers with.
#same functionality in a bash profile function
function cors-test() {
ORIGIN=$1
URI=$2
METHOD=$3
if [ -z "$3" ] && [ -z "$METHOD" ]; then
echo -e "\033[0;33mSince you did not provide a method, the default GET will be used.\nYou can provide a third param to specify the method\n(to use with the curl -X option).\033[1;33m\033[0m\n"
METHOD="-X ${METHOD}"
fi

Keybase proof

I hereby claim:

  • I am morales2k on github.
  • I am morales2k (https://keybase.io/morales2k) on keybase.
  • I have a public key whose fingerprint is 1AFA F283 1358 C560 6CEA B2CE FE71 D6F5 43DC 3CF7

To claim this, I am signing this object:

@morales2k
morales2k / AppServiceProvider.php
Last active May 5, 2018 22:52
Some custom Laravel validation rules
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
class AppServiceProvider extends ServiceProvider
{
/**
@morales2k
morales2k / Homestead.yaml
Last active December 14, 2017 22:49
For use with Laravel Homestead. Set a server_name to add for ngrok (or similar services, but my useccase is ngrok.) With this type of setup, I can use Homestead globally (only one vm for many sites) and add an additional domain for ngrok on the sites I wish to load it with.
---
ip: "10.10.192.168"
memory: 2048
cpus: 1
provider: virtualbox
name: homestead-7
authorize: ~/.ssh/id_rsa.pub
keys: