Skip to content

Instantly share code, notes, and snippets.

View lucasaffonso0's full-sized avatar

José Lucas lucasaffonso0

View GitHub Profile
@lucasaffonso0
lucasaffonso0 / export_env_from_ecs.py
Created April 2, 2025 14:34
Get the environment variables from an ECS task definition and export them to a .env file
import boto3
# Defina suas credenciais da AWS aqui (⚠️ Evite hardcode em produção)
AWS_ACCESS_KEY = ""
AWS_SECRET_KEY = ""
AWS_REGION = ""
TASK_DEFINITION_NAME = ""
# Criar sessão do boto3 com credenciais manuais
session = boto3.Session(
aws_access_key_id=AWS_ACCESS_KEY,
@lucasaffonso0
lucasaffonso0 / user_exporter.sh
Created April 29, 2024 12:05
Exporter for Prometheus that exposes CPU and memory consumption metrics per operating system user
#!/bin/bash
# Install python3
sudo apt-get install python3 -y
# Install pip3
sudo apt install python3-pip -y
# Install prometheus_client
pip3 install prometheus_client
@lucasaffonso0
lucasaffonso0 / send_mail.php
Created April 4, 2024 15:00
Send email via SMTP where applications only allow phpmailer Configure in php.ini: sendmail_path = /usr/bin/php -f /etc/scripts/send_mail.php
<?php
// Includes PHPMailer autoload
require '/etc/scripts/PHPMailer/src/PHPMailer.php';
require '/etc/scripts/PHPMailer/src/SMTP.php';
require '/etc/scripts/PHPMailer/src/Exception.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
@lucasaffonso0
lucasaffonso0 / security.conf
Created January 10, 2024 20:13
Security configuration for nginx running wordpress sites
if ($http_user_agent ~* (thesis-research-bot|Amazonbot|Turnitin|Go-http-client|Blackbox|Netsparker|Acunetix|Havij|owasp-zap|AppScan|UptimeRobot|serpstatbot|DuckDuckBot|DuckDuckBot-Https|YandexBot|OpenindexSpider|ZoominfoBot|bingbot|sqlmap|CrowdTanglebot|DataForSeoBot|omgili|trendictionbot|MJ12bot|MegaIndex|PetalBot|aspiegel|trendkite-akashic-crawler|AhrefsBot|SemrushBot|Seekport|AwarioRssBot|AwarioBot|Pinterestbot|UptimeRobot|SEOkicks|DotBot|BLEXBot|crawler|Semanticbot|msnbot|EchoboxBot|mediacloud|Applebot|SeekportBot|Squidbot|SentiBot|CensysInspect|SeznamBot|AwarioSmartBot)) {
return 403;
}
if ($request_uri ~* "onload.*alert.*document.domain") {
return 403;
}
if ($request_uri ~* '\?aam-media') {
return 403;
@lucasaffonso0
lucasaffonso0 / backup_percona_8.sh
Created September 12, 2023 17:21
backup percona mysql 8
#!/bin/bash
date=`date +%Y-%m-%d`
name=`hostname`
WEBHOOK_URL=''
cleanup() {
curl -H "Content-Type: application/json" -X POST -d "{\"content\":\":x: $(hostname)-$date: Backup não foi finalizado!\"}" $WEBHOOK_URL
exit 1
}
trap cleanup SIGINT SIGTERM
@lucasaffonso0
lucasaffonso0 / fixbitbucket.sh
Created June 21, 2023 13:22
Update your Bitbucket Cloud SSH Host Keys
#!/bin/bash
config_file=/etc/ssh/ssh_config
if grep -q "# StrictHostKeyChecking ask" "$config_file"; then
# Substitui a linha comentada pela linha descomentada
sed -i 's/# StrictHostKeyChecking ask/StrictHostKeyChecking no/' "$config_file"
echo "Configuração atualizada em $config_file"
else
echo "A linha a ser modificada não foi encontrada em $config_file"
@lucasaffonso0
lucasaffonso0 / backup_percona.sh
Created June 17, 2023 01:03
Create a backup of the database, and send it in real time to spaces
#!/bin/bash
name=`hostname`
date=`date +%Y-%m-%d`
WEBHOOK_DISCORD_URL=''
stop() {
curl -H "Content-Type: application/json" -X POST -d "{\"content\":\":x: $name-$date: Backup não foi finalizado!\"}" $
exit 1
}
@lucasaffonso0
lucasaffonso0 / create_backup.sh
Created March 31, 2023 12:28
create backup wordpress or bedrock
#!/bin/bash
if ! [ $(id -u) = 0 ]; then
echo "O script precisa ser executado como root." >&2
exit 1
fi
if [ $# -eq 0 ]
then
echo "Nenhum argumento fornecido"
else
@lucasaffonso0
lucasaffonso0 / Configure_cloudflare.py
Created March 24, 2023 19:29
Setup cloudflare for free for better optimization on wordpress sites
import requests
import json
from decouple import config
class Cloudflare():
def __init__(self):
self.token = config('TOKEN_CLOUDFLARE')
self.email = config('EMAIL_CLOUDFLARE')
self.headers = {
'Content-Type': 'application/json',
@lucasaffonso0
lucasaffonso0 / create_database_backup.sh
Created March 17, 2023 03:20
create database backup
mysqldump --single-transaction --set-gtid-purged=OFF --triggers --routines --events -h myrds.us-east-1.rds.amazonaws.com -u root my_db -r my_db_00.sql