Skip to content

Instantly share code, notes, and snippets.

View tschaume's full-sized avatar
👋

Patrick Huck tschaume

👋
View GitHub Profile
@tschaume
tschaume / submit_jobs_comet.sh
Created May 4, 2016 23:55
job submission throttling for MPComplete on XSEDE Comet based on SU usage
#!/bin/bash -l
source /home/phuck/mp_prod/bin/activate
export FW_CONFIG_FILE=$FW_CONFIG_mp_prod
export DB_LOC=/home/phuck/mp_prod/config/dbs
export VENV_LOC=/home/phuck/mp_prod/bin/activate
export SCRIPT_LOC=/home/phuck/mp_prod/config/scripts
# xdusage doesn't work in a cronjob due to sudo usage, needs tty!?
@tschaume
tschaume / Makefile
Created April 17, 2015 19:19
A single Makefile to generate thesis/webpage/etc. from AsciiDoc source files (see https://github.com/tschaume/wp-pdf)
# filelist (needs to be in order!)
FILELIST= physics/part_title.txt \
physics/intro.txt \
physics/ana/chapter_title.txt \
physics/ana/exp.txt \
physics/ana/dsets_evttrk.txt \
physics/ana/evtplane.txt \
physics/ana/pid.txt \
physics/ana/pairrec.txt \
physics/effcorr.txt \
@tschaume
tschaume / rmGitHistory.sh
Created March 23, 2015 01:20
remove files/dirs from git history
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@tschaume
tschaume / pymatgen_rest_test.py
Last active August 29, 2015 14:16
Testing new MP REST endpoints via MPRester
import os
from pymatgen.matproj.rest import MPRester
from pymatgen.io.cifio import CifParser
ENDPOINT, API_KEY = "https://www.materialsproject.org/rest", os.environ.get('MAPI_KEY')
with MPRester(API_KEY, endpoint=ENDPOINT) as m:
# retrieve all references for a given mp-id
# curl -H "x-api-key:$MAPI_KEY" https://www.materialsproject.org/rest/materials/mp-568345/refs
print m.get_materials_id_references('mp-568')
@tschaume
tschaume / get_references.py
Last active August 29, 2015 14:15
Materials Project: get all references for a material
# mktmpenv
# pip install numpy
# pip install scipy
# pip install pymongo
# pip install monty
# pip install -U setuptools
# pip install -e git+git@github:materialsproject/mpworks#egg=mpworks
import os
from pymongo import MongoClient
from monty.serialization import loadfn
@tschaume
tschaume / dynamic_word_count.tex
Last active August 29, 2015 14:15
dynamically count and return number of words in a section
\documentclass{article}
\newcommand\wordcount{
\immediate\write18{texcount -sub=section \jobname.tex | grep "Section" | sed -e 's/+.*//' | sed -n \thesection p > 'count.txt'}
(\input{count.txt}words)}
\begin{document}
\section{Introduction}
In publishing and graphic design, lorem ipsum is placeholder text (filler text) commonly used to demonstrate the graphics elements of a document or visual presentation, such as font, typography, and layout. The lorem ipsum text is typically a section of a Latin text by Cicero with words altered, added and removed that make it nonsensical in meaning and not proper Latin.
\wordcount
@tschaume
tschaume / pymatgen_matcher_test.py
Last active August 29, 2015 14:11
small pymatgen StructureMatcher test
from os.path import isfile
from pymatgen import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher, ElementComparator
from pymatgen.io.cifio import CifWriter, CifParser
from mpworks.snl_utils.snl_mongo import SNLMongoAdapter
sma = SNLMongoAdapter.auto_load()
def get_structure(gid):
ciffile = 'snlgroup_id_%d.cif' % gid
@tschaume
tschaume / pandas_masked_numbers.py
Created December 6, 2014 23:09
This gist illustrates the issue in Plotly of non-json-serializable masked constants as produced by Pandas with and without the pull request at https://github.com/plotly/python-api/pull/159) (also see http://stackoverflow.com/questions/27053729)
import pandas as pd
from plotly.matplotlylib import Exporter, PlotlyRenderer
from plotly.plotly import plot
import matplotlib.pyplot as plt
data = {
'esN': [0, 1, 2, 3],
'ewe_is0': [ -398.11901997, -398.11902774, -398.11897111, -398.11882215 ],
'ewe_is1': [ -398.11793027, -398.11792966, -398.11786308, None ],
'ewe_is2': [ -398.11397008, -398.11396421, None, None ]