Skip to content

Instantly share code, notes, and snippets.

View jrsmith3's full-sized avatar

Joshua Ryan Smith jrsmith3

View GitHub Profile
@jrsmith3
jrsmith3 / get_cites.py
Created May 5, 2013 22:11
Combining ideas from [getcites.py](https://gist.github.com/jrsmith3/5519665) and [doi2bib.py](https://gist.github.com/jrsmith3/5513926), generate a bibtex file of papers referenced by DOIs in the body of a LaTeX document.
# -*- coding: utf-8 -*-
import pycurl
import StringIO
from pybtex import auxfile
from pybtex.database.input import bibtex as bibtexin
from pybtex.database.output import bibtex as bibtexout
import pybtex.database
def doi2bib(doi):
"""
@jrsmith3
jrsmith3 / getcites.py
Created May 5, 2013 04:13
Get a list of bibTeX keys from a LaTeX document using plasTeX.
from plasTeX.TeX import TeX
# The following can be a problem if you are using revtex.
doc = TeX(file="filename.tex").parse()
refs = doc.getElementByTagName("cite")
cites = []
for ref in refs:
@jrsmith3
jrsmith3 / doi2bib.py
Last active January 5, 2024 09:17
Python method to access crossref.org DOI bibtex metadata resolver
import requests
def doi2bib(doi):
"""
Return a bibTeX string of metadata for a given DOI.
"""
url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"}
@jrsmith3
jrsmith3 / physics_words
Created April 25, 2013 23:39
A list of physics words that appear as variable, class, or method names in my programs. It would be great to be able to abbreviate these names without ambiguity due to overlap (e.g. "pos" could be "positive" or "position"). They are in no particular order.
position
positive
negative
temperature
potential
calculate
point
permittivity
boltzmann
mass
@jrsmith3
jrsmith3 / wtf.txt
Created March 17, 2013 15:12
Idea for a command that tells you what specified flags for an arbitrary bash command are.
wtf -- list specified command options of a bash command
EXAMPLE
-------
$ wtf rsync -rvcl src/ dest/
-r, --recursive recurse into directories
-v, --verbose increase verbosity
-c, --checksum skip based on checksum, not mod-time & size