Skip to content

Instantly share code, notes, and snippets.

@luiscoms
luiscoms / kafka_send_file.py
Created August 22, 2025 12:54
This script is used to send the contents of a specified file to a Kafka topic.
#!/usr/bin/env python3
"""
This script is used to send the contents of a specified file to a Kafka topic.
Pre-requisites:
- Python 3.x
- Kafka broker running and accessible
- Required Python packages installed (e.g., kafka-python, json, logging)
The file is expected to contain JSON data, which will be read, processed, and sent as a message to the Kafka topic.
@luiscoms
luiscoms / logger_dict_formatter.py
Created September 30, 2021 17:52
Python Logger Dict Formatter
from copy import deepcopy
from logging.config import dictConfig
from os.path import isfile
import yaml
class LoggerDictConfigFormatter:
unwanted_keys: tuple = ('level', 'handlers', 'propagate')
max_deep: int = 10
import argparse
import os
from os.path import splitext
from PIL import Image
DEFAULT_SIZE = (220, 180)
# DEFAULT_SIZE = (300, 30)
# DEFAULT_SIZE = (300, 128)
#!/usr/bin/env lua
--https://www.tutorialspoint.com/lua/lua_quick_guide.htm
requests = require 'requests'
inspect = require 'inspect'
response = requests.get{'http://httpbin.org/get', timeout=1}
json_data = response.json()
@luiscoms
luiscoms / restartable_thread.py
Created April 2, 2019 18:06
RestartableThread from python
from threading import Thread
class RestartableThread(Thread):
def __init__(self, *args, **kwargs):
self.init_args, self.init_kwargs = args, kwargs
super(RestartableThread, self).__init__(*args, **kwargs)
def clone(self):
r = RestartableThread(*self.init_args, **self.init_kwargs)
@luiscoms
luiscoms / CHANGELOG-after.md
Last active July 13, 2018 14:53
Bumpversion example

CHANGELOG

1.1.0

  • The next big thing

1.0.1

@luiscoms
luiscoms / snap.sh
Last active November 1, 2017 12:51
Take a snapshot from machine
#!/bin/bash
# INIT
/bin/echo " - Start snapshot - "
/bin/date >> /opt/resources/snap-hard-`/bin/date -I`.out
/bin/echo " " >> /opt/resources/snap-hard-`/bin/date -I`.out
/bin/echo " " >> /opt/resources/snap-hard-`/bin/date -I`.out
@luiscoms
luiscoms / performance_algorithm.py
Created July 28, 2017 13:12
Python performance test
import timeit
black_list = ["status", "components", "exposed_id", "external_id", "gaucha_id", "publish_scheduled",
"created", "origin_link", "canonical", "friendly_title", "friendly_title_history"]
input_data = {
"x": 1,
"_id": 1,
"_created": 1,
"_updated": 1,
@luiscoms
luiscoms / .pypirc
Last active July 3, 2020 19:13
My pypirc
[distutils]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.python.org/pypi
username=luiscoms
password=
@luiscoms
luiscoms / .editorconfig
Last active July 25, 2019 12:56
Editor Config
# Se tiver essa diretiva, a recursividade para, ou seja,
# esse é o arquivo raiz da configuração
root = true
# Comentários podem começar com ; ou #
# Pra todos os arquivos
# [*]
# Para arquivos em extensões abaixo
[{*.{c,cpp,conf,cfg,js,py,php,sh},Makefile}]
# Defino que serão todos utf-8