Skip to content

Instantly share code, notes, and snippets.

View tommylees112's full-sized avatar
๐Ÿ˜

Tommy Lees tommylees112

๐Ÿ˜
  • University of Oxford
  • Oxford
View GitHub Profile
@BertrandBordage
BertrandBordage / autoreplyer.py
Last active June 5, 2023 07:03
Automatically reply to unread and unanswered messages in Python
"""
Automatically replies to mails both unread and unanswered.
WARNING: This answers to any both unread and unanswered mail, even if it is years old.
Donโ€™t use on a mailbox with old messages left unread and unanswered.
Simply subclass ``AutoReplyer``, define the undefined class attribute,
and call the ``run`` method on an instance. This loops until you stop the script
(using Ctrl+C, typically) or until an error occurs, like a network failure.
@jdossgollin
jdossgollin / gen_extreme_value.stan
Last active December 27, 2022 13:50
Fit a univariate GEV distribution in stan
/*
Fit a GEV distribution in stan
Code is largely based on previous code by
Cameron Bracken: http://bechtel.colorado.edu/~bracken/tutorials/stan/
and Yenan Wu: http://discourse.mc-stan.org/t/troubles-in-rejecting-initial-value/1827
*/
functions{
real gev_lpdf(vector y, real mu, real sigma, real xi) {
vector[rows(y)] z;
vector[rows(y)] lp;
@PaulC91
PaulC91 / network_wc.R
Last active July 19, 2018 13:28
network graph of world cup players connected by club and country
library(rvest)
library(tidyverse)
library(tidygraph)
library(ggraph)
wc_squads <- html("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup_squads")
tables <- wc_squads %>%
html_table()
@ahartikainen
ahartikainen / prior_and_posterior.ipynb
Last active February 22, 2019 01:22
Simple example on PyStan
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nadya-p
nadya-p / pdf_to_text.py
Last active August 15, 2022 04:42
Extract text contents of PDF files recursively
from tika import parser
import os
def extract_text_from_pdfs_recursively(dir):
for root, dirs, files in os.walk(dir):
for file in files:
path_to_pdf = os.path.join(root, file)
[stem, ext] = os.path.splitext(path_to_pdf)
if ext == '.pdf':
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tommylees112
tommylees112 / clip_netcdf_to_shapefile.py
Created March 28, 2021 09:33
chopping a shapefile from netcdf files
"""
Mask xarray dataset using a shapefile [closed]
https://stackoverflow.com/a/64587946/9940782
"""
from typing import Tuple
import geopandas as gpd
import xarray as xr
import rasterio as rio
from pathlib import Path
import numpy as np
@tommylees112
tommylees112 / wave2web_env.sh
Last active October 28, 2021 15:09
Environment with rasterio, skimage, pytorch, xarray, networkx
conda create -n w2w python=3.8 --yes
conda activate w2w
conda install -c conda-forge pytorch xarray=0.16 pytorch torchvision cudatoolkit --yes
conda install dask --yes
conda install -c conda-forge rasterio scikit-image --yes
conda install -c conda-forge seaborn=0.11 --yes
conda install -c anaconda networkx --yes
conda install -c conda-forge zarr gcsfs netcdf4 numba tqdm jupyterlab tensorboard ipython pip ruamel.yaml descartes statsmodels scikit-learn black mypy --yes
conda install -c conda-forge geopandas --yes
conda install -c conda-forge cdsapi --yes