Skip to content

Instantly share code, notes, and snippets.

# Some slopeless formulations for working with line segments
# Author: @avonmoll
# There are two functions, each with two versions, one which computes the slope
# and one which circumvents direct calculation of the slope.
import numpy as np
def closestPointOnLineToPoint(start, end, point):
"""Find the point on the line that is closest to the given
@avonmoll
avonmoll / 00-startup.py
Created December 10, 2018 14:21
Startup file for IPython
# The main purpose of this file is to force matplotlib to use XeLaTeX with the fonts specified. Matplotlib's default
# font handling for PDF is really bad on macOS and the file sizes end up being massive
import numpy as np
import matplotlib as mpl
import importlib
from matplotlib.backends.backend_pgf import FigureCanvasPgf # For PGF or PDF export (uses TeX to render everything, no Type 3 fonts)
mpl.backend_bases.register_backend('pdf', FigureCanvasPgf) #
pgf_with_rc_fonts = { # Comment these lines in order to go back to matplotlib's mathtex (Type 3 or Type 42 fonts)
#! /bin/sh
git clone --bare https://github.com/avonmoll/.dotfiles.git $HOME/.dotfiles
function config {
/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@
}
mkdir -p .dotfiles-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out dotfiles.";
@avonmoll
avonmoll / ranger-mupdf.md
Created February 28, 2020 15:03
ranger with MuPDF for PDF preview

ranger is a great terminal-based file manager. For a long time, I used pdftoppm for image-based PDF previews which is the recommended approach. However, I found it was difficult to install pdftoppm everywhere (particularly, macos) and finally turned to MuPDF, which was much easier to get.

In order to use MuPDF, I changed the PDF case within the handle_image() function inside scope.sh to the following:

application/pdf)
    mutool draw -F png -o "${IMAGE_CACHE_PATH}" "${FILE_PATH}" 1 \
 && exit 6 || exit 1;;
@avonmoll
avonmoll / 0_how-I-use-papis.md
Last active April 18, 2025 14:40
A Guide on How to Use papis Sensibly

Installation

Easiest, if you have pip:

$ pip install papis

Adding Documents

Most of the time I add documents via their DOI. For example, I'll be on IEEExplore or ResearchGate and see a paper that I either want to read or know for sure I'll want to cite. So I simply copy the DOI and run

@avonmoll
avonmoll / 0_readme.md
Last active May 19, 2024 15:38
typst IEEE-style equation references

Problem: the default typst references for math.equation labels appears as "Equation 1". One may provide a supplement argument when referencing as in: <someEquation>[Eq.] which renders "Eq. 1" in the text. However, this is insufficient for meeting the IEEE specification for equation references which should be rendered "(1)".

Solution: I modified the thmref function provided by typst-theorems (see here) in order to provide the level of customization necessary.

@avonmoll
avonmoll / .gitignore
Last active December 23, 2024 14:29
Categorized Bibliography in Typst
library.yaml