Skip to content

Instantly share code, notes, and snippets.

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

Tiago Cardoso tiagocardosos

🏠
Working from home
View GitHub Profile
@tiagocardosos
tiagocardosos / MySQL Replication Check
Created April 29, 2019 23:31 — forked from ssimpson89/MySQL Replication Check
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')
from django.db import models
from django.db.models.query import QuerySet
from django.utils import timezone
"""
Implementação do softdelete
Todas as classes que devem implementar o SoftDelete, devem herdar de SoftDeletionModel
"""
class SoftDeletionQuerySet(QuerySet):
def delete(self):
@tiagocardosos
tiagocardosos / flask_file_streamer.py
Created July 16, 2019 18:49 — forked from tgwizard/flask_file_streamer.py
A Flask request multipart/form-data file streamer
import time
import werkzeug.formparser
from flask import Flask, Response, request
class DummyWerkzeugFile:
def write(self, b: bytes):
print('reading file parts: size=%s' % len(b))
@tiagocardosos
tiagocardosos / set_default_python.md
Last active August 26, 2019 14:37
ubuntu - set default python

To change Python 3.6.8 as the default in Ubuntu 18.04 to Python 3.7.

Install Python 3.7

Steps to install Python3.7 and configure it as the default interpreter.

Install the python3.7 package using apt-get

sudo apt-get install python3.7

@tiagocardosos
tiagocardosos / nginx.conf
Created October 9, 2019 16:14 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@tiagocardosos
tiagocardosos / insert_tabela_cfop.sql
Last active May 17, 2021 19:52
TABELA CFOP - MYSQL
INSERT INTO cfop(codigo,descricao,aplicacao,classificador) VALUES (1000,'ENTRADAS OU AQUISIÇÕES DE SERVIÇOS DO ESTADO','Classificam-se, neste grupo, as operações ou prestações em que o estabelecimento remetente esteja localizado na mesma unidade da Federação do destinatário','OUTROS');
INSERT INTO cfop(codigo,descricao,aplicacao,classificador) VALUES (1100,'COMPRAS PARA INDUSTRIALIZAÇÃO, PRODUÇÃO RURAL, COMERCIALIZAÇÃO OU PRESTAÇÃO DE SERVIÇOS','Início
(NR Ajuste SINIEF 05/2005) (DECRETO Nº 28.868, DE 31/01/2006) (Dec. 28.868/2006 – Efeitos a partir de 01/01/2006, ficando facultada ao contribuinte a sua adoção para fatos geradores ocorridos no período de 01 de novembro a 31 de dezembro de 2005)','OUTROS');
INSERT INTO cfop(codigo,descricao,aplicacao,classificador) VALUES (1101,'Compra para industrialização ou produção rural (NR Ajuste SINIEF 05/2005) (Decreto 28.868/2006)','Compra de mercadoria a ser utilizada em processo de industrialização ou produção rural, bem como a entrada de mercadoria em estabelecimen
@tiagocardosos
tiagocardosos / readme.md
Created February 8, 2023 18:29
ClickhouseDb - POC

Tabela exemplo

CREATE TABLE capes
(
    `id` String,
    `title` Array(String),
    `year` UInt16,
    `documentType` String,
    `abstract` Array(String),