Skip to content

Instantly share code, notes, and snippets.

@asross
asross / supersub.sh
Created July 3, 2015 15:12
supersub
## replace all instances of $1 with $2 within $3.
function supersub {
ack -l "$1" "$3" | xargs perl -p -i -e "s/$1/$2/g"
}
@asross
asross / README.md
Created January 18, 2016 14:01 — forked from benelsen/README.md

The current solar terminator is shown in blue, assuming a spherical Earth and an axial tilt of 23.4°. Hmm, on second thought, I think I didn’t account for the orbit of the Earth around the sun, so this is not entirely accurate. Please fork this example and fix it!

@asross
asross / KDN5.xml
Last active May 10, 2016 20:20
Attempt at demonstrating OrderSet chemotherapy regimen timing using as few extensions as possible
<OrderSet>
<moduleMetadata>
<identifier>
<system value="http://nccn.org/ordertemplates" />
<value value="KDN5" />
</identifier>
</module>
<!-- Here we only have one course (which repeats for 6 21-day cycles), but we could have multiple courses -->
<action>
@asross
asross / figure_grid.py
Last active September 7, 2018 14:44
A helper to plot grids of graphs in matplotlib.pyplot
"""
Examples:
with figure_grid(5, 3) as grid:
grid.next()
# plot something
grid.next()
# plot something
# ...etc
@asross
asross / cacheprop.py
Last active April 9, 2017 17:23
Like @Property, but only evaluated once
class cacheprop(object):
def __init__(self, getter): self.getter = getter
def __get__(self, shelf, _):
value = self.getter(shelf)
shelf.__dict__[self.getter.__name__] = value
return value
class Foo():
@cacheprop
def bar(self):