This file contains hidden or 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
voo = [ | |
('KLM75', 'Amsterdam', '14:35', '60', '50'), | |
('AF111', 'Paris', '14:20', ' 50', '64'), | |
('LH333', 'Frankfurt', '14:10', '112', '203'), | |
('KLM71', 'Madrid', '14:55', '120', '100'), | |
('TAP103', 'Salvador', '15:20', '174', '210'), | |
('KLM79', 'Sofia','09:30','113','13'), | |
('LH123', 'Berlin', '15:10', '115', '210')] | |
voo.sort(lambda x, y: cmp(x[2], y[2])) |
This file contains hidden or 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
dados = [dict(id=1,name='slex',year=25+i) for i in xrange(10)] | |
def view1(items): | |
return [ | |
dict( | |
id=item['id'], | |
name=item['name'], | |
year=item['year'], | |
) |
This file contains hidden or 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 -*- | |
# by [email protected] | |
# =) | |
def infinity(): | |
# Ao infinito e alem ... | |
i = 0 | |
while True: | |
i += 1 | |
yield i |
This file contains hidden or 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 pprint | |
conteudo = """ | |
<?xml encoding="utf-8"?> | |
<Bola> | |
<Imovel> | |
<sssss>asdasd</sssss> | |
<AAAA>asdasd</AAAA> | |
</Imovel> | |
<Imovel>2<!--Bolas?><?<# --></Imovel> | |
<Imovel>3</Imovel> |
This file contains hidden or 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 -*- | |
# da_urllib.py | |
# by [email protected] | |
import urllib | |
def urldencode(params): | |
resp = {} | |
for item in params.split('&'): | |
if not item: |
This file contains hidden or 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 -*- | |
"""Renomeia pastas de acordo com uma tag de um arquivo dentro da pasta.""" | |
# renomeia_pastas.py | |
import unicodedata | |
import glob | |
import os | |
def remove_accents(s): | |
"""Remove acentos de uma string.""" |
This file contains hidden or 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 -*- | |
"""Fecha todas as janelas pelo nome.""" | |
from gi.repository import Gtk, Wnck | |
import os | |
Gtk.init([]) | |
screen = Wnck.Screen.get_default() | |
screen.force_update() |
This file contains hidden or 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
def template(html, **params): | |
import jinja2 | |
env = jinja2.Environment(loader=FileSystemLoader('')) | |
def tojson(s): | |
import json | |
return json.dumps(s) | |
env.filters['tojson'] = tojson |
This file contains hidden or 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 requests | |
def busca_noticias(url, limit=10, debug=False): | |
offset = 0 | |
while True: | |
urlget = url.format(limit=limit, offset=offset) | |
if debug: | |
print('#### GET: ' + urlget) | |
resp = requests.get(urlget).json() | |
for noticia in resp['ok']['noticias']: |
This file contains hidden or 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 -*- | |
"""Implements semaphoro to control atomic blocks on file.""" | |
# by [email protected] | |
import os | |
import sys | |
import uuid | |
import time | |
import signal | |
OlderNewer