Skip to content

Instantly share code, notes, and snippets.

View LX5321's full-sized avatar

Alexander Roque Rodrigues LX5321

View GitHub Profile
import boto3
import os
import time
import json
import uuid
# Initialize AWS clients
s3 = boto3.client('s3')
athena = boto3.client('athena')
import boto3
import csv
import io
import time
import json
import uuid
# AWS Clients
s3 = boto3.client('s3')
athena = boto3.client('athena')
import asyncio
import aiohttp
# Exponential backoff and retry function
async def fetch_with_retries(session, url, retries=5, backoff_factor=1):
attempt = 0
while attempt <= retries:
try:
async with session.get(url) as response:
print("Attempt", attempt, "for", url)
import hashlib
import boto3
from boto3.s3.transfer import S3Transfer
def calculate_checksum(file_path, algorithm='sha256'):
"""
Calculate the checksum of a file on disk.
:param file_path: Path to the file
:param algorithm: Checksum algorithm (default is sha256)
:return: checksum as a hexadecimal string
import re
def format_string(input_string):
# Remove spaces and capitalize the first letter after each space
result = re.sub(r'(\s+)(\w)', lambda match: match.group(2).upper(), input_string.replace(' ', ''))
return result
# Example usage:
input_string = "hello world example string"
@LX5321
LX5321 / g.sh
Last active February 6, 2025 05:23
#!/bin/bash
# Function to check if the given date is a weekday
is_weekday() {
day_of_week=$(date -d "$1" +%u)
if [[ "$day_of_week" -ge 1 && "$day_of_week" -le 5 ]]; then
return 0 # Weekday
else
return 1 # Weekend
fi
@LX5321
LX5321 / topo.macro
Last active November 27, 2024 12:29
Sub TopologicalSortAndModifyTablesWithRemapLogic()
Dim lastRow As Long
Dim i As Long
Dim job As String ' Job name (String)
Dim dependentJob As String ' Dependent job (String)
Dim jobList As Object
Dim inDegree As Object
Dim queue As Collection
Dim result As Collection
Dim currentJob As Variant ' To loop over sorted jobs
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class ProcessBuilderExample {
public static void main(String[] args) {
// Create a ProcessBuilder instance to run the 'ls' command
ProcessBuilder processBuilder = new ProcessBuilder("ls", "-l"); // You can add other options as needed
try {
@LX5321
LX5321 / shell_recorder.sh
Created March 12, 2021 15:18
Record Terminal and Filter Output
cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > typescript-processed
@LX5321
LX5321 / read.cpp
Created December 12, 2020 13:55
read multi column file in c++ and split by regex rule
#include <bits/stdc++.h>
bool iterateFile(std::string fileName, std::function<void (const std::string & )> callback)
{
std::ifstream in(fileName.c_str());
if(!in)
{
std::cerr << "Cannot open the File : "<<fileName<<std::endl;
return false;
}