Skip to content

Instantly share code, notes, and snippets.

View gustavofuhr's full-sized avatar

Gustavo Führ gustavofuhr

View GitHub Profile
@gustavofuhr
gustavofuhr / rename_arxiv_files.py
Created July 11, 2024 17:53
Rename arxiv pdf files to the paper's title (and year, if required)
import os
import re
import argparse
import feedparser
def get_arxiv_number(s):
p = re.compile(r"(\d{4}.\d{5})(v\d)?\.pdf")
result = p.search(s)
@gustavofuhr
gustavofuhr / get_image_files.py
Created July 12, 2024 20:51
Get all the image files from a dir path, including subdirs.
import os
import glob
import functools, operator
# extract image paths inside the image_dir_path including may include subdirectories using glob
accepted_exts = [".jpg", ".jpeg", ".png"]
image_files = [glob.glob(os.path.join(image_dir_path, "*"+ex)) for ex in accepted_exts]
if include_subdirs:
image_files.extend([glob.glob(os.path.join(image_dir_path + "/**/", "*"+ex)) for ex in accepted_exts])
@gustavofuhr
gustavofuhr / check_realmadrid_tickets.py
Created July 18, 2024 18:45
Check if general public tickets are available at the Real Madrir official site.
import time
import smtplib
import ssl
from email.message import EmailMessage
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
@gustavofuhr
gustavofuhr / llm_wrapper.py
Created August 20, 2024 13:52
A wrapper for GPT4, Claude Sonnet, LLama and Google Gemini.
import os
from enum import Enum
import argparse
from openai import OpenAI
import anthropic
import ollama
import google.generativeai as genai
@gustavofuhr
gustavofuhr / aws_utils.py
Created January 3, 2025 18:52
classes to handle AWS Batch jobs and SageMaker model inference easily.
import json
import time
import boto3
class SageMakerClient:
def __init__(self, region_name):
self.client = boto3.client('sagemaker', region_name=region_name)
@gustavofuhr
gustavofuhr / gist:5debc28ca568ccda7b78c177776a61de
Created March 12, 2025 21:37
Event streamer - normal behavior
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[3651]: MOTION EVENT DETECTED! Send signal to send frames...
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[3651]: 2025-03-11 19:56:37.080 DEBUG setRequestHeader(): Appending header to request: host -> kinesisvideo.sa-east-1.amazonaws.com/getDataEndpoint
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[3651]: 2025-03-11 19:56:37.080 DEBUG setRequestHeader(): Appending header to request: X-Amz-Date -> 20250311T195637Z
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[3651]: 2025-03-11 19:56:37.080 DEBUG setRequestHeader(): Appending header to request: content-type -> application/json
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[3651]: 2025-03-11 19:56:37.080 DEBUG setRequestHeader(): Appending header to request: content-length -> 56
2025-03-11T16:57:00.084-03:00 axis-b8a44fa0dc7a [ INFO
2025-03-11T19:53:16.151-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[5846]: MOTION EVENT DETECTED! Send signal to send frames...
2025-03-11T19:53:16.151-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[5846]: 2025-03-11 21:40:29.243 DEBUG setRequestHeader(): Appending header to request: x-amz-security-token -> IQoJb3JpZ2luX2VjEGUaCXVzLWVhc3QtMiJHMEUCIQCQtbVw91eCPGe6kwYyszfdp7vaBQtZja6i96v+o45pBAIgbrtMzSp7ipQ2Z3nca94Iv5FNAaBPJzlHDU1UvhaXGu0q6AMIrv//////////ARAAGgwzNTQ5MTgzNjkzMjUiDIo3R+qzUxIvjgenuSq8AzL7m5pRb57rScSjWOX76b5rW3ieKVSmFqcQFNFcFN89+um6ZRfJFD0bmVT2bDknF3Nx0v3P+FGziZPcFPipnveVuSVguLYXZnYTnYgLijtJ1Q0qA1xjSjX8Leu7je1n4Zlni7zoNbfMZ2ggRVy4sJugBXWKSPnmLCTwZjrEHxbAbRLEmcp0VI24mVZTfGAvvs7kPvP5DbS8DFhISKhA8CPShWusrTAeIMNEur0zf61bIQD08S8O125i9DDiBCm53ymkv8vWCvKPE9B1Bwhy878Z1urvx80q84gYzhV0ylEbzQX0cEHZ7O2BQ05lri0kE+0moXPe6LdwVpi/MnxvhPpiuxqbsXurP+zg+Q295oFy7A/uOkeOF1fSXgYEjAlPO6PYif1ZnDl76GVA9/u/XxBE3jxNF3A0oHb/LsyP/I0GxIiJmbVjgbKpG9lCBlZBNlpbpvfHaSEqbt3qdrIDrI22S+zDH7pSS7JSToJCyXD6wvgT
@gustavofuhr
gustavofuhr / gist:0715eaf1039d864b48d0641591f407c8
Created March 18, 2025 01:44
Kinesis C producer skipping frames.
2025-03-17T21:31:10.117-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: Options:
2025-03-17T21:31:10.117-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: authType: iot
2025-03-17T21:31:10.117-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: awsIotCredentialsEndpoint: ctepgq3hvkisw.credentials.iot.eu-west-1.amazonaws.com
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: awsIotRoleAlias: producerc_role_alias2
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: awsIotThingName: axis-local
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: awsRegion: us-east-2
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: preBufferSeconds: 20
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iamotioneventstreamer[6471]: streamingDurationSeconds: 30
2025-03-17T21:31:10.118-03:00 axis-b8a44fa0dc7a [ INFO ] iam