Skip to content

Instantly share code, notes, and snippets.

View moacirmoda's full-sized avatar

Moacir Moda moacirmoda

View GitHub Profile
file = "file.txt"
# ler linha a linha
for line in handle(file):
print line
# lendo o arquivo todo
with open(file) as handle:
data = handle.read()
# abrindo o arquivo para leitura
with open('test.txt') as handle:
# criando uma variável para armazenar a quantidade de linhas
lines = 0
# iterando, linha por linha, no aquivo de leitura
for line in handle:
# incrementando a variável de linhas
@moacirmoda
moacirmoda / instructions.md
Created May 3, 2016 15:09
Alteração de MySQL para Proethos2

Abaixo de:

# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!

Inserir as seguintes linhas:

innodb_file_format = Barracuda
innodb_file_per_table = 1
from bs4 import BeautifulSoup as bs
from datetime import datetime
import requests
import httplib
import socket
import ssl
init = datetime.now()
def connect_patched(self):
# https://github.com/moacirmoda/pygram/blob/master/pygram/api.py
from pygram.api import PyGram
users = (
('user1', 'pass1'),
('user2', 'pass2'),
)
apis = []
for username, password in users:
@moacirmoda
moacirmoda / query.sql
Created April 5, 2017 02:42
Query para extrair informações de partidas do European Soccer Database
select
c.name as country,
l.name as league,
t.team_long_name as home_team,
t2.team_long_name as away_team,
m.*
from "Match" m
inner join Country c ON c.id = m.country_id
inner JOIN League l ON l.id = m.league_id
import asyncio
from datetime import datetime
async def get_number(number):
await asyncio.sleep(1)
print("%s - %s" % (datetime.now(), number))
loop = asyncio.get_event_loop()
tasks = []
import asyncio
import requests
from datetime import datetime
async def get_number(number):
await asyncio.sleep(1)
print("%s - %s" % (datetime.now(), number))
response = requests.get("https://httpbin.org/get?number=%s" % number)
import asyncio
import requests
from datetime import datetime
def get_number(number):
print("%s - %s" % (datetime.now(), number))
response = requests.get("https://httpbin.org/get?number=%s" % number)
@moacirmoda
moacirmoda / query.py
Last active July 12, 2017 18:28
Poder do Peewee
emails = FactEmailMovement.select(FactEmailMovement, FactEmail, DimEmailAddress) \
.join(FactEmail) \
.join(FactDebtor) \
.join(DimDocument) \
.switch(FactEmail) \
.join(DimEmailAddress) \
.where(DimDocument.document == '12532825600')
"""
SELECT