I hereby claim:
- I am colobas on github.
- I am colobas (https://keybase.io/colobas) on keybase.
- I have a public key whose fingerprint is DF91 A609 74D7 C174 822C F5EF EC7C 6ED6 33FB 288D
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import numpy as np | |
from sklearn.metrics import mutual_info_score | |
def calc_MI(x, y, bins): | |
c_xy = np.histogram2d(x, y, bins)[0] | |
mi = mutual_info_score(None, None, contingency=c_xy) | |
return mi | |
def calc_MI_matrix(A, bins) | |
n = A.shape[1] |
def retirement(s,y,n,r): | |
""" | |
Considering: | |
- You have 0 debt | |
- You make y per year (yearly income) | |
- You can save a fraction s per year | |
- You can invest at a r-1 yearly interest | |
This function returns the amount you have accumulated after n years. | |
This means you can live with (1-s)*y per year. |
#! /usr/bin/env python2 | |
import ctypes, re, sys | |
## Partial interface to ptrace(2), only for PTRACE_ATTACH and PTRACE_DETACH. | |
c_ptrace = ctypes.CDLL("libc.so.6").ptrace | |
c_pid_t = ctypes.c_int32 # This assumes pid_t is int32_t | |
c_ptrace.argtypes = [ctypes.c_int, c_pid_t, ctypes.c_void_p, ctypes.c_void_p] | |
def ptrace(attach, pid): | |
op = ctypes.c_int(16 if attach else 17) #PTRACE_ATTACH or PTRACE_DETACH | |
c_pid = c_pid_t(pid) |
words="$(echo | k2pdfopt nickel2016.pdf -h 20000 -w 1200 -pl 100 -pr 100 | grep -Eo "[0-9]* words" | grep -Eo "[0-9]*")" | |
let "reading_time = $words * 1.1 / 275" | |
reading_mins="$(printf "%.0f" $reading_time)" | |
if [[ $reading_mins -le 60 ]]; then | |
echo "approx reading time: $reading_mins mins" | |
else | |
let "hours = $reading_mins / 60" | |
let "mins = $reading_mins % 60" | |
echo "approx reading time: $hours h $mins mins" | |
fi |
[ | |
(7035, 0.145), | |
(20100-7035, 0.285), | |
(40200-20100, 0.37), | |
(80000-40200, 0.45), | |
("inf", 0.48) | |
] |
# credits to: https://stackoverflow.com/a/26209900 | |
def pretty(value, htchar='\t', lfchar='\n', indent=0): | |
nlch = lfchar + htchar * (indent + 1) | |
if type(value) is dict: | |
items = [ | |
nlch + repr(key) + ': ' + pretty(value[key], htchar, lfchar, indent + 1) | |
for key in value | |
] | |
return '{%s}' % (','.join(items) + lfchar + htchar * indent) | |
elif type(value) is list: |
from selenium import webdriver | |
import pyperclip | |
driver = webdriver.Chrome() | |
driver.get("http://192.168.1.218") | |
input("AUTHENTICATE AND GO TO PASSMAN PAGE") | |
table = driver.find_elements_by_class_name("credential-table")[0] | |
rows = table.find_elements_by_tag_name("tr") |
import time, sys | |
while True: | |
blah="⡿⣟⣯⣷⣾⣽⣻⢿" | |
for l in blah: | |
_ = sys.stdout.write(l) | |
_ = sys.stdout.flush() | |
_ = sys.stdout.write('\b') | |
time.sleep(0.2) |
import umap | |
import matplotlib.pyplot as plt | |
from mpl_toolkits.mplot3d import axes3d | |
def draw_umap(data, n_neighbors=15, min_dist=0.1, n_components=2, metric='euclidean', title='', color=None): | |
fit = umap.UMAP( | |
n_neighbors=n_neighbors, | |
min_dist=min_dist, | |
n_components=n_components, |