Skip to content

Instantly share code, notes, and snippets.

View gileno's full-sized avatar

Gileno Filho gileno

View GitHub Profile
@gileno
gileno / select_all.js
Created March 13, 2014 21:43
Simples código para toggle em uma tabela
(function($) {
$.fn.selectAll = function(options) {
var defaults = {
inputs: 'input[name=ids]',
selectAll: "#select_all",
selected: false
};
var settings = $.extend(defaults, options);
return this.each(function(x) {
var table = $(this);
@gileno
gileno / forms.py
Created May 6, 2014 20:46
Django Many to Many CheckboxSelectMultiple
from django.forms.widgets import CheckboxSelectMultiple
from django import forms
from .models import Curriculo
class CurriculoForm(forms.ModelForm):
class Meta:
model = Curriculo
@gileno
gileno / main.java
Last active August 29, 2015 14:01
Comparativo de Ler Arquivo
package com.mkyong.io;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class BufferedReaderExample {
public static void main(String[] args) {
@gileno
gileno / classificacao.py
Created October 13, 2014 23:51
Questão de IP - SI
continuar = True
nome_vencedor = ''
pontos_vencedor = -1
vitorias_vencedor = -1
gols_a_favor_vencedor = -1
gols_sofridos_vencedor = -1
saldo_vencedor = None
while continuar:
@gileno
gileno / forms.py
Created January 16, 2015 16:53
Alterando atributos do widget no Form
from django import forms
class MeuForm(forms.Form):
campo1 = forms.CharField(label="Campo 1")
def __init__(self, *args, **kwargs):
super(MeuForm, self).__init__(*args, **kwargs)
self.fields["campo1"].widget.attrs["class"] = "classe_css1"
@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()
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 / 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/',
@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 / 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',
)