Skip to content

Instantly share code, notes, and snippets.

@Biazus
Biazus / builder.py
Created March 21, 2020 23:55
Sample of builder design pattern
#!/usr/bin/env python3
from abc import ABC, abstractmethod
class AbstractEdgeBuilder(ABC):
@abstractmethod
def build_edge(self):
pass
@Biazus
Biazus / postgresql-set-id-seq.sql
Created February 5, 2023 13:40
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@Biazus
Biazus / script.sql
Last active February 18, 2023 17:29
Find / Remove duplicates PostgreSQL
CREATE TABLE customer (
customer_id serial PRIMARY KEY,
first_name VARCHAR ( 50 ) NOT NULL,
last_name VARCHAR ( 50 ) NOT NULL,
address VARCHAR ( 50 ) NOT NULL
)
INSERT INTO customer (first_name, last_name, address) values ('John', 'B', 'x Avenue');
INSERT INTO customer (first_name, last_name, address) values ('John', 'B', 'x Avenue');
INSERT INTO customer (first_name, last_name, address) values ('Maria', 'Pena', 'Cal St.');
@Biazus
Biazus / testing_gray_and_black.py
Created July 24, 2025 04:28
Just a small snippet to test normalization
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread("D:\\Projetos\\Cinza\\teste.jpg")
gray = 0.299 * img[:, :, 0] + 0.587 * img[:, :,1] + 0.114 * img[:, :,2]
gray = gray.astype(np.uint8) # garantindo valores inteiros
limit = 127