Skip to content

Instantly share code, notes, and snippets.

View gutierri's full-sized avatar

Gutierri Barboza gutierri

View GitHub Profile
@gutierri
gutierri / migrate-django.md
Created February 25, 2019 20:46 — forked from sirodoht/migrate-django.md
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

@gutierri
gutierri / fix_permissions.py
Last active April 18, 2018 14:58 — forked from magopian/fix_permissions.py
Django admin command to "fix permissions" (create them properly for proxy models).This is needed because of the following bug in Django (not fixed as of 1.6): https://code.djangoproject.com/ticket/11154 (Work with Django > 1.6 and <= 1.9.X)
# -*- coding: utf-8 -*-
"""Add permissions for proxy model.
This is needed because of the bug https://code.djangoproject.com/ticket/11154
in Django (as of 1.6, it's not fixed).
When a permission is created for a proxy model, it actually creates if for it's
base model app_label (eg: for "article" instead of "about", for the About proxy
model).
@gutierri
gutierri / validate_cpf.js
Last active August 29, 2015 13:57 — forked from fabiomontefuscolo/gist:1095584
Validação de CPF
function validate_cpf(cpf) {
var sum, summod11;
cpf = cpf.replace(/[^0-9]/g, '');
if(cpf.length != 11 || cpf.match(/^([0-9])\1+$/)) {
return false;
}
// 9 primeiros digitos do cpf
var digit = Array.prototype.slice.call(cpf, 0, 9);