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 diagrams import Diagram, Cluster | |
from diagrams.aws.compute import EC2 | |
from diagrams.aws.network import ELB | |
with Diagram("Simple Website Diagram", direction='TB') as diag: | |
API = ELB("API") | |
piton = ELB("Python") | |
with Cluster("Webserver Cluster"): | |
svc_group = [EC2("Spotify"),EC2("Shazam!"),EC2("YouTube"),EC2("REWIND!")] | |
API >> piton >> svc_group |
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 bs4 import BeautifulSoup | |
import spotipy, requests | |
from spotipy.oauth2 import SpotifyClientCredentials | |
def get_cuerda(artista, cancion): | |
martista = artista.lower().replace(' ','_') | |
mcancion = cancion.lower().replace(' ','_') | |
url = f'https://acordes.lacuerda.net/{martista}/{mcancion}' | |
bs = BeautifulSoup(requests.get(url).text, 'lxml') |
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 goblet import Goblet, goblet_entrypoint | |
app = Goblet(function_name="goblet_example") | |
goblet_entrypoint(app) | |
@app.route('/home') | |
def home(): | |
return {"hello": "world"} |
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 numba import jit | |
@jit(nopython=True) | |
def psum(p): | |
acc = 0 | |
for i in range(1,1000000): | |
acc += pow(i, -p) | |
return acc | |
import time |
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 pickle, requests, time | |
from bs4 import BeautifulSoup | |
import pandas as pd | |
def tit(html): | |
tt0=BeautifulSoup(html,'lxml').find_all('meta', attrs={'property': 'og:title'})[0] | |
return tt0['content'] | |
def apo(html): | |
idx = html.index('Cuenta con') |
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 numpy as np | |
from operator import itemgetter | |
LOCAL = 0.5; EMPATE = 0.3; VISITA = 0.2 | |
pos = {'BRA': 33, 'ARG':25, 'ECU':20, 'CHI':16, 'COL':16, | |
'URU': 16, 'PER':14, 'PAR': 12, 'BOL':12 , 'VEN':7 } | |
rem = [('URU','ARG'),('ARG','BRA'), ### CHECK ORDER OF ARG'BRA | |
('BOL','URU'),('VEN','PER'),('COL','PAR'),('ARG','BRA'),('CHI','ECU'), | |
('CHI','ARG'),('COL','PER'),('ECU','BRA'),('PAR','URU'),('VEN','BOL'), |
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 time | |
t0=time.time() | |
psum=[(p,sum(pow(ix,-p) for ix in range(1,1000000))) for p in range(2,20)] | |
print(psum, time.time()-t0) # on my HP (2-20)x1M takes 4.5s |
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 glob | |
from PyPDF2 import PdfFileMerger | |
merger = PdfFileMerger() | |
for fn in glob.glob('*.pdf'): | |
merger.append(fn) | |
merger.write('merged.pdf') | |
merger.close() |
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 os, time, pandas as pd | |
carpeta_salida = 'geocgr' | |
comunas = pd.read_excel('s3://corporacionciudades/cut_2018_v03.xls') # esto debiera vivir en una API | |
print(f'TOTAL comunas: {len(comunas)}') | |
#fuente: http://www.subdere.gov.cl/sites/default/files/documentos/cut_2018_v03.xls | |
url_base='https://www.contraloria.cl/opencgrapp/geocgr/api/comunas/%05d/newobras' | |
t0 = time.time() | |
sdf = pd.DataFrame() |
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 matplotlib.pyplot as plt | |
conn=sqlite3.connect('revlocal.db') | |
sqloc = lambda q: pd.read_sql(q, conn) | |
odf = sqloc('SELECT * FROM stats_v1 ORDER BY Ocupación_Promedio DESC') | |
#odf=odf[odf.Ocupación_Minima>0]; | |
odf=odf[odf.Ocupación_Máxima<1.20] | |
fig = plt.figure(figsize=(20,16));odf['cod_hotel']=odf['cod_hotel'].apply(lambda x: x.rstrip()) | |
plt.hlines(y=odf['cod_hotel'],xmin=0, xmax = 100*odf['Ocupación_Promedio'], lw=8, color='cyan') #, color=my_color,linewidth=3, alpha =0.8) |