Skip to content

Instantly share code, notes, and snippets.

View luzfcb's full-sized avatar

Fábio C. Barrionuevo da Luz luzfcb

View GitHub Profile
repos:
- repo: https://github.com/browniebroke/django-codemod
# django-codemod is a tool to automatically
# fix Django deprecations.
# Any tag/version (>=1.9.1):
# https://github.com/browniebroke/django-codemod/tags
#
# Automatic execution of this hook has been disabled
# because it is a bit slow but its configuration is
# kept here so it can be easily run:
@luzfcb
luzfcb / dismiss_all_twitter_topics.js
Last active March 8, 2022 09:47
Dismiss all twitter topics
// Dismiss all topics listed on https://twitter.com/YOUR_USERNAME/topics
// 1 - open the https://twitter.com/YOUR_USERNAME/topics
// 2 - open the browser console (Press Command + Option + J (Mac) or Control + Shift + J (Windows and Linux))
// 3 - copy this code
// 4 - paste the code on the console to run
// 5 - reload the page and run step 4 and 5 again until you no longer see "Dismiss" messages
.DEFAULT_GOAL := help
help: ## show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
compile: ## Compile foobar
@echo "##### Compiling foobar"
repos:
- repo: https://github.com/browniebroke/django-codemod
# django-codemod is a tool to automatically
# fix Django deprecations.
# Any tag/version (>=1.5.6):
# https://github.com/browniebroke/django-codemod/tags
#
# Automatic execution of this hook has been disabled
# because it is a bit slow but its configuration is
# kept here so it can be easily run:
@luzfcb
luzfcb / fields.py
Last active September 29, 2021 18:08 — forked from ramsrib/fields.py
A form field to handle validation of image + svg in Django 3
from io import BytesIO
from defusedxml import ElementTree
from django.core.exceptions import ValidationError
from django.core.validators import (
FileExtensionValidator,
get_available_image_extensions,
)
from django.forms import ImageField as DjangoImageField
from PIL import Image
@luzfcb
luzfcb / desabilitar_microfone_bluetooth_headset.md
Last active September 23, 2021 13:20
Desabilitar microfone bluetooth headset HSP / HFP

dica: Se você tiver um microfone melhor e quiser desativar o microfone do seu headset bluetooth (e com isso fazer ele conectar em modo com audio de qualidade melhor)

echo -e "\n\n## desabilita modo HSP/HFP\n# https://web.archive.org/web/20210302172458/http://korepov.pro/infobase/linux/6\nDisable=Headset" | sudo tee --append /etc/bluetooth/input.conf

Depois:

mkdir -p "${HOME}/.config/pulse/"
@luzfcb
luzfcb / sqlprint.py
Last active September 5, 2022 21:53
sqlprint Format the SQL generated by Django Queryset and print to the console more human readable
def sqlprint(qs, explain=False):
"""
pip install sqlparse pygments
Format the SQL generated by Django Queryset and print to the console more human readable.
if you use pycharm, you can include this snippet in Pycharm Django Console
by pressing CRTL + ALT + S.
>>> from django.contrib.auth.models import User
>>> qs = User.objects.filter(username__in=['user1', 'user2'], groups__isnull=True).only('username')
>>> sqlprint(qs)
@luzfcb
luzfcb / template_LGPD.md
Last active July 11, 2025 17:24
Template LGPD - Template para solicitar exclusão de dados conforme a LGPD - Lei Geral de Proteção de Dados do brasil. LEI Nº 13.709, DE 14 DE AGOSTO DE 2018. Disclaimer: Não sou advogado e não me responsabilizo por qualquer coisa decorrente do uso desde conteudo. Use por sua conta e risco.

Olá <NOME_EMPRESA>.

Vocês estão me enviando <email, ligação, SMS, via plataforma Whatsapp, via plataforma Telegram> comerciais não-solicitados, portanto SPAM.

No dia vocês enviaram ao meu uma mensagem comércial, com o seguinte texto:

<MENSAGEM>
@luzfcb
luzfcb / celery_extras.py
Last active July 8, 2021 22:02
Rate limit control using requests . Celery, Python.
import functools
import inspect
import random
#
from celery.utils.log import get_task_logger
# https://github.com/jazzband/django-redis#raw-client-access
from django_redis import get_redis_connection
@luzfcb
luzfcb / celery_django_redis_ratelimit.py
Created June 19, 2021 13:27 — forked from Vigrond/celery_django_redis_ratelimit.py
Celery / Django / Redis Rate Limits done "as expected" - Simple SMTP Example
# Rate limiting with Celery + Django + Redis
# Multiple Fixed Windows Algorithm inspired by Figma https://www.figma.com/blog/an-alternative-approach-to-rate-limiting/
# and Celery's sometimes ambiguous, vague, and one-paragraph documentation
#
# Celery's Task is subclassed and the is_rate_okay function is added
# celery.py or however your App is implemented in Django
import os
import math