Skip to content

Instantly share code, notes, and snippets.

View dmentipl's full-sized avatar

Daniel Mentiplay dmentipl

View GitHub Profile
@dmentipl
dmentipl / git_latexdiff.sh
Created October 7, 2020 00:01
Make a latexdiff of the current manuscript in a git repo against an earlier commit.
#!/usr/bin/env bash
#
# Make a latexdiff of the current manuscript.
#
# NOTES:
# - Must be run from a directory inside the git repo.
# - Produces a file "diff.pdf" containing the diff.
# - Removes blue highlighting in MNRAS links
# (which conflicts with blue highlighting from diff).
@dmentipl
dmentipl / stability.py
Last active July 24, 2020 04:45
Show time step stability constraint for explicit Euler and leapfrog methods for ODEs
"""Euler and leapfrog stability.
Stability for both is guaranteed by
dt < - 2 / lambda,
where lambda is from the ODE
dv/dt = lambda * v.
"""
@dmentipl
dmentipl / make_bibtex_from_citations.py
Last active July 10, 2020 04:15
Make a paper bibtex from citations contained within the .tex of the paper
#!/usr/bin/env python
"""Generate bibtex from citations in tex using a master bibtex.
It uses the following regex to find citations in the tex file:
regex = re.compile(r'\\|no|cite[a-z]*\*?{(.*?)}')
This regex matches citations like \cite{}, \citet{}, \citep{},
\citeauthor{}, \citet*{}, and so on, and returns the captured citekey.
@dmentipl
dmentipl / lastsnap.py
Last active November 25, 2021 04:39
Get the last .h5 snap in a dir (or list of dirs)
#!/usr/bin/env python3
import argparse
from pathlib import Path
def main():
parser = argparse.ArgumentParser(description='Last snap')
parser.add_argument('dirs', type=str, nargs='+', help='Input dirs for snaps')
@dmentipl
dmentipl / slurm.swm
Last active November 25, 2021 04:40
Slurm job script for ozstar
#!/bin/bash
#SBATCH --nodes=1 --ntasks=1
#SBATCH --cpus-per-task=32
#SBATCH --job-name=twhya
#SBATCH --output=twhya01.swmout
#SBATCH --mail-type=BEGIN
#SBATCH --mail-type=FAIL
#SBATCH --mail-type=END
#SBATCH [email protected]
#SBATCH --time=7-00:00:00
@dmentipl
dmentipl / Plonk-tutorial.ipynb
Last active September 5, 2020 00:38
Plonk tutorial for the 3rd Phantom + MCFOST users workshop, Monash University, Feb 25, 2020 -- https://phantomsph.bitbucket.io/workshop2020
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmentipl
dmentipl / monash_library_bookmarklet.js
Created October 16, 2019 23:51
Bookmarklet to get access to a journal article via Monash library
javascript:(function() { window.location=window.location.toString().replace(/(https*:\/\/)(.*?)\/(.*)/, "$1$2.ezproxy.lib.monash.edu.au/$3"); })()
@dmentipl
dmentipl / pypi.md
Created August 26, 2019 00:20
Uploading a Python package to PyPI

Uploading to PyPI

First need to create accounts with PyPI and TestPyPI.

Then:

python setup.py sdist bdist_wheel
twine check dist/*
@dmentipl
dmentipl / fix_bibdesk_file_links.py
Last active August 8, 2019 08:17
Fix BibDesk file links
@dmentipl
dmentipl / Makefile
Last active July 15, 2019 03:08
Phantom HDF5 at Disc-ussions workshop, Monash University, July 15, 2019
#
# Make notebook, html, slides from markdown
.PHONY:
help:
@echo "Usage:"
@echo " make <target>"
@echo
@echo " notebook Make .ipynb notebook"
@echo " html Make .html notebook"