Skip to content

Instantly share code, notes, and snippets.

<head>
</head>
<body>
</body>
@dwinston
dwinston / gist:8d4251286469422f408d
Created September 26, 2014 21:51
Counting ways to make change for cent amounts using sets of coins, using memoization
"""Count ways to make change for cent amounts using sets of coins."""
def memoize(f):
"""Memoize a function of positional arguments."""
cache = {}
def helper(*args):
if tuple(args) not in cache:
cache[tuple(args)] = f(*args)
return cache[tuple(args)]
return helper
@dwinston
dwinston / mmm-jsx.el
Last active August 29, 2015 14:16 — forked from dgellow/mmm-jsx.el
(require 'mmm-mode)
(mmm-add-classes
'((jsx
:submode web-mode
:front "\\((\\)[[:space:]\n]*<"
:front-match 1
:back ">[[:space:]\n]*\\()\\)"
:back-match 1)))
#!/usr/bin/env python
import argparse
from pymatgen.core.structure import IStructure
from pymatgen.matproj.rest import MPRester
from pymatgen.analysis.structure_matcher import StructureMatcher,\
ElementComparator
parser = argparse.ArgumentParser(
description="""find_struct_in_mp is a script that reads structures from
@dwinston
dwinston / datatable-react-stateless.js
Last active August 29, 2015 14:17
Use of DataTable via React props for column and row data (stateless)
var TabularData = React.createClass({
componentDidMount: function () {
$(this.refs.table.getDOMNode()).DataTable();
},
componentDidUpdate: this.componentDidMount,
render: function () {
var headers = _.pluck(this.props.table.columns, 'title')
.map(function (title) {
return D.th({key: title}, title);
});
@dwinston
dwinston / mp_structure_predictor_results.ipynb
Created October 7, 2015 23:42
getting Materials Project (MP) Structure Predictor results
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dwinston
dwinston / nmgc_nanoporous_data.ipynb
Last active February 4, 2016 01:46
Access raw NMGC nanoporous material data from the Materials Project
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dwinston
dwinston / es_img_builder.py
Created February 19, 2016 04:06
generate pairs of aligned-vertical-axis BS and DOS images from MP structures and persist to gridfs
# coding: utf-8
#
# Electronic structure (es) image builder:
#
# Build static images (*.png) for plots of bandstructure (BS) and
# density-of-states (DOS) data for materials, storing them in a GridFS
# filesystem (e.g. 'es_plot.files' and 'es_plot.chunks' collections) on the
# same db as that of the source 'materials'/'electronic_structure' collections.
from __future__ import division, unicode_literals, print_function
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.