Skip to content

Instantly share code, notes, and snippets.

View Pelirrojo's full-sized avatar
🤷‍♂️
Somewhere I have to keep my test code

Manuel Eusebio de Paz Carmona Pelirrojo

🤷‍♂️
Somewhere I have to keep my test code
View GitHub Profile
@Pelirrojo
Pelirrojo / evereven_AWS_APIGW_update-stage.sh
Created October 30, 2024 14:28
Phase 3: Fine-Tuning | Implement Request Throttling in API Gateway
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween
# https://blog.evereven.tech
# Get API GW IDs and stage names
aws apigateway get-rest-apis --query 'items[*].[id,name]' --output json
> [
> [
> "abc123xyz",
> "my-api"
> ]
@Pelirrojo
Pelirrojo / evereven_AWS_ASG_update-auto-scaling-group.sh
Created October 30, 2024 14:28
Phase 3: Fine-Tuning | Adjust Auto-Scaling Parameters
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween
# https://blog.evereven.tech
# Obtain Auto Scaling Group Name
aws autoscaling describe-auto-scaling-groups \
--query 'AutoScalingGroups[*].[AutoScalingGroupName,MinSize,MaxSize,DesiredCapacity]' \
--output json
> [
> [
> "my-asg-cool-name",
@Pelirrojo
Pelirrojo / evereven_AWS_CLOUDFRONT_update-distribution.sh
Created October 30, 2024 14:28
Phase 2: Enhanced Protection | Add Geographic Restrictions in CloudFront
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween
# https://blog.evereven.tech
# Obtain distribution ID
aws cloudfront list-distributions --query 'DistributionList.Items[*].Id' --output json
> [
> "E1PI*******PNY"
> ]
# Obtain codes from: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
@Pelirrojo
Pelirrojo / evereven_AWS_WAF_CREATE_emergency-ddos-rules.sh
Created October 30, 2024 14:27
Phase 1: Immediate Response | Deploy Emergency WAF Rules (Rate based rules)
# A vantablack friday: How to be prepared to stop DDoS Attacks after Halloween
# https://blog.evereven.tech
# Create a WebACL Group Rule
aws wafv2 create-rule-group \
--name "emergency-ddos-rules" \
--scope REGIONAL \
--capacity 1000 \
--visibility-config \
MetricName=DDOSRuleMetric,SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true \
@Pelirrojo
Pelirrojo / wp-evereven_populate-SEO.php
Last active October 15, 2024 10:25
PHP Script to generate the SEO tags through AWS Bedrock with Claude Sonnet
<?php
// Ensure this script its used by consola or exit process
if (php_sapi_name() !== 'cli') {
die('This script can only be run from the command line.');
}
// Load SDK de AWS
require 'vendor/autoload.php';
use Aws\Exception\AwsException;
@Pelirrojo
Pelirrojo / wp-evereven_augment.php
Last active October 15, 2024 10:25
PHP Script to augment the page content through AWS Bedrock with Claude Sonnet
<?php
// Ensure this script its used by consola or exit process
if (php_sapi_name() !== 'cli') {
die('This script can only be run from the command line.');
}
// Database config (get all this data from wp-config.php)
$db_host = '<db_ip>:3306';
$db_name = '<db_name>';
@Pelirrojo
Pelirrojo / wp-evereven_export.php
Last active October 15, 2024 10:25
PHP Script to export all wordpress content in plain text
<?php
// Ensure this script its used by consola or exit process
if (php_sapi_name() !== 'cli') {
die('This script can only be run from the command line.');
}
// Connect to datatase (get all this data from wp-config.php)
$db_host = '<db_ip>:3306';
$db_name = '<db_name>';
@Pelirrojo
Pelirrojo / sample-card.vcf
Created June 7, 2024 21:02
Snippets for the blog entry - How to Create a Sustainable Business Card with AWS CloudFront
BEGIN:VCARD
VERSION:3.0
FN:John Doe
ORG:Example Corp
TITLE:Software Engineer
TEL;TYPE=WORK,VOICE:+1234567890
EMAIL:[email protected]
END:VCARD
@Pelirrojo
Pelirrojo / distribution.tf
Last active June 7, 2024 21:01
Snippets for the blog entry - How to Create a Sustainable Business Card with AWS CloudFront
provider "aws" {
region = "us-east-1"
}
locals {
s3_origin_id = "S3-business-card"
}
variable "zone_id" {
type = string
async def generate_blurred(
image_path: str,
output_path: str,
original_filename: str,
original_extension: str,
faces_detail: dict,
ids_requested: dict,
) -> str:
image = Image.open(image_path)
imgWidth, imgHeight = image.size