Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

  • 09:26 (UTC +01:00)
View GitHub Profile
@filipeandre
filipeandre / test1.yaml
Last active May 2, 2025 19:54
Test substitution logic for IP construction with dummy resource (sub, select, ssm)
AWSTemplateFormatVersion: '2010-09-09'
Description: Test substitution logic for IP construction with dummy resource.
Resources:
DummyResource:
Type: AWS::CloudFormation::WaitConditionHandle
Outputs:
FabricComponentsStaticIP:
Value: !Sub
@filipeandre
filipeandre / detete-redis-cache.js
Last active April 29, 2025 17:46
Helper script to delete redis cache
const redis = require('redis');
const readline = require('readline');
async function connectRedis(host, port, db, password) {
const client = redis.createClient({
socket: { host, port },
database: db,
password
});
await client.connect();
@filipeandre
filipeandre / extract_data_frame_paddleocr.py
Created April 21, 2025 14:52
PaddleOCR aims to create multilingual, awesome, leading, and practical OCR tools that help users train better models and apply them into practice.
# define functions to run the ocr,
# annotate the images with the bounding boxes
# consolidate the results to a dataframe
# and iterate over a folder of images
from PIL import Image, ImageDraw
import pandas as pd
from paddleocr import PaddleOCR
import os
import traceback
@filipeandre
filipeandre / verify_latency.sh
Created March 26, 2025 16:20
Inside ECS, this allow to verify the latency to the AIM endpoint
while true; do
curl -o /dev/null -s -w "%{http_code}, %{time_total}s\n" \
http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
sleep 5
done
@filipeandre
filipeandre / install_pgbadger.sh
Created March 17, 2025 17:19
Install pgbadger on Amazon Linux 2023
#!/bin/bash
echo "Updating package lists..."
dnf update -y
echo "Installing required dependencies..."
dnf install -y perl perl-core perl-FindBin perl-Time-HiRes perl-JSON \
perl-Digest-MD5 perl-Text-CSV perl-LWP-Protocol-https \
perl-DBI perl-DBD-Pg tar gzip make
@filipeandre
filipeandre / revet_secret.sh
Created March 13, 2025 14:44
Revert aws secret to previous version
#!/bin/bash
set -euo pipefail
# Check for required commands: aws and jq.
command -v aws >/dev/null 2>&1 || { echo "aws CLI is required but not installed. Exiting." >&2; exit 1; }
command -v jq >/dev/null 2>&1 || { echo "jq is required but not installed. Exiting." >&2; exit 1; }
usage() {
cat <<EOF
Usage: $0 [secret_name]
@filipeandre
filipeandre / install_jupiter_lab.sh
Last active March 10, 2025 20:31
Install Jupiter lab using PIPx
# install pipx
python -m pip install --user pipx
python -m pipx ensurepath
sudo pipx ensurepath --global
# install jupyterlab
pipx install jupyterlab --include-deps
pipx ensurepath
# add common dependencies
@filipeandre
filipeandre / cloudformation-language-extensions-fn-foreach.yaml
Last active March 7, 2025 15:41
Working Alarm template with cloudformation Fn::ForEach
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::LanguageExtensions
Parameters:
AlarmLambdaPairs:
Type: CommaDelimitedList
Description: |
Comma-separated "prefix:lambdaName" pairs. Example: "PrefixA:MyLambdaA,PrefixB:MyLambdaB"
Default: PrefixA:MyLambdaA,PrefixB:MyLambdaB
@filipeandre
filipeandre / sources.md
Last active February 27, 2025 12:13
Prototype of XKS proxy in Node.js that leverages the official Azure SDKs to interact with Azure Key Vault

Sources

AWS KMS Custom Key Store (XKS) Documentation:

The design and endpoint concepts are inspired by AWS’s documentation for creating an external key store. AWS XKS Documentation

Azure Key Vault Keys Documentation:

Details about managing keys and using cryptographic operations with Azure Key Vault Azure Key Vault Keys Overview.

Azure SDK for JavaScript:

@filipeandre
filipeandre / delete_deprecated_lambdas.py
Last active February 19, 2025 11:32
Delete all deprecated lambdas
import boto3
def delete_old_nodejs_lambdas():
client = boto3.client("lambda")
deprecated_runtimes = {"nodejs12.x", "nodejs14.x", "nodejs16.x"}
# Paginate through all Lambda functions
paginator = client.get_paginator("list_functions")
page_iterator = paginator.paginate()