Skip to content

Instantly share code, notes, and snippets.

View mateuspadua's full-sized avatar

Mateus Pádua mateuspadua

View GitHub Profile
// If you using SweetAlert2 (Swal) and JQuery you can replace all alert and confirm that way.
// https://limonte.github.io/sweetalert2/
// TIP: if you aren't using JQuery, use native JavaScript to create extend method. As bellow:
/*
function extend(a, b){
for(var key in b)
if(b.hasOwnProperty(key))
a[key] = b[key];
return a;
}
@mateuspadua
mateuspadua / gist:491590b5c33ebad11e834a9fa5c4bbb9
Created February 16, 2017 17:19 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@mateuspadua
mateuspadua / .flake8
Last active February 11, 2020 16:39
How add pre-commit on project
[flake8]
max-line-length = 88
exclude=*/migrations/*
@mateuspadua
mateuspadua / db_timestamp_auto_now_field.py
Last active July 19, 2022 14:03
Create a DateTimeField managed by MySQL and not by Django.
from datetime import datetime
from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper
class DBTimestampAutoNowField(models.DateTimeField):
"""
Cria um DateTimeField que é representado no banco de dados como um TIMESTAMP,
que é atualizado a cada modificação na instância, com a data atual com uma precisão
de milisegundos.
Essa atualização é gerenciada pelo próprio MySQL e não pelo Django, garantindo