Skip to content

Instantly share code, notes, and snippets.

View maxwellamaral's full-sized avatar
😀

Maxwell Anderson maxwellamaral

😀
View GitHub Profile
@maxwellamaral
maxwellamaral / admin.py
Created September 6, 2022 12:38 — forked from maxwellcc/admin.py
Django: apagar a ação delete do admin
def get_actions(self, request):
actions = super().get_actions(request)
if 'delete_selected' in actions:
del actions['delete_selected']
return actions
@maxwellamaral
maxwellamaral / models.py
Created September 6, 2022 12:38 — forked from maxwellcc/models.py
Como criar um modelo Django que herde de classe pai como proxy, com restrições na consulta
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
age = models.PositiveIntegerField()
def __str__(self):
return self.first_name
class Majority(models.Manager):
@maxwellamaral
maxwellamaral / any_template.html
Created September 6, 2022 12:37 — forked from maxwellcc/any_template.html
Enviando emails atraves do Django, utilizando formulário
<!-- 4. Criar link no template html -->
<p>
<a href="{% url 'blog:post_share' post.id %}">Share this post</a>
</p>
update tabela
set nome = (replace(replace(replace(regexp_replace((initcap(nome)), '[^A-zÀ-ú]', ' ', 'g'),' Do ', ' do '), ' De ', ' de '), ' Da ', ' da '))
@maxwellamaral
maxwellamaral / remove_all.bat
Created September 6, 2022 12:37 — forked from maxwellcc/remove_all.bat
Apagando tudo no docker
docker ps -a | awk '{print $1}' | xargs docker stop
docker ps -a | awk '{print $1}' | xargs docker rm -f
docker images -a | awk '{print $3}' | xargs docker rmi -f
docker volume ls | awk '{print $2}' | xargs docker volume rm
docker network ls | awk '{print $2}' | xargs docker network rm
docker ps -a
docker images -a
docker volume ls
docker network ls
@maxwellamaral
maxwellamaral / config.html
Created September 6, 2022 12:37 — forked from maxwellcc/config.html
Requerido para evitar erros de validação no crispy quando usar formulários do Django
{% block js %}
<script>
{# Requerido para evitar erros de validação no crispy quando usar formulários do Django #}
$("#id-configForm").attr('novalidate', 'novalidate');
</script>
{% endblock %}
@maxwellamaral
maxwellamaral / configuration.yaml
Created September 6, 2022 12:36 — forked from maxwellcc/configuration.yaml
Configurando o home assistant para gerenciar o sistema de consumo de energia elétrica
# _ _ _ _ _
# | | | | /\ (_) | | | |
# | |__| | ___ _ __ ___ ___ / \ ___ ___ _ ___| |_ __ _ _ __ | |_
# | __ |/ _ \| '_ ` _ \ / _ \ / /\ \ / __/ __| / __| __/ _` | '_ \| __|
# | | | | (_) | | | | | | __/ / ____ \\__ \__ \ \__ \ || (_| | | | | |_
# |_| |_|\___/|_| |_| |_|\___| /_/ \_\___/___/_|___/\__\__,_|_| |_|\__|
#
# https://www.home-assistant.io/docs/configuration/basic/
# Configure a default setup of Home Assistant (frontend, api, etc)
@maxwellamaral
maxwellamaral / ha-uninstall.sh
Created September 6, 2022 12:36 — forked from maxwellcc/ha-uninstall.sh
Uninstaller for Home Assistant Supervised on Debian 10/11
#!/usr/bin/env bash
sudo systemctl disable apparmor
sudo systemctl disable hassio-apparmor.service
sudo systemctl disable hassio-supervisor.service
sudo systemctl daemon-reload
sudo systemctl reset-failed
sudo rm /etc/systemd/system/hassio-supervisor.service
sudo rm /etc/systemd/system/hassio-apparmor.service
@maxwellamaral
maxwellamaral / procedimento.md
Created September 6, 2022 12:36 — forked from maxwellcc/procedimento.md
Erro 'Elemento não encontrado' ao tentar utilizar ou converter uma distro Linux do WSL 1 para o WSL 2.

Erro 'Elemento não encontrado' ao tentar utilizar ou converter uma distro Linux do WSL 1 para o WSL 2.

WslRegisterDistribution failed with error: 0x80070490
Error: 0x80070490 Elemento não encontrado.

Olá! Eu estive um pouco angustiado com esse problema e como eu não encontrei uma solução, eu resolvi tentar por conta própria. Eu estou usando Windows 10 21H2 e esta tentativa foi realizada em 21/05/2022. Eu segui estes passos e obtive sucesso:

  1. Eu desinstalei as distros utilizando o comando > wsl --unregister <Distro>
  2. Eu desinstalei o Docker
@maxwellamaral
maxwellamaral / readme.md
Created September 6, 2022 12:35 — forked from maxwellcc/readme.md
List of Tuya devices with codes for Home Assistant