This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Display various file statistics for each directory. | |
""" | |
import sys | |
import os | |
import stat | |
from time import strftime, localtime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Looks for files (or directories) in a given directory, whose filenames | |
match a specified strptime format. | |
For those that are more than a specified number of days old, deletes certain | |
files, such that the interval between the ones that are retained does not | |
exceed the maximum specified interval. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Icinga plugin to test that certain known facet values exist when doing an | |
ESGF search. | |
The most important check is on the values for index_node. Because of the way | |
that the value for index_node is set by the publisher (it matches the index | |
hostname that it is publishing to), the set of facet values for index_node | |
can be used to test whether all of the Solr shards are responding properly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
help = ("Compresses a netCDF file by compressing time slices and " | |
"concatenating them. Requires NCO utilities.") | |
import os | |
import sys | |
import subprocess | |
import argparse | |
import shutil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyIter: | |
def __init__(self, iterable): | |
self._iterator = iter(iterable) | |
self.at_end = False | |
self._prefetch_next() | |
def __next__(self): | |
if self.at_end: | |
raise StopIteration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def commented_pprint(obj, name='obj', indent=4): | |
""" | |
Pretty-print object obj, which can contain nested dictionaries, lists and tuples, | |
with comment lines showing how to index it. | |
""" | |
pairs = list(_yield_pprint_lines(obj, name=name, indent=indent)) | |
max_len = max(len(line) for line, _ in pairs) | |
for line, comment in pairs: | |
print(f'{line:{max_len}} {comment}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.stats | |
from scipy.interpolate import interp1d | |
#import matplotlib as mpl | |
from matplotlib import pyplot as plt | |
def cints(n, levels): | |
ci_out = np.zeros((len(levels), 1 + n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example usage: | |
# | |
# this runs the following commands simultaneously, each in different areas of the screen: | |
# 1) echo hello | |
# 2) cal | |
# 3) for i in 1 2 3 4 5 ; do date; sleep 1; done | |
# | |
# it waits for 2 seconds after they have all finished, before clearing the screen | |
# | |
./run_in_panes.py -s 2 'echo hello' 'cal' 'for i in 1 2 3 4 5 ; do date; sleep 1; done' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def explore(l, c, t): # l = 2d list of connections; c = current node; t = target node | |
if c == t: # base case | |
return [[c]] | |
else: # recursive case | |
conns = [] | |
if c in i: | |
conns.extend([[c] + conn | |
for conn in explore([k for k in l if i != k], | |
(i[0] if c == i[1] else i[1]), | |
t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write(self, filename, arcname=None, compress_type=None, | |
fp=None, mtime=None, size=None, isdir=None, | |
mode=None): | |
"""Put the bytes from filename into the archive under the name | |
arcname.""" | |
if not self.fp: | |
raise RuntimeError( | |
"Attempt to write to ZIP archive that was already closed") | |
if isdir: |
NewerOlder