Skip to content

Instantly share code, notes, and snippets.

View eduardogpg's full-sized avatar
🏠
Working from home

Eduardo Ismael García Pérez eduardogpg

🏠
Working from home
View GitHub Profile
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(100)
);
CREATE TABLE posts (
id INT PRIMARY KEY,
user_id INT,
content TEXT,
created_at DATETIME
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT,
enrollment_year INT
);
CREATE TABLE enrollments (
id INT PRIMARY KEY,
student_id INT,
@eduardogpg
eduardogpg / main.py
Last active February 12, 2025 15:30
Scrip to kill psql queries.
import logging
from typing import Optional
from django.db import connection
from concurrent.futures import TimeoutError, Future
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class QueryTimeoutException(BaseException):
def __init__(self, message: str, pid: Optional[int] = None):
import time
from threading import Thread
from multiprocessing import Process
def is_prime(number):
if number < 2:
return False
for x in range(2, number):
if number % x == 0:
from multiprocessing import Process
import time
import os
from concurrent.futures import ProcessPoolExecutor
def fib(number):
if number <= 1:
return number
return fib(number - 1) + fib(number - 2)
from threading import Thread
import time
def fib(number):
if number <= 1:
return number
return fib(number - 1) + fib(number - 2)
if __name__ == '__main__':
import threading
import requests
import time
def fetch_data(post_id):
url = f"https://jsonplaceholder.typicode.com/posts/{post_id}"
response = requests.get(url)
if response.status_code == 200:
print(f"Successfully fetched data for post {post_id}")
import time
from threading import Thread
def prepare_dough():
print("Preparing the dough...")
time.sleep(3)
print("Dough is ready.")
def add_ingredients():
print("Adding ingredients...")
CREATE TABLE employees (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, -- No necesario
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
hire_at DATE, -- No necesario
salary DECIMAL(10, 2) NOT NULL,
status ENUM('active', 'inactive') DEFAULT 'active', -- No necesario
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -- No necesario
);
@eduardogpg
eduardogpg / public_sentences.sql
Last active February 5, 2024 10:12
public_sentences.sql
-- SCHEMA
DROP TABLE IF EXISTS project_employees;
DROP TABLE IF EXISTS projects;
DROP TABLE IF EXISTS employees;
CREATE TABLE IF NOT EXISTS employees (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,