This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interval_overlap(alo, ahi, blo, bhi): | |
# interval a: alo to ahi | |
# interval b: blo to bhi | |
return (blo < ahi and bhi > alo) or (alo < bhi and ahi > blo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with: $ make | |
# or make -j4 to run in parallel | |
.PHONY: all help # rules that do not correspond to a output file | |
.SUFFIXES: # disable built-in rules | |
.SECONDARY: # do not delete intermediate products | |
# first rule is default | |
all: mytarget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Package a paper written in latex for arxiv. | |
Rationale | |
--------- | |
You may have figures and bibliography included from somewhere else in your file system with absolute paths. | |
This script makes a subdirectory package-mylatexfile.tex/ which contains the latex file, figures, .bib, input files referenced in the tex file | |
in the subdirectory, pdflatex mylatexfile.tex should work and not touch any files outside the subdirectory. | |
the subdirectory can then by tarred and uploaded to arxiv. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def rebin( | |
Nbins = 40, | |
minimum = 0.1, | |
): | |
bins = np.linspace(0, 1, Nbins) | |
lam = minimum + 0 * bins | |
c = np.random.poisson(lam) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To submit just at the right time (deadline 14:00 EST), | |
# | |
# How to use: | |
# - Make sure your clock is synced to https://arxiv.org/localtime | |
# - Prepare arxiv submission up to last page, move cursor over submission button | |
# - execute below function which will produce a left-button mouse click at 14:00 | |
# - if too early, unsubmit, fix clock, try again the next day | |
# | |
# Hopefully one day arxiv will randomize their submission ordering. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Intercept all matplotlib calls and store each figure's data | |
into json files, with labels as keys. | |
Usage: | |
Just replace: | |
import matplotlib.pyplot as plt | |
with: | |
from mplrecorder import plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
max_memory = int(os.environ.get('MAX_MEMORY', '10')) | |
recent_lines = [] | |
for line in sys.stdin: | |
if line not in recent_lines: | |
sys.stdout.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find $FOLDER -maxdepth 1 -type f -printf '%s\t%p\n' | | |
{ S=0; while read s l; do | |
((S+=s)); [[ $S -gt 1000000000 ]] && rm -v "$l"; | |
done; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compression can be improved when files with the same or similar content | |
# are next to each other in the file list. | |
# | |
# This command sorts by reversed filenames, which places files | |
# together by file extension, filename and path, in that order. | |
# identify all files | |
find mypath/ -type f | | |
rev | sort | rev | | |
tar --no-recursion --files-from=- -cvzf myarchive.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# you need to install: | |
# pip install openbases | |
# sudo apt install texlive-xetex pandoc pandoc-citeproc | |
PDF_INFILE=paper.md | |
PDF_LOGO=logo.png | |
PDF_OUTFILE=paper.pdf | |
TEX_OUTFILE=paper.tex |