Skip to content

Instantly share code, notes, and snippets.

View jvtrisso's full-sized avatar

João jvtrisso

View GitHub Profile
@jvtrisso
jvtrisso / blog.py
Last active July 7, 2023 02:36
Blog example showing how to integrate pydantic with the peewee ORM
import pydantic
import peewee
from playhouse.db_url import connect
from typing import List
import logging
logger = logging.getLogger('peewee')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
@jvtrisso
jvtrisso / oracle_sql_sessions.sql
Last active May 9, 2023 20:36
Oracle Database - Listar informações de consultas e sessões
SELECT
CLIENT_INFO,
STATUS, -- Status da sessão (ex. ativa ou inativa)
S.SID, -- ID da sessão
S.SERIAL#, -- ID da operação
TO_CHAR(S.LOGON_TIME,'dd/mm/yyyy hh24:mi') START_TIME, -- Timestamp de início
S.USERNAME, -- Usuário da sessão
S.PROGRAM, -- Programa
S.MACHINE, -- Host de onde foi feita a conexão
SQ.SQL_TEXT, -- Consulta SQL
@jvtrisso
jvtrisso / test_server.py
Created October 18, 2018 17:33
Python3 HTTP server with PUT support
#!/usr/bin/env python
import argparse
import http.server
import sys
import socketserver
import os
class HTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def __init__(self,req, client_addr, server):
@jvtrisso
jvtrisso / output.txt
Created June 3, 2018 20:03
Pi-Hole Setup
```shell
[✓] Root user check
.;;,.
.ccccc:,.
:cccclll:. ..,,
:ccccclll. ;ooodc
'ccll:;ll .oooodc
.;cll.;;looo:.
@jvtrisso
jvtrisso / rocketchatserver_default.conf
Created November 26, 2017 15:31
Rocket.Chat Nginx Reverse Proxy
# Upstreams
upstream backend {
server 127.0.0.1:3000;
}
# HTTPS Server
server {
listen 443;
server_name your_hostname.com;
@jvtrisso
jvtrisso / rocketchat.service
Last active November 26, 2017 15:25
Rocket.chat server systemd service
[Unit]
Description=Rocket.Chat Server
Requires=After=mongod.service # Requires the mongod service to run first
[Service]
ExecStart=/usr/local/bin/node /opt/rocket.chat/main.js
WorkingDirectory=/opt/rocket.chat # Set to rocket.chat directory
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
@jvtrisso
jvtrisso / knn_metrics.py
Created November 26, 2017 12:41
k-NN metrics
hits = np.asarray([cnf_matrix[i][i] for i in range(cnf_matrix.shape[0])])
expected = np.sum(cnf_matrix, axis=0)
num_hits = np.sum(hits)
total = test_data.shape[0]
precision = 100 * (num_hits / total)
recall_per_class = hits / expected
recall = 100 * (np.sum(recall_per_class) / recall_per_class.shape[0])
@jvtrisso
jvtrisso / knn_confusionmat.py
Created November 26, 2017 12:41
k-NN confusion matrix
from sklearn.metrics import confusion_matrix
cnf_matrix = confusion_matrix(test_data_labels, prediction)
@jvtrisso
jvtrisso / knn_training.py
Created November 26, 2017 12:40
KNN training
classifier = KNearestNeighbors(k=5)
# Train the classifier
classifier.fit(train_data, train_data_labels)
# Obtain the predictions based on the training data
prediction = classifier.predict(test_data)
@jvtrisso
jvtrisso / knn_dataset.py
Created November 26, 2017 12:37
KNN Dataset
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt
# Load data set and corresponding labels
digits_data = load_digits()
digits = digits_data.data
labels = digits_data.target
class_names = digits_data.target_names
# Partition data set into training and test data sets