Skip to content

Instantly share code, notes, and snippets.

View lucasrcezimbra's full-sized avatar
🐍

Lucas Rangel Cezimbra lucasrcezimbra

🐍
View GitHub Profile
@lucasrcezimbra
lucasrcezimbra / django_compare_password_hashers.py
Created May 2, 2024 22:32
Django password hashers time comparison
"""
How to use:
1. poetry add django[bcrypt]
2. poetry run python contrib/compare_password_hashers.py
"""
import timeit
from uuid import uuid4
from django.conf import settings
from django.contrib.auth.hashers import (
"""
13. wordcount
Este desafio é um programa que conta palavras de um arquivo qualquer de duas
formas diferentes.
A. Lista todas as palavras por ordem alfabética indicando suas ocorrências.
Ou seja...
@lucasrcezimbra
lucasrcezimbra / conftest.py
Created May 8, 2021 19:08
pytest parameters
def pytest_addoption(parser):
parser.addoption('--headless', action='store_true')
@pytest.fixture(scope='module')
def headless(pytestconfig):
headless = pytestconfig.getoption('headless')
return headless
@lucasrcezimbra
lucasrcezimbra / django_static_recursive_delete.py
Created March 27, 2021 19:50
Recursive delete files from S3 via Django Storages
from django.core.files.storage import default_storage
def recursive_delete(fullpath):
dirs, files = default_storage.listdir(fullpath)
for file in files:
filepath = f'{fullpath}{file}'
print(f'deleting {filepath}')
default_storage.delete(filepath)
for dir in dirs:
@lucasrcezimbra
lucasrcezimbra / create_pdf.py
Created March 24, 2021 22:33 — forked from cantoniazzi/create_pdf.py
creating pdf with python and jinja
from jinja2 import Environment
from jinja2 import FileSystemLoader
from pdfkit import from_string
def create_pdf():
template_vars = {
'template_title': 'A template example',
'template_description': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit'
}
class cached_property(property):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.cache_name = f'_{self.fget.__name__}'
def __get__(self, obj, type):
if not hasattr(obj, self.cache_name):
value = super().__get__(obj, type)
setattr(obj, self.cache_name, value)
return getattr(obj, self.cache_name)
@lucasrcezimbra
lucasrcezimbra / snippet.html
Last active December 12, 2020 22:28
My social media links
<style>
a.social-media {
border-bottom: none;
}
img.social-media {
width: 35px;
height: 35px;
}
</style>
@lucasrcezimbra
lucasrcezimbra / .bumpversion.cfg
Created September 23, 2020 22:00
bump2version
[bumpversion]
current_version = 0.0.1
tag_name = {new_version}
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-rc.(?P<rc>\d+))?
serialize =
{major}.{minor}.{patch}-rc.{rc}
{major}.{minor}.{patch}
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: debug-statements
- id: end-of-file-fixer
@lucasrcezimbra
lucasrcezimbra / resposta_aos_novatos.md
Created April 20, 2018 20:27 — forked from luzfcb/resposta_aos_novatos.md
resposta aos iniciantes novatos pythonbrasil