Skip to content

Instantly share code, notes, and snippets.

View rmminusrslash's full-sized avatar

rmminusrslash

View GitHub Profile
@rmminusrslash
rmminusrslash / gist:77ed5795070fbec644b3acff07f1e7da
Last active December 1, 2022 12:19
add request id to all log lines
from loguru import logger
def task():
logger.info("Processing!")
if __name__ == "__main__":
# remove default logger
logger.remove(0)
from prometheus_client import Histogram
h = Histogram('request_latency_seconds', 'Description of histogram')
h.observe(4.7) # Observe 4.7 (seconds in this case)
@rmminusrslash
rmminusrslash / gist:16e20739ba8c2d06bdba1f696e409dfd
Last active January 3, 2019 13:46
DIscover conda kernels in jupyter
environment must have
ipykernel
import numpy as np
from matplotlib import pylab as plt
#from mpltools import style # uncomment for prettier plots
#style.use(['ggplot'])
# generate all bernoulli rewards ahead of time
def generate_bernoulli_bandit_data(num_samples,K):
CTRs_that_generated_data = np.tile(np.random.rand(K),(num_samples,1))
true_rewards = np.random.rand(num_samples,K) < CTRs_that_generated_data
return true_rewards,CTRs_that_generated_data