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 calculadora_impuestos(ingresos): | |
irpf_escalones = { | |
12_450 : 0.19, | |
20_200 : 0.24, | |
35_200 : 0.30, | |
60_000 : 0.37, | |
300_000 : 0.45, | |
1e100 : 0.47 | |
} | |
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
javascript:(function(){ | |
document.querySelectorAll(".fc-dialog-container, .fc-dialog-overlay").forEach(e => {e.style.setProperty("display", "none", "important");}); | |
document.body.style.overflow = "visible"; | |
})() | |
// Add this as a bookmark to your bookmark bar |
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
from math import atan2, degrees, radians, sin, cos | |
def fit_text_as_geometry_between_two_points(text, A, B): | |
mid_coords = ((B[1] + A[1])/2, (B[0] + A[0])/2) | |
angle = atan2(B[1] - A[1], B[0] - A[0]) | |
bbox = LineString([A,B]).bounds | |
h = get_height(bbox) | |
w = get_width(bbox) | |
scale_factor = 100*(abs(h*sin(angle)) + abs(w*cos(angle))) | |
ml = text_as_geometry(text, mid_coords, scale_factor, degrees(angle)) | |
return ml |
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 numpy as np, pandas as pd | |
import freetype | |
from shapely.geometry import * | |
from shapely import affinity as aff | |
from cartoframes.viz import Layer | |
face = freetype.Face("Vera.ttf") # path to your font | |
face.set_char_size(3000, hres = 100) | |
# These parameters are ok for Vera, but should be adjusted for each font. | |
char_width = 1500 |
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
deadly_one_liner = ( | |
lambda r, n : print("".join( | |
["00" | |
if any((i == p[0] and j == p[1] for p in | |
(lambda r, n : [ | |
[round((lambda x : 1 - (x**2)/2 + x**4/(4*3*2) - x**6/(6*5*4*3*2))(2*3.1415/n*x)*r + n/2), | |
round((lambda x : x - (x**3)/6 + x**5/(5*4*3*2) - x**7/(7*6*5*4*3*2))(2*3.1415/n*x)*r + n/2)] | |
for x in range(-int(n/2),int(n/2))])(r,n))) | |
or (i == round(n/2) and j < n) or j == round(n/2) | |
or i == j or i == n - j |
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 pandas as pd | |
import numpy as np | |
from itertools import cycle | |
def generate_fake_dataframe(size, cols, col_names = None, intervals = None, seed = None): | |
categories_dict = {'animals': ['cow', 'rabbit', 'duck', 'shrimp', 'pig', 'goat', 'crab', 'deer', 'bee', 'sheep', 'fish', 'turkey', 'dove', 'chicken', 'horse'], | |
'names' : ['James', 'Mary', 'Robert', 'Patricia', 'John', 'Jennifer', 'Michael', 'Linda', 'William', 'Elizabeth', 'Ahmed', 'Barbara', 'Richard', 'Susan', 'Salomon', 'Juan Luis'], | |
'cities' : ['Stockholm', 'Denver', 'Moscow', 'Marseille', 'Palermo', 'Tokyo', 'Lisbon', 'Oslo', 'Nairobi', 'Río de Janeiro', 'Berlin', 'Bogotá', 'Manila', 'Madrid', 'Milwaukee'], | |
'colors' : ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple', 'pink', 'silver', 'gold', 'beige', 'brown', 'grey', 'black', 'white'] | |
} |
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 math, numpy as np | |
from math import factorial as fact | |
import statistics as stats | |
def prob_of_sum_gaussian(s,n): | |
mean = 3.5*n | |
std = np.sqrt(n*105/36) | |
normal_dist = stats.NormalDist(mean, std) | |
return normal_dist.pdf(s) |
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
proxy = "IP:PORT" | |
http_proxy = "http://" + proxy | |
https_proxy = "https://"+ proxy | |
ftp_proxy = "ftp://"+ proxy | |
proxyDict = { | |
"http" : http_proxy, | |
"https" : https_proxy, | |
"ftp" : ftp_proxy | |
} |
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
%load_ext autoreload | |
%autoreload 2 | |
import sys, os | |
file_path = r"\path\to\file.py" | |
path = os.path.dirname(file_path) | |
sys.path.append(path) | |
from file import * |
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
# run from the environment you want to add to jupyter. | |
# --name myenv is just the internal name ipykernel gives to the kernel | |
source activate myenv | |
python -m ipykernel install --user --name myenv --display-name "Python (myenv)" |
NewerOlder