Hierarchical bayesian model without packages

I'm attempting to build a hierarchical Bayesian model. For various reasons (including my own edification), I want to do this from scratch (i.e., without using the various packages and libraries written for this purpose). However, all the examples and tutorials I've come across make use of Stan, JAGS, PyMC3, etc. Does anyone know of or have an example of a working script that implements a simple hierarchical Bayesian model? Preferably it would be written in either python, R, or Matlab.

It's really good, and he even has a github repo called minimcmc which does some sampling. If you are interested in MCMC/HMC, I would start there.