Skip to content

Instantly share code, notes, and snippets.

View gileno's full-sized avatar

Gileno Filho gileno

View GitHub Profile
@gileno
gileno / middleware.py
Last active August 29, 2015 14:25
Middlware
from django.conf import settings
from django.http import Http404
class MeuMiddleware(object):
def process_request(self, request):
if request.META["REMOTE_ADDR"] in settings.IPS_PERMITIDOS:
pass
else:
raise Http404
@gileno
gileno / pipelines.py
Last active September 18, 2015 22:18
Blog post VII
# -*- coding: utf-8 -*-
import rethinkdb as r
class RethinkdbPipeline(object):
conn = None
rethinkdb_settings = {}
@gileno
gileno / olx.py
Created June 29, 2015 00:48
Blog post VI
# -*- coding: utf-8 -*-
import scrapy
class OlxSpider(scrapy.Spider):
name = "olx"
allowed_domains = ["pe.olx.com.br"]
start_urls = (
'http://pe.olx.com.br/imoveis/aluguel',
)
@gileno
gileno / olx.py
Last active August 29, 2015 14:23
Scrapy blog post V
# -*- coding: utf-8 -*-
import scrapy
class OlxSpider(scrapy.Spider):
name = "olx"
allowed_domains = ["pe.olx.com.br"]
start_urls = (
'http://pe.olx.com.br/imoveis/aluguel',
)
@gileno
gileno / olx.py
Last active August 29, 2015 14:23
Scrapy blog post IV
# -*- coding: utf-8 -*-
import scrapy
class OlxSpider(scrapy.Spider):
name = "olx"
allowed_domains = ["pe.olx.com.br"]
start_urls = (
'http://pe.olx.com.br/imoveis/aluguel',
)
@gileno
gileno / olx.py
Created June 22, 2015 22:42
Scrapy blog post III
# -*- coding: utf-8 -*-
import scrapy
class OlxSpider(scrapy.Spider):
name = "olx"
allowed_domains = ["pe.olx.com.br"]
start_urls = (
'http://pe.olx.com.br/imoveis/aluguel',
)
@gileno
gileno / gilenofilho.py
Created June 22, 2015 21:41
Scrapy blog post II
# -*- coding: utf-8 -*-
import scrapy
class GilenoFilhoSpider(scrapy.Spider):
name = "gilenofilho"
allowed_domains = ["gilenofilho.com.br"]
def starts_requests(self):
@gileno
gileno / gilenofillho.py
Created June 22, 2015 21:31
Scrapy post blog I
# -*- coding: utf-8 -*-
import scrapy
class GilenoFilhoSpider(scrapy.Spider):
name = "gilenofilho"
allowed_domains = ["gilenofilho.com.br"]
start_urls = (
'http://www.gilenofilho.com.br/',
from django import forms
class MeuForm(forms.Form):
meu_campo = forms.CharField(
error_messages={'required': 'Este campo de ser preenchido'}
)
meu_campo2 = forms.IntegerField(
error_messages={'required': 'Este campo de ser preenchido', 'invalid': 'Informe um número válido'}
@gileno
gileno / report.py
Last active August 29, 2015 14:13
Exemplo Reportlab Canvas
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
c = canvas.Canvas("hello.pdf")
c.setFont("Helvetica", 40)
c.drawString(3*inch, 3*inch, "Hello World")
c.showPage()
c.save()