Skip to content

Instantly share code, notes, and snippets.

View maxdevblock's full-sized avatar
☮️
peace, no war

MaxDevBlock maxdevblock

☮️
peace, no war
View GitHub Profile
@maxdevblock
maxdevblock / onlinenow.py
Created February 19, 2019 16:09 — forked from dfalk/onlinenow.py
django online users
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth.models import User
ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15)
ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50)
def get_online_now(self):
return User.objects.filter(id__in=self.online_now_ids or [])
@maxdevblock
maxdevblock / stan_demo.py
Created June 1, 2020 07:41 — forked from sergiosonline/stan_demo.py
Jupyter Notebook accompanying "Painless Introduction to Applied Bayesian Inference Using PyStan"
#!/usr/bin/env python
# coding: utf-8
# # Intro to PyStan
# Stan is a computation engine for Bayesian model fitting. It relies on HMC to sample from the posterior distribution of the desired model.
#
# Here are the detailed installation steps to set up Stan: https://pystan.readthedocs.io/en/latest/installation_beginner.html
#
# For MacOS:
@maxdevblock
maxdevblock / last_Rt.py
Last active November 22, 2020 23:47
Estimate last Effective Reproduction Number with Wallinga-Teunis method
import numpy as np
import scipy.stats as sps
def last_Rt_simulation(incidence,
SI_sh, SI_ra,
ci=.95, samples=1000):
"""
***********************************
* Max Pierini - EpiData.it - 2020 *
@maxdevblock
maxdevblock / IE01.py
Last active October 19, 2022 16:15
Table of events and intersections
A B C AB AC BC ABC
A . . . . . . .
B . . . . . . .
C . . . . . . .
AB . . . . . . .
AC . . . . . . .
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
B . . . . . . .
C . . . . . . .
AB . . . . . . .
AC . . . . . . .
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
+B 1 1 . 2 1 1 2
C . . . . . . .
AB . . . . . . .
AC . . . . . . .
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
+B 1 1 . 2 1 1 2
+C 1 1 1 2 2 2 3
AB . . . . . . .
AC . . . . . . .
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
+B 1 1 . 2 1 1 2
+C 1 1 1 2 2 2 3
-AB 1 1 1 1 2 2 2
AC . . . . . . .
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
+B 1 1 . 2 1 1 2
+C 1 1 1 2 2 2 3
-AB 1 1 1 1 2 2 2
-AC 1 1 1 1 1 2 1
BC . . . . . . .
ABC . . . . . . .
A B C AB AC BC ABC
+A 1 . . 1 1 . 1
+B 1 1 . 2 1 1 2
+C 1 1 1 2 2 2 3
-AB 1 1 1 1 2 2 2
-AC 1 1 1 1 1 2 1
-BC 1 1 1 1 1 1 0
ABC . . . . . . .