Skip to content

Instantly share code, notes, and snippets.

View jrsmith3's full-sized avatar

Joshua Ryan Smith jrsmith3

View GitHub Profile
@jrsmith3
jrsmith3 / kink.ipynb
Created April 17, 2015 14:52
Analysis of kink in plot of photon energy flux vs. temperature for semiconductor
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am jrsmith3 on github.
  • I am joshuarsmith (https://keybase.io/joshuarsmith) on keybase.
  • I have a public key whose fingerprint is E0A0 7701 0330 22E5 29A9 3AC5 9A19 5912 200C 61F9

To claim this, I am signing this object:

@jrsmith3
jrsmith3 / pdfmod.py
Created April 3, 2014 03:31
Convert specified pages from a PDF to png
"""
This script was used to create the figures for http://jrsmith3.github.io/sample-logs-the-secret-to-managing-multi-person-projects.html from a PDF file containing some old CMU sample logs.
"""
import PyPDF2
from wand.image import Image
import io
import os
@jrsmith3
jrsmith3 / sla2pdf.py
Created March 12, 2014 01:31
Converts every scribus document to a PDF in a specified directory.
"""
Convert every .sla to a pdf in a specified directory.
This script can only be run from within [scribus](http://http://scribus.net).
"""
import os
work_dir = #you have to explicitly tell scribus where your working directory is.
filenames = os.listdir(work_dir)
@jrsmith3
jrsmith3 / splitrepos.py
Last active August 29, 2015 13:56
Split a monolithic git repo into several small ones
# -*- coding: utf-8 -*-
"""
I used the following script to convert each subdirectory of work.git into its own git repo. The one exception was paper-2013.01.16_nea_collector which I did by hand using essentially the same method as below, except I skipped the part where I removed the tags. I used the procedure found at [1] and slightly modified it. I also used the solution in [2] to convert non-bare repos to bare. Note also that I first cloned work from its bare git repo on the SD card, removed the remote, and tarred the result to work.tar.
[1] http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository
[2] http://stackoverflow.com/questions/1784506/when-creating-a-git-repository-that-will-be-on-the-server-can-i-convert-it-to-a
"""
import os
import subprocess
@jrsmith3
jrsmith3 / round_exponential.py
Created May 6, 2013 22:06
Round a value to an integer [1-9] times a power of 10. How would you write a test for this method?
import numpy as np
def round_exponential(val):
"""
Round a value to an integer [1-9] times a power of 10.
Example
>>> val1 = 7.83126342297e-07
>>> print round_exponential(val1)
>>> 8e-07
@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 May 17, 2024 17:43
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"}