Skip to content

Instantly share code, notes, and snippets.

View alonsoir's full-sized avatar
👋
time to learn python by doing experiments with AI.

@alonso_isidoro alonsoir

👋
time to learn python by doing experiments with AI.
View GitHub Profile
@alonsoir
alonsoir / refactor.sql
Created November 15, 2024 07:45
Visto en Linkedin, una refactorización de una consulta bastante grande.
---
Query original:
SELECT
u.user_id,u.username,u.email, COALESCE(SUM(o.total_amount), 0) AS total_ spent, COUNT(DISTINCT o. order_id) AS total_orders,
ROUND (AVG(o. total_amount, 2) AS avg_order_value,
MAXo. total amount) AS max order_value,
RANK() OVER (ORDER BY SUM(o. total_amount) DESC) AS spending_rank,
SELECT MAX(02. order_date)
FROM orders 02
@alonsoir
alonsoir / scanner.sh
Created November 6, 2024 18:14
Enumerate Subdomains & Emails Using CRT
#!/bin/bash
# Prompt the user for a link
echo "Please enter the link to scan:"
read link
# Output the entered link
echo "You entered: $link"
curl -s "https://crt.sh/?q=%25.$link&output=json" | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u
from openai import OpenAI
import requests
from dotenv import load_dotenv
import time
import os
import json
load_dotenv()
client = OpenAI()
@alonsoir
alonsoir / summarize.py
Last active October 31, 2024 18:42
Explicación del código summarize_section: Envía cada sección de texto a la API de OpenAI para obtener un resumen de 400 caracteres (o menos de 100 tokens). split_text: Divide el texto en fragmentos de aproximadamente 8,000 tokens cada uno (aproximadamente 5,000 palabras), ajustando el tamaño si es necesario. summarize_document: Procesa cada secc…
# pip install openai
# para probarlo, me bajo el libro Moby Dick, lo divido en 72 secciones y envio cada seccion gpt-4.
# Hay que tener cuidado con los parametros MAX_TOKENS_PER_CHUNK y SUMMARY_TOKEN_LIMIT para no molestar a openAI.
from openai import OpenAI
import requests
from dotenv import load_dotenv
load_dotenv()
client = OpenAI()
@alonsoir
alonsoir / LinkedList.java
Created October 18, 2024 11:54
ejemplo lista enlazada en java
public class ListaDobleEnlazada<T> {
private Nodo<T> cabeza;
private Nodo<T> cola;
// Clase interna Nodo
private static class Nodo<T> {
T dato;
Nodo<T> siguiente;
Nodo<T> anterior;
from rembg import remove
from PIL import Image
## Path for input and output image
input_img = 'spiderman_with_bg.jpeg'
output_img = 'spiderman_without_bg.png'
## loading and removing background
inp = Image.open(input_img)
output = remove(inp)
@alonsoir
alonsoir / fileToSpeech.py
Created August 26, 2024 17:09
It will use say native osx command to read and make a speach about the content.
import PyPDF2
import subprocess
# Open the PDF file (Enter Path To Your PDF)
file = open('fullnotes_lagrangiano_modelo_estandar.pdf', 'rb')
readpdf = PyPDF2.PdfReader(file)
# Iterate over each page in the PDF
for pagenumber in range(len(readpdf.pages)):
# Extract text from the page
@alonsoir
alonsoir / open_links.py
Created August 26, 2024 17:07
a tool to open links in your browser...
@alonsoir
alonsoir / create_fake_data.py
Created August 26, 2024 17:06
faker sample
import pandas as pd
from faker import Faker
import random
fake = Faker()
def generate_fake_data(num_entries=10):
data = []
@alonsoir
alonsoir / analyze.py
Created August 26, 2024 17:00
running of pylint and flake...
import os
import subprocess
def analyze_code(directory):
# List Python files in the directory
python_files = [file for file in os.listdir(directory) if file.endswith('.py')]
if not python_files:
print("No Python files found in the specified directory.")
return