Skip to content

Instantly share code, notes, and snippets.

View jairochapela's full-sized avatar

Jairo Chapela-Martínez jairochapela

  • Cangas, Pontevedra, Galicia (Spain)
View GitHub Profile
#!/usr/bin/env python3
from datetime import datetime
import sys
LOG_FILE="/var/log/snmptraps.log"
# Obtener la fecha y hora del evento
timestamp=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@jairochapela
jairochapela / gunicorn.service
Created November 28, 2024 12:21
Django + Gunicorn + Nginx
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
Type=notify
# the specific user that our service will run as
User=django
Group=django
RuntimeDirectory=/home/django/myproject/venv/bin
@jairochapela
jairochapela / apache.conf
Created November 28, 2024 12:19
Django con WSGI en Apache
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /path/to/your/django/project
WSGIDaemonProcess example.com python-path=/path/to/your/django/project
WSGIProcessGroup example.com
WSGIScriptAlias / /path/to/your/django/project/wsgi.py
@jairochapela
jairochapela / base.html
Created November 20, 2024 10:48
Jerarquía de plantillas Django
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
h1, h2, h3 {
color: red;
}
@jairochapela
jairochapela / cesar.py
Created March 3, 2024 12:00
Cifrado Cesar utilizando cierres en Python
# Cifrado César.
def Cesar(key):
'''
Cifrado Cesar. (Y un ejemplo de uso de cierres en Python.)
'''
ckey = key # Clave de cifrado
dkey = -key # Clave de descifrado (opuesta a la de cifrado)
@jairochapela
jairochapela / Persona.py
Created December 5, 2021 20:34
Ejercicio POO con Python: Personal
class Persona:
def __init__(self, nombre, edad, dni) -> None:
if nombre == "":
raise ValueError("El nombre no puede estar vacío")
if edad < 0:
raise ValueError("La edad no puede ser negativa")
if len(dni)!=9:
raise ValueError("El DNI debe tener 9 caracteres")
self.nombre = nombre
@jairochapela
jairochapela / Main.java
Created December 5, 2021 20:33
Ejercicio POO con Java: Personal
public class Main {
public static void main(String[] args) {
Persona juan = new Persona("Juan García Pérez", 23, "12345678R");
Trabajador alberto = new Trabajador("Alberto Gónzalez López", 41, "87654321M", 40, 1050);
System.out.println(juan);
System.out.println(alberto);
}
}
@jairochapela
jairochapela / Libro.py
Created December 5, 2021 20:30
Ejercicio POO con Python: Biblioteca
class Libro:
def __init__(self, titulo, autor, isbn) -> None:
self.titulo = titulo
self.autor = autor
self.set_isbn(isbn)
def comprobar_isbn10(isbn) -> bool:
return sum(map(lambda p: int(p[0])*p[1], zip(isbn.replace("-", ""), range(1, 11)))) % 11 == 0
@jairochapela
jairochapela / formulario.html
Created November 22, 2021 08:35
Formulario con validación
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formulario de autodiagnóstico</title>
</head>
<body>
<h1>Formulario de autodiagnóstico</h1>
@jairochapela
jairochapela / procesar.php
Created October 13, 2021 09:59
Procesamento xenérico de formularios en PHP, con fins de depuración.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Procesamiento de formulario</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>