This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Static spekaer page generator for www.conadev.com | |
Author: Raphael Passini <raphapassini[at]gmail[dot]com> | |
""" | |
from jinja2 import Template | |
from slugify import slugify | |
html = open('speaker-template.html', 'r').read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ladroes = set(['lula', 'dilma', 'pt']) | |
tempo = set(['clima', 'tempo', 'temperatura']) | |
pets = set(['gato', 'cachorro', 'papagaio']) | |
frase = 'eu gosto do clima' | |
frase_set = set(frase.split()) | |
for s in [ladroes, tempo, pets]: | |
if s & frase_set: | |
print 'Encontrei a string que procurava' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:UTF-8 -*- | |
from collections import namedtuple | |
import csv | |
def devolve_livro(codigo): | |
"""Remove um livro do arquivo csv. Retorna uma lista | |
dos livros que ainda estão emprestados. | |
Args: | |
codigo (str): Codigo do livro para remover removido |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:UTF-8 -*- | |
import sqlite3 | |
conn = sqlite3.connect('meubanco.db') | |
conn.text_factory = str | |
cursor = conn.cursor() | |
# cria a tabela no banco de dados | |
# é necessário um try pois depois da primeira | |
# execuçaõ do script a tabela já vai estar criada |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
class User(Document): | |
image = ImageField() | |
# views.py | |
image = open('/path/to/your/file', 'rb') | |
user = User() | |
user.image.put(image, content_type = 'image/jpeg') | |
user.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lista1 = [10, 20, 30, 40] | |
lista2 = [10, 30, 100, 110, 44] | |
resultado = set(lista1) - set(lista2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import scrapy | |
from scrapy import Request | |
from scrapy.linkextractors import LinkExtractor | |
from keywords import ocean_keywords as keywords | |
class BBCSpider(scrapy.Spider): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import re | |
from os import listdir | |
from os.path import isfile, join | |
def main(): | |
folder = './logs' | |
onlyfiles = [f for f in listdir(folder) if isfile(join(folder, f))] | |
log_files = filter( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Controlador(object): | |
def __init__(self): | |
self.fila_avioes = {'tam': 'rjo-spo', 'azul': 'rjo-miami', 'gol':'rjo-bsa'} | |
self.num_avioes = len(fila_avioes) | |
#a)listar os números de avioes esperando para decolar: | |
def listar(self) | |
for chave in fila_avioes: | |
print (self.num_avioes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Construtor import * | |
def usuario_seleciona_uma_opcao(): | |
print('*'*23 + '*'*10 + ' CONTROLADOR DE VOO - IFSP ' + '*'*22 + '\n'*2) | |
NU = input('Escolha uma opção desejada:\n 1) Listar o número de aviões\n 2) Autorizar a decolagem do primeiro avião\n 3) Adicionar avião na fila de espera\n 4) Listar todos os aviões na fila de espera\n 5) Listar todas as características do primeiro avião\n 6) Sair\n Sua Opção: ') | |
return NU | |
if __name__ == "__main__": | |
opcao = usuario_seleciona_uma_opcao() |
OlderNewer