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 sys | |
import argparse | |
from getpass import getpass | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
def navigate(card_number, user_name, passkey): | |
try: | |
browser = webdriver.Firefox() |
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
""" | |
IPython Magic to show sequence's indexes. | |
Useful to demonstrate how python indexes works with strings. | |
Example: | |
>>> %indexes henrique | |
0 1 2 3 4 5 6 7 | |
h e n r i q u e |
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
#!/usr/bin/python -tt | |
# coding: utf-8 | |
import argparse | |
from collections import Counter | |
import tkinter as tk | |
from tkinter.filedialog import askopenfile | |
from tkinter.scrolledtext import ScrolledText | |
def load(file): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/python -tt | |
import argparse | |
from collections import Counter | |
import re | |
def purge(word): | |
if not word.isalpha(): | |
word = ''.join(ch for ch in word if ch.isalpha()) | |
return word |
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 main(): | |
deck = Deck() | |
assert deck | |
assert len(deck) == 52 | |
assert Card(rank='2', suit='spades') == Card(rank='2', suit='spades') | |
assert deck[0] == Card(rank='2', suit='spades') | |
assert deck[:2] == [Card('2', 'spades'), Card('3', 'spades')] | |
assert deck[12::13] == [Card('A', 'spades'), Card('A', 'diamonds'), |
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 main(): | |
assert Vector(2, 4) | |
assert (Vector(2, 4).x, Vector(2, 4).y) == (2, 4) | |
assert repr(Vector(2, 4)) == 'Vector(2, 4)' | |
assert str(Vector(2, 4)) == '(2, 4)' | |
assert Vector(2, 4) == Vector(2, 4) | |
assert Vector(2, 4) + Vector(1, 2) == Vector(3, 6) | |
assert Vector(2, 4) * 2 == Vector(4, 8) |
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
# Exemplo com closure | |
def crazy_sum(): | |
acc = 0 | |
def wrapped(t): | |
nonlocal acc | |
sum_with_acc = sum(t) + acc | |
acc = max(0, sum_with_acc - 9) |
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 happy(number): | |
string = str(number) | |
digits = [int(char) for char in string] | |
squares = [digit**2 for digit in digits] | |
n = sum(squares) | |
if n >= 10: | |
return happy(n) | |
if n in (1, 7): |
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 | |
""" | |
Hackish Script to import MyFinance data into GNUCash | |
The order of things: | |
1) Load and Fix the MyFinance dataset | |
2) Separete the data into intermediary parts. | |
3) Define GNUCash helper function. | |
4) Define conversion highlevel functions. |