Skip to content

Instantly share code, notes, and snippets.

View keizerzilla's full-sized avatar
💯
🏁

Artur Rodrigues keizerzilla

💯
🏁
  • Brasil
  • 03:31 (UTC -03:00)
View GitHub Profile
@keizerzilla
keizerzilla / camlist.py
Created January 24, 2023 14:05
Lists all avaiable cameras attached to the computer using Python and OpenCV.
# camlist.py
# Lists all avaiable cameras attached to the computer
# Dependencies: pip install opencv-python
# Usage: python camlist.py
import cv2
print(f"OpenCV version: {cv2.__version__}")
max_cameras = 10
@keizerzilla
keizerzilla / gera_amostras.py
Created May 10, 2021 22:57
Simples gerador de amostras sintéticas a partir de distâncias. Requisitos: numpy scikit-learn.
def gera_amostras(dados, k_vizinhos=5, k_amostras=5):
"""
Simples gerador de amostras sintéticas a partir de distâncias. A partir de duas
amostras P e Q do conjunto de k_amostras, gera uma terceira R igual ao ponto médido
de P e Q.
Requisitos: numpy scikit-learn.
Parâmetros
----------
@keizerzilla
keizerzilla / dunn-sklearn.py
Created December 2, 2018 01:18
Dunn index for sklearn-generated clusters
import numpy as np
def normalize_to_smallest_integers(labels):
"""Normalizes a list of integers so that each number is reduced to the minimum possible integer, maintaining the order of elements.
:param labels: the list to be normalized
:returns: a numpy.array with the values normalized as the minimum integers between 0 and the maximum possible value.
"""
@keizerzilla
keizerzilla / colortest.c
Last active September 3, 2018 11:17
Formatting output with colors using printf() (C stdio.h). For more info: http://ascii-table.com/ansi-escape-sequences.php
#include <stdio.h>
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"