Skip to content

Instantly share code, notes, and snippets.

@fabiuxx
fabiuxx / postgres_conn.py
Last active January 26, 2023 17:59
Script que utiliza psycopg2 para conectarse a una base de datos postgres.
import traceback
import munch
import psycopg2
import sys
DEBUG_QUERYS = False
def row_to_dict(cursor, row):
x = {}
for key, col in enumerate(cursor.description):
@fabiuxx
fabiuxx / mail_server.py
Last active January 31, 2018 12:37
Script que permite ejecutar un servidor SMTP y persistir los correos como archivos EML.
# -*- coding: utf-8 -*-
from datetime import datetime
import asyncore
from smtpd import SMTPServer
class EmlServer(SMTPServer):
no = 0
def process_message(self, peer, mailfrom, rcpttos, data):
@fabiuxx
fabiuxx / mail_sender.py
Last active January 31, 2018 12:35
Script para envío de correos electrónicos utilizando gmail
# -*- coding: utf-8 -*-
import smtplib
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_email(user, pwd, recipient, subject, body):
gmail_user = user
gmail_pwd = pwd