Skip to content

Instantly share code, notes, and snippets.

View luispedro's full-sized avatar

Luis Pedro Coelho luispedro

View GitHub Profile
from collections import namedtuple
import re
# From https://live.chessbase.com/en/CrossTable?id=fide-world-cup-2025&displayTitle=FIDE%20World%20Cup%202025%2C%20Goa
DATA = '''
Kovalev,V2557½1------1.5
Velten,P2530½0------0.5
Mekhitarian,K25450½------0.5
Petrov,M25401½------1.5
Can,E2552½00½----1
%matplotlib qt
from scipy.stats import pearsonr,spearmanr
from scipy import stats
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
data = pd.read_excel('./062109-1.xlsx', sheet_name=2)
data = data[data.columns[:12]]
@luispedro
luispedro / steps2024.py
Last active September 13, 2024 12:46
Steps in 2024
import pandas as pd
TARGET = 5_000_000
TARGET_RATE = TARGET / 366
data = [
('January', 31, 271_347),
('February', 29, 321_084),
('March', 31, 424_562),
('April', 30, 412_478),
('May', 31, 442_295),
@luispedro
luispedro / connect-qr-code.py
Last active July 8, 2023 19:09
Connect to a WiFi networks using a QR code
import re
import cv2
import subprocess
pat = re.compile(r'^WIFI:S:([^;]+);T:WPA;P:([^;]+);;')
detect = cv2.QRCodeDetector()
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
rval, frame = vc.read()
import COVID19Py
covid19 = COVID19Py.COVID19()
locations = covid19.getLocations(timelines=True)
UK = '2020-12-03T00:00:00Z'
EU = set(['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LU', 'MT', 'NL', 'PL', 'RO', 'SK', 'SI', 'ES', 'SE'])
tot = 0
for loc in locations:
if loc['country_code'] in EU:
tim = loc['timelines']['deaths']['timeline']

Keybase proof

I hereby claim:

  • I am luispedro on github.

  • I am luispedro (https://keybase.io/luispedro) on keybase.

  • I have a public key ASBto9ey42rmyXUsEJflex23RWhAlqOiCzmCroSke7XYigo

# %matplotlib qt
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
from matplotlib import style
style.use('default')
TOTAL_POP = 100_000
MAX_ITERS = 100_000
rho = 0.5
import pymc3 as pm
from scipy import stats
import numpy as np
NR_TESTS = 3330
POSITIVES = 50
PRE_NEG = 401
PRE_NEG_POS = 2
PRE_PLUS = 37+75+85
# for Emacs: -*- coding: utf-8 -*-
# Originally found on the internet. Not my work
include "%L"
# def emit(keys, codepoint, word):
# print ('<Multi_key> %s <period>\t: "%s"\tU%04X\t\t# CIRCLED DIGIT %s' %
# (keys, unichr(codepoint), codepoint, word)).encode('utf8')
@luispedro
luispedro / simulate-china-us-pop.py
Last active January 26, 2020 12:08
Simulate population
import numpy as np
# FROM
# http://worldpopulationreview.com/countries/china-population/
pyramid0china = np.array(
[16446861., 16821572., 17097250., 17284418., 17390933., 17423080.,
17403550., 17341743., 17247061., 17129365., 16998517., 16861620.,
16727156., 16605907., 16498945., 16404588., 16387661., 16480191.,