Skip to content

Instantly share code, notes, and snippets.

View gilsondev's full-sized avatar
💼
Work

Gilson Filho gilsondev

💼
Work
View GitHub Profile
@gilsondev
gilsondev / command_cat.rst
Created October 15, 2013 19:31
Inserir conteúdo em arquivo usando comando cat e comando de redirecionamento

Usando cat e redirecionamento para inserir texto

Use da seguinte forma:

$ echo cat <<EOF > .env
> DEBUG=True
> PORT=8000
> EOF
@gilsondev
gilsondev / settings.py
Created October 21, 2013 23:01
Configurações de projetos django que usa variáveis de ambiente para armazenar os valores. Recomendável para Heroku principalmente.
# -*- coding: utf-8 -*-
import os
import dj_database_url
from unipath import Path
PROJECT_PATH = Path(__file__).parent
@gilsondev
gilsondev / gist:7379549
Created November 8, 2013 23:57 — forked from jacobh/gist:2842966
Template used for form fields with twitter bootstrap
{% for field in form %}
<div class="control-group {% if field.errors %}error{% endif %}">
<label class="control-label" for="{{ field.html_name }}">{{ field.label }}</label>
<div class="controls">
{{ field }}
{% if field.errors %}
<span class="help-inline">{{ field.errors|first }}</span>
{% endif %}
{% if field.help_text %}
<p class="help-block">{{ field.help_text }}</p>
@gilsondev
gilsondev / README.md
Last active December 31, 2015 01:29 — forked from myaser/README.md

Testing abstract models

a TestCase subclass to help you test your abstract django models

usage:

1- subclass your django abstract models

@gilsondev
gilsondev / laravel_project.sh
Last active January 1, 2016 06:39
Script created to facilitate the creation of a project laravel using composer.
#!/bin/bash
# File: laravel_project.sh
# Description: Script created to facilitate the creation of a project laravel using composer.
#
# Use: ./laravel_project <project name>
#
green='\e[0;32m' # '\e[1;32m' is too bright for white bg.
endColor='\e[0m'
@gilsondev
gilsondev / views_delete.py
Created March 13, 2014 02:10
Class based view created to ignore confirm delete page
class CourseDelete(DeleteView):
model = Course
success_url = reverse_lazy('app:success_url')
def get(self, *args, **kwargs):
"""Override to ignore confirm delete page"""
return self.post(*args, **kwargs)
# install Pillow on Mac
CFLAGS=-I/usr/X11/include/freetype2/ pip install Pillow

How to migrate using south.

Lets say we got two apps: common and specific:

myproject/
|-- common
|   |-- migrations
|   |   |-- 0001_initial.py
|   |   `-- 0002_create_cat.py
@gilsondev
gilsondev / glossary.py
Last active August 29, 2015 14:06
Organizing queryset with alphabetical groups. The glossary style
import string
glossary = []
object_list = Model.objects.all()
for letter in string.ascii_uppercase:
entries = filter(lambda c: letter == c.word[0], object_list)
letter_list = {'letter': letter, 'entries': entries}
glossary.append(letter_list)
@gilsondev
gilsondev / web_app_30.xml
Created January 9, 2015 01:32
Header of web.xml to Java projects that use 3.0 version
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Web Application with 3.0 version</display-name>
</web-app>