Skip to content

Instantly share code, notes, and snippets.

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

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@rg3915
rg3915 / README.md
Created August 31, 2023 11:52
redirect with LoginRequiredMixin
@rg3915
rg3915 / Document.gif
Last active July 29, 2023 17:34
input suggestion text autocomplete AlpineJS suggestion
Document.gif
@rg3915
rg3915 / atable2.gif
Last active September 8, 2023 01:57
table insert row insere linha tabela AlpineJS
atable2.gif
@rg3915
rg3915 / choices.py
Created July 25, 2023 19:18
Django Manager QuerySet ativo
from django.db.models import TextChoices
from django.utils.translation import gettext
class TipoPessoaChoice(TextChoices):
F = "F", gettext("Pessoa Fisica")
J = "J", gettext("Pessoa Juridica")
@rg3915
rg3915 / chat.html
Last active July 22, 2023 09:30
chat tailwindCSS
<div class="fixed bottom-4 right-8 border border-gray-200 rounded-lg shadow-md">
<div class="container mx-auto">
<!-- Chat container -->
<div class="container mx-auto">
<!-- Flex container -->
<div class="flex">
<!-- First div -->
<div class="w-1/2 p-4">
<!-- lista de contatos -->
<div class="container mx-auto p-4">
@rg3915
rg3915 / models.py
Last active July 15, 2023 11:20
model serializable_value to_dict Django - Como gerar um dicionário serializável de um objeto automaticamente com serializable_value
class MyModel(models.Model):
# Como gerar um dicionário serializável de um objeto automaticamente com serializable_value
# https://stackoverflow.com/a/39384659/802542
...
def to_dict(self, exclude=[]):
# https://stackoverflow.com/a/39384659/802542
tree = {}
for field in self._meta.fields:
if field.name in exclude:
@rg3915
rg3915 / README.md
Created July 14, 2023 06:53
AlpineJS Javascript Alpine Expression Error: Cannot read properties of undefined - Elvis Operator

AlpineJS Javascript Alpine Expression Error: Cannot read properties of undefined - Elvis Operator

<span x-text="object.context.vencedor?.fornecedor?.shortuuid"></span>

Elvis Operator

@rg3915
rg3915 / models.py
Created July 12, 2023 09:50
get_issues
class Sprint(UuidModel, TimeStampedModel):
title = models.CharField(max_length=100, null=True, blank=True)
project = models.ForeignKey(
Project,
on_delete=models.CASCADE,
related_name='sprints',
)
def get_issues(self):
return self.issue_set.all()
@rg3915
rg3915 / index.html
Created July 3, 2023 02:14
dark mode switcher
<html class="">
<head>
<!-- A diferença é que o JS precisa ser carregado antes. -->
<script src="{% static 'js/switcher.js' %}"></script>
</head>
<body>
<div id="switcher" class="dark-mode-switcher cursor-pointer shadow-md fixed bottom-0 right-0 box dark:bg-dark-2 border rounded-full w-40 h-12 flex items-center justify-center z-50 mb-10 mr-10">
<!-- classes do TailwindCSS -->
@rg3915
rg3915 / main.sh
Created July 2, 2023 08:30
Copy and rename files recursively
find backend/core/templates -type f -name "*_*" -exec bash -c 'mv "$0" "${0//_/-}"' {} \;
find backend/core/templates -type f -name "*_light_*" -exec bash -c 'mv "$0" "${0//_light_/_}"' {} \;