Skip to content

Instantly share code, notes, and snippets.

View alonsoir's full-sized avatar
👋
time to learn SCADA.

@alonso_isidoro alonsoir

👋
time to learn SCADA.
View GitHub Profile
@alonsoir
alonsoir / Dockerfile
Last active February 26, 2025 13:03
The generic Dockerfile represents a hypothetical app that may have problems and the gh.action pipeline will review it with the help of a series of tools and a custom script so that with the help of an ollama it can try to generate patches, tests and iterative pull requests. The script will try to save each iteration to show Ollama where it could…
# Dockerfile
FROM python:3.8-slim
# Establecer un usuario no root
RUN adduser --disabled-password appuser
USER appuser
# Configurar el directorio de trabajo
WORKDIR /app
@alonsoir
alonsoir / multi_thread.py
Created February 13, 2025 08:57
A scapy based sample about how to use in a multi thread way an sniffer and a packets sending tool.
import threading
import argparse
import queue
from scapy.all import *
from scapy.layers.dns import *
from scapy.layers.inet import ICMP
'''
Mejoras aplicadas con respecto a fuzzing_dns_multi_thread:
#open_deep_researcher.py
!pip install nest_asyncio
import nest_asyncio
nest_asyncio.apply()
import asyncio
import aiohttp
import json
import os
import ray
from langchain.chains import RetrievalQA
from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
from langchain_community.document_loaders import PyPDFLoader, TextLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_google_community import GoogleSearchAPIWrapper
from langchain_community.tools import Tool
import os
from langchain.chains import RetrievalQA
from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
from langchain_community.document_loaders import PyPDFLoader, TextLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_google_community import GoogleSearchAPIWrapper
from langchain_community.tools import Tool
import multiprocessing
import ipaddress
import subprocess
from scapy.all import sniff, IP
# Rango de IPs asignadas a China
china_ip_ranges = [
"36.0.0.0/8", "42.0.0.0/8", "58.0.0.0/7", "101.0.0.0/8",
"110.0.0.0/7", "120.0.0.0/8", "202.0.0.0/7"
]

(attendance-system-py3.10) ┌<▸> ~/g/attendance_system └➤ poetry add textblob

The following packages are already present in the pyproject.toml and will be skipped:

  • textblob

If you want to update it to the latest compatible version, you can use poetry update package. If you prefer to upgrade it to the latest available version, you can use poetry add package@latest.

@alonsoir
alonsoir / multi.py
Created January 22, 2025 10:43
Para tareas multicore, es mejor usar Pool que Parallel
from multiprocessing import Pool
from joblib import Parallel, delayed
import time
def medir_tiempo(func):
def wrapper(*args, **kwargs):
inicio = time.time()
resultado = func(*args, **kwargs)
fin = time.time()

(attendance-system-py3.10) ┌<▸> ~/g/attendance_system └➤ ./video_to_gif.sh Uso: ./video_to_gif.sh ruta/al/video.mp4 [nombre_del_gif] (attendance-system-py3.10) ┌<▪> ~/g/attendance_system └➤ ./video_to_gif.sh output.mp4 ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers built with Apple clang version 16.0.0 (clang-1600.0.26.4) configuration: --prefix=/usr/local/Cellar/ffmpeg/7.1_4 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enabl

import email
import quopri
from email import policy
from email.parser import BytesParser
def parse_email(file_path):
with open(file_path, 'rb') as file:
msg = BytesParser(policy=policy.default).parse(file)
print("From:", msg.get("From", "N/A"))