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 | |
''' | |
Uma carta tem atributos valor e naipe:: | |
>>> c = Carta('A','ouros') | |
>>> c | |
<A de ouros> | |
Dado um baralho... :: |
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 sys | |
from math import sqrt | |
from random import uniform | |
TOTAL_DEFAULT = 10**6 | |
if len(sys.argv) == 2: | |
total = int(sys.argv[1]) | |
else: | |
total = TOTAL_DEFAULT |
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/env python | |
import sys | |
from random import uniform | |
TOTAL_DEFAULT = 10**6 | |
total = int(sys.argv[1]) if len(sys.argv) == 2 else TOTAL_DEFAULT | |
dentro = 0 |
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
def media(x, y): | |
return float(x + y)/2 | |
def raizq(x): | |
''' raiz quadrada pelo metodo de Newton ''' | |
chute = 1.0 | |
while abs(chute * chute - x) >= 0.0001: | |
chute = media(chute, float(x)/chute) | |
return chute |
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 | |
import random | |
import webbrowser | |
target = random.randrange(3, 483) | |
url = 'http://us.pycon.org/2012/review/%s/' % target | |
webbrowser.open(url) |
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 sys | |
from itertools import dropwhile | |
import re | |
START = re.compile(r'''<pycon_bot> ==== Talk (\d{1,3}): (.*?) now, (http://.*?) ====''') | |
VOTES = re.compile(r'''<pycon_bot> Talk Votes: (\d+) yays, (\d+) nays, (\d+) abstentions''') | |
DECISION = re.compile(r'''<pycon_bot> ==== Chair decision: talk (\w+)''') | |
LINE_FORMAT = '{talk_id:>3} {decision} {yays:>2} {nays:>2} {abst:>2} {title}' |
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 sys | |
from itertools import dropwhile | |
import re | |
START = re.compile(r'''<pycon_bot> ==== Talk (\d{1,3}): (.*?) now, (http://.*?) ====''') | |
VOTES = re.compile(r'''<pycon_bot> Talk Votes: (\d+) yays, (\d+) nays, (\d+) abstentions''') | |
DECISION = re.compile(r'''<pycon_bot> ==== Chair decision: talk (\w+)''') | |
LINE_FORMAT = '{talk_id:>3} {decision} {yays:>2} {nays:>2} {abst:>2} {title}' |
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 sys | |
import json | |
LINE_FORMAT = '{id:>3} {mark} {yay:>2} {nay:>2} {abstain:>2} {name}' | |
with open(sys.argv[1]) as json_in: | |
talks = json.load(json_in) | |
for talk in talks: | |
mark = {'rejected':'-', 'accepted': '+', 'poster': 'p' |
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 sys | |
import json | |
from itertools import dropwhile | |
LINE_FORMAT = '{id:>3} {mark} {yay:>2} {nay:>2} {abstain:>2} {name}' | |
with open(sys.argv[1]) as json_in: | |
talks = json.load(json_in) | |
for talk in dropwhile(lambda x:x['id']<264, talks): |
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
luciano@vogon:~$ sudo easy_install bottle | |
[sudo] password for luciano: | |
Searching for bottle | |
Reading http://pypi.python.org/simple/bottle/ | |
Reading http://bottlepy.org/ | |
[...] | |
Reading http://github.com/defnull/bottle | |
Best match: bottle 0.9.7 | |
Downloading http://pypi.python.org/packages/source/b/bottle/bottle-0.9.7.tar.gz#md5=eb4faa6a519251928e4bb737db4217ae | |
Processing bottle-0.9.7.tar.gz |
OlderNewer