Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

  • 12:42 (UTC +01:00)
View GitHub Profile
@filipeandre
filipeandre / create_ppt_presentation.py
Created July 10, 2024 07:33
Script used to create a power point presentation
from pptx import Presentation
from pptx.util import Inches
prs = Presentation()
# Slide 1: Title Slide
slide_1 = prs.slides.add_slide(prs.slide_layouts[0])
title_1 = slide_1.shapes.title
subtitle_1 = slide_1.placeholders[1]
title_1.text = "Suspend Manager Event Flow Representation"
@filipeandre
filipeandre / zip_lambda.py
Created July 2, 2024 18:53
Create a zip to be used as python lambda
#!/usr/bin/env python
import os
import re
import zipfile
import site
import argparse
"""Package this lambda"""
ignore = ["__pycache__", "_pytest"]
@filipeandre
filipeandre / remove_sls_sdk_wrapper.py
Last active June 17, 2024 17:27
Remove the AWS_LAMBDA_EXEC_WRAPPER env variable and sls-sdk-* layers from all aws lambdas of current region and account
import boto3
def list_and_update_lambdas():
client = boto3.client('lambda')
paginator = client.get_paginator('list_functions')
response_iterator = paginator.paginate()
lambdas_updated_count = 0
for page in response_iterator:
@filipeandre
filipeandre / mongo_collection_to_excel.py
Created June 15, 2024 21:25
Example of a script that exports a mongo db collection to an excel file
import os
import pandas as pd
from pymongo import MongoClient
import inquirer
import configparser
# pip install pymongo pandas openpyxl inquirer
config_file = 'to_excel.ini'
config_section = 'mongodb'
@filipeandre
filipeandre / update_to_most_recent_template.py
Last active June 14, 2024 14:25
It gets the latest github tag from a repository, gets a stack from an s3 location and deploy it by using a temporary bucket. It support deployment in another aws accounts. The settings are saved and it supports profiles.
import os
import sys
import re
import requests
import configparser
import tempfile
import uuid
import argparse
import subprocess
import inquirer
@filipeandre
filipeandre / valitate_hello_sign.py
Created June 6, 2024 16:46
Validate hello sign key
import requests
from requests.auth import HTTPBasicAuth
def validate_hellosign_credentials(api_key):
url = 'https://api.hellosign.com/v3/account'
response = requests.get(url, auth=HTTPBasicAuth(api_key, ''))
if response.status_code == 200:
print("Valid HelloSign credentials")
@filipeandre
filipeandre / get_user_data.sh
Created May 29, 2024 10:45
Get user data script from EC2
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
export INSTANCE_ID=`curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-id`
sudo cat /var/lib/cloud/instances/$INSTANCE_ID/user-data.txt
@filipeandre
filipeandre / get_command_invocations_waiter.ts
Last active May 27, 2024 13:06
Implementation of get command incocations boto3 waiter
import botocore.waiter
import botocore.session
get_command_invocations_model = botocore.waiter.WaiterModel({
"version": 2,
"waiters": {
"CommandSuccess": {
"delay": 2,
"operation": "GetCommandInvocation",
"maxAttempts": 3,
@filipeandre
filipeandre / batch_get_builds_waiter.py
Last active June 17, 2024 07:40
Implementation of batch get builds boto3 waiter
import botocore.waiter
import botocore.session
batch_get_builds_model = botocore.waiter.WaiterModel({
"version": 2,
"waiters": {
"BuildSuccess": {
"delay": 5,
"operation": "BatchGetBuilds",
"maxAttempts": 60,
@filipeandre
filipeandre / promise_all.js
Last active May 27, 2024 11:15
Examples of ways to wait for promises
// Promise.all only resolves when all Promises in the array passed in are resolved, and returns the array of resolved values.
const { setTimeout } = require('timers/promises');
const promise1 = setTimeout(100, 'Promise 1 resolved');
const promise2 = setTimeout(200, 'Promise 2 resolved');
const promise3 = setTimeout(300, 'Promise 3 resolved');
async function examplePromiseAll() {
try {
const results = await Promise.all([promise1, promise2, promise3]);