Skip to content

Instantly share code, notes, and snippets.

View billmetangmo's full-sized avatar

Bill Metangmo billmetangmo

  • France
View GitHub Profile
@billmetangmo
billmetangmo / draw.py
Created July 2, 2024 14:28
Graph distribution of resources
import pandas as pd
import matplotlib.pyplot as plt
# Load the CSV file
file_path = '/mnt/data/resources(2).csv'
data = pd.read_csv(file_path)
# Calculate the number of resources per region
resources_per_region = data['Region'].value_counts().reset_index()
resources_per_region.columns = ['Region', 'Number of Resources']
@billmetangmo
billmetangmo / deny_regions.json
Created July 2, 2024 09:55
scp deny all unused regions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyCreateResourcesInSpecificRegions",
"Effect": "Deny",
"Action": [
"*"
],
"Resource": "*",
@billmetangmo
billmetangmo / gist:262fb7f2d379a4ea4c7d3bd499aa7c3b
Last active June 26, 2024 02:07
sample argo applicationset
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: easyappointments-preview
namespace: argocd
spec:
generators:
- pullRequest:
github:
owner: mongulu-cm
import unittest
from typing import List, Dict
from tqdm import tqdm
def distribute_elements(stream: List[int], servers: List[str], weights: List[int]) -> Dict[str, List[int]]:
if len(servers) != len(weights):
raise ValueError("The number of servers and weights must be the same.")
total_weight = sum(weights)
normalized_weights = [weight / total_weight for weight in weights]
@billmetangmo
billmetangmo / cfn-patches.yml
Last active January 4, 2024 11:42
Code to add a new domain to aws copilot
- op: add
path: /Resources/HTTPSRulePriorityAction1
value:
Metadata:
'aws:copilot:description': 'Custom resource assigning priority for the first HTTPS listener rule'
DependsOn: HTTPSListenerRule
Type: Custom::RulePriorityFunction
Properties:
ServiceToken: !GetAtt RulePriorityFunction.Arn
RulePath: ["/"]
@billmetangmo
billmetangmo / gitab-pipelines-stages-histogram.py
Created October 6, 2023 11:17
Generate histogram from gitlab pipelines scrape with Bardeen
import pandas as pd
import datetime
import re
import matplotlib.pyplot as plt
# Load the CSV file
df = pd.read_csv("/mnt/data/06-10-2023_10-10.csv")
# Function to convert status text to timedelta
def convert_to_timedelta_updated_with_weeks(text):
@billmetangmo
billmetangmo / slack_archive.py
Created September 12, 2023 15:49
slack archive channels
import os
import pandas as pd
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
import csv
from time import sleep
# Initialize Slack client with your token
client = WebClient(token="<SLACK_BOT_TOKEN>")
@billmetangmo
billmetangmo / categories.py
Last active August 5, 2023 11:58
Détermine si une question compta online peut-être répondu juste juridiquement
from openpyxl import load_workbook
import csv
from collections import defaultdict, Counter
# Load the workbook
file_path = "Forum Gestion Entreprise Compta online.xlsx"
workbook = load_workbook(file_path)
sheet = workbook['Sheet1']
# Get the content of the "Droit pourquoi?" column
@billmetangmo
billmetangmo / argilla.py
Created August 4, 2023 23:30
Label output LLM
import argilla as rg
from argilla.client.feedback.schemas.records import ResponseSchema, SuggestionSchema, ValueSchema
rg.init(
api_url="http://localhost:6900",
api_key="admin.apikey"
)
dataset = rg.FeedbackDataset(
guidelines="Add some guidelines for the annotation team here.",
@billmetangmo
billmetangmo / ocr_pdf_scanneds.md
Created July 31, 2023 15:11
ocr_pdf_scanneds

Comment détecter les tableaux sur les pages de pdf scannés ?

Détecter les tableaux dans des pages de PDF scannés est un problème qui implique plusieurs étapes, car vous travaillez avec des images numérisées plutôt qu'avec du texte numérique. Voici une approche générale:

  1. OCR (Reconnaissance optique de caractères) : La première étape consiste à utiliser une technologie OCR pour transformer les images numérisées en texte lisible par une machine. Il existe plusieurs outils qui peuvent faire cela, y compris Google's Vision API, Tesseract, Adobe's Acrobat, et d'autres. Notez que la qualité de la numérisation et la netteté de l'image peuvent affecter la précision de l'OCR.

  2. Détection des tableaux : Une fois que vous avez du texte lisible par une machine, vous pouvez commencer à détecter les tableaux. Il s'agit souvent d'une tâche difficile, car les tableaux peuvent avoir des formats très différents. Vous pourriez envisager d'utiliser des expressions régulières pour détecter des motifs qui res