Skip to content

Instantly share code, notes, and snippets.

View MilesCranmer's full-sized avatar

Miles Cranmer MilesCranmer

View GitHub Profile
@pat-alt
pat-alt / cp_sr.jl
Last active July 31, 2023 09:50
Symbolic Regression with Conformal Prediction Intervals.
using ConformalPrediction
using Distributions
using MLJ
using Plots
# Inputs:
N = 600
xmax = 3.0
d = Uniform(-xmax, xmax)
@farr
farr / latexbuild.yml
Created October 2, 2020 18:32
GitHub Action for auto-building your LaTeX paper
name: latex-build
on: [push]
jobs:
build-latex:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install TeXlive
run: sudo apt-get install texlive texlive-publishers texlive-science latexmk
@yk
yk / .vimrc
Created July 6, 2020 14:26
vimrc july 2020
set nocompatible " be iMproved, required
let g:python3_host_prog = '/usr/local/opt/python@3.8/bin/python3.8'
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
@benwillkommen
benwillkommen / _readme.md
Last active June 27, 2022 21:27
Unsubscribe from all watched repositories in a particular organization

Remove All Subscriptions from a Specific Github Organization

This script will delete all the subscriptions in your account for the Github Organization passed to it.

This script was created when I took a new job, and my notification settings inadvertantly subscribed me to all 600+ of their repos. I wanted a better signal to noise ratio in my notifications, but I didn't want to click the "Unwatch All" button, which would remove my subscriptions to repos outside my new employer's org.

How To

  1. Create a Personal Access Token with the "repo" scope, and expose it as the GITHUB_PERSONAL_ACCESS_TOKEN environment variable:
$ export GITHUB_PERSONAL_ACCESS_TOKEN=
@MilesCranmer
MilesCranmer / use_pymc3_like_emcee.py
Last active October 2, 2019 02:37
Use PyMC3 like emcee
##########################################
#emcee example:
##########################################
import numpy as np
import emcee
# Number of samples for each chain.
N_samp = 1000
def log_prob(x):
@markwk
markwk / writings-tracking-with-git.bash
Last active April 18, 2024 13:41
My Writings Tracker with Git: A bash script for tracking my writings in plain tex files, calculate stats like word count, hashtags and new files, store stats to csv and commit to git.
#!/bin/bash
##################################
#
# THE ARCHIVE TRACKER
#
# REF: https://gist.github.com/markwk/c85a8a72bc8c03d0f510262bb5219a34/
#
# INTRODUCTION:
# Daily script to navigate to a directory of plain text files,
# add files to git repo, calculate key stats, store stats to csv
import torch
def jacobian(y, x, create_graph=False):
jac = []
flat_y = y.reshape(-1)
grad_y = torch.zeros_like(flat_y)
for i in range(len(flat_y)):
grad_y[i] = 1.
grad_x, = torch.autograd.grad(flat_y, x, grad_y, retain_graph=True, create_graph=create_graph)
jac.append(grad_x.reshape(x.shape))
#
# Kurtosisf.py calculates the spectral kurtosis from fast-capture .dada files
# and outputs spectral kurtosis, real and imaginary kurtosis values, and flagging
# information for each window of every channel in all of the antennas.
# Commented out code relates to making histograms, and other junk. I know it's a mess.
#
# Original code written by Hugh Garsden
# Edited and made a general mess of by Alex Bailey, June 2017
#
@MilesCranmer
MilesCranmer / word_count_changes.md
Last active February 22, 2024 23:17
Accurate word count changes in git, useful for tracking changes on a paper in overleaf

Words changed in a git repo

This should work generally, but I use this to track the number of words changed in a (LaTeX) paper with a version history in git (and which Overleaf uses by default).

This is a tricky thing to deal with for many reasons.

Show the added words, deleted words, words on duplicate lines on every commit in the last day (bash):

@MilesCranmer
MilesCranmer / nobels_by_country.md
Last active June 18, 2017 11:55
Nobel prizes by country, per capita and per scientist, post-1985 and post-1970

Rankings

First, let's look at just physics.

Since this is a lot less data to work with, we'll take prizes from 1970 onwards.

Country Nobels in Physics 2016 population (millions) Nobels per million
Denmark 2 5.7 0.350877193