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
find . -type f -name 'myfiles.*' -delete |
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 pstats,cProfile | |
import my_function | |
cProfile.runctx("my_function(a,b)",globals(),locals(),"Profile.prof") | |
s = pstats.Stats("Profile.prof") | |
s.strip_dirs().sort_stats("time").print_stats() |
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 clean_whitespace(s): | |
''' | |
Returns a version of s with no leading or trailing whitespace/\t/\n and one whitespace | |
between each whitespace-separated token in the string. | |
Ex: ' a b c d \n' -> 'a b c d' | |
''' | |
return ' '.join(l.strip().split()) | |
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 datetime as dt | |
def date_parser(datestring): | |
""" | |
Accepts a datestring in the format: | |
mm/dd/yyyy hh:mm:ss | |
and returns a python datetime object with all relevant fields properly set. | |
""" | |
mdy = [int(x) for x in datestring.split(' ')[0].split('/')] | |
hms = [int(x) for x in datestring.split(' ')[1].split(':')] |
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 time | |
class Timer: | |
def __enter__(self): | |
self.start = time.clock() | |
return self | |
def __exit__(self,*args): | |
self.end = time.clock() | |
self.interval = self.end - self.start |
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
for f in *.cfg | |
echo 'Working on' $f | |
set out (basename $f .cfg).out | |
set err (basename $f .cfg).err | |
<myprog> --config=$f >$out ^$err | |
python process_output.py -input=$out -output=results.dat | |
end |
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
# write | |
mycommand >stdout ^stderr | |
# append | |
mycommand >>stdout ^^stderr |
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
#!/bin/bash | |
#BSUB -L /bin/bash | |
#BSUB -J paj[1-4] | |
#BSUB -e paj.%I.err | |
#BSUB -o paj.%I.out | |
#BSUB -n 1 | |
source ~/venv/bin/activate | |
python parse_command_line.py --config=conf_${LSB_JOBINDEX}.cfg --output=results_${LSB_JOBINDEX}.out |
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/python | |
import sys, getopt | |
def config_file_parser(configfile): | |
""" | |
Very basic code for reading a simple config file and returning | |
a dictionary of options. | |
""" | |
config = {} |
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
pip install --install-option="--user" package_name |
NewerOlder