Skip to content

Instantly share code, notes, and snippets.

View douglasmiranda's full-sized avatar
👽

Douglas Miranda douglasmiranda

👽
  • Earth, Brazil
View GitHub Profile
@douglasmiranda
douglasmiranda / option1.py
Last active April 25, 2024 09:10
Fix: Django Debug Toolbar not showing when using with Docker.
# YOU MAY WANT TO CHECK THIS OUT: https://github.com/douglasmiranda/ddpt/blob/master/{{cookiecutter.django_project_name}}/{{cookiecutter.django_project_name}}/config/local.py
# If you don't do this you will have to add the host IP in INTERNAL_IPS = ('127.0.0.1',)
# And it will change, then you will have to change INTERNAL_IPS again.
def show_toolbar(request):
if request.is_ajax():
return False
return True
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
{{ form.media }}
</head>
<body>
<form action="" method="post">
INSTALL JAVA
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
--
# ubuntu 64bits issue
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
@douglasmiranda
douglasmiranda / gist:7186775
Created October 27, 2013 19:23
Comandos ubuntu
http://www.ubuntubrsc.com/13-principais-comandos-do-ubuntu.html
Atualizar a lista de pacotes: sudo apt-get update
Efetua a atualização: sudo apt-get upgrade
Instalar pacotes: sudo apt-get install nome do pacote
Procurar pacotes: apt-cache search palavras chave
Procurar por dependências inválidas: sudo apt-get check
Corrigir problemas de dependências, concluir instalação de pacotes pendentes e outros erros: sudo apt-get -f install
Se o comando sudo apt-get -f install não resolver use: sudo dpkg -i –force-all para forçar a instalação ou sudo dpkg -r nome do pacote para desistir da instalação
sudo apt-get build-dep python-sympy python-scipy python-matplotlib python-pandas python-nose
@douglasmiranda
douglasmiranda / gist:6410163
Created September 2, 2013 07:38
Deleting Django South Migration (poor memory)
$ python manage.py shell
>>> from south.models import MigrationHistory
>>> m = MigrationHistory.objects.get(migration='<migration_name>')
>>> m.delete()
from django import forms
from .models import ExampleModel
class LocalizeMixin(object):
def __init__(self, *args, **kwargs):
super(LocalizeMixin, self).__init__(*args, **kwargs)
fields = self.Meta.localized_fields
if fields:
for field in fields:
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@douglasmiranda
douglasmiranda / gist:5573742
Created May 14, 2013 04:41
How to change the message of your last commit
git commit --amend
more info: http://git-scm.com/book/en/Git-Basics-Undoing-Things
# O select você faz normal usando o 'using' para indicar a database específica
# algo como: Usuario.objects.using('database_test')
from django import forms
# ...
class UsuarioForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ContentForm, self).__init__(*args, **kwargs)
self.fields["user"].queryset = Usuario.objects.using('database_test')