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 / 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),
@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 / 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 / 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 / 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))
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 / 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 }')
@tiagocardosos
tiagocardosos / walk.py
Created April 18, 2019 18:45
What's the fastest way to recursively search for files in python?
# https://stackoverflow.com/questions/50948391/whats-the-fastest-way-to-recursively-search-for-files-in-python
import os
import glob
def walk():
pys = []
for p, d, f in os.walk('.'):
for file in f:
if file.endswith('.py'):
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""Death by Captcha HTTP and socket API clients.
There are two types of Death by Captcha (DBC hereinafter) API: HTTP and
socket ones. Both offer the same functionalily, with the socket API
sporting faster responses and using way less connections.
To access the socket API, use SocketClient class; for the HTTP API, use
@tiagocardosos
tiagocardosos / install_python3.6_ubuntu.md
Last active February 10, 2018 18:24
How to Install Python 3.6.1 in Ubuntu 16.04 LTS

This quick tutorial is going to show you how to install the latest Python 3.6.1 in Ubuntu 16.04 LTS via PPA.

Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default. You can install Python 3.6 along with them via a third-party PPA by doing following steps:

1. Open terminal via Ctrl+Alt+T or searching for “Terminal” from app launcher. When it opens, run command to add the PPA:

sudo add-apt-repository ppa:jonathonf/python-3.6