This file contains 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
''' | |
File Refiner | |
May 18 2015 | |
This code is written to import a file, start to read the lines after a particular line | |
and stop on a particular line. Finally results will convert to float number and write | |
in a file. | |
Assuming the code and file.crd are in the same directory, and we want to miss first 5 lines | |
and extract 239 lines after that, one should type: |
This file contains 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 | |
### find files with ".f" extension in the current directory | |
### copy them to directory "dirx" | |
ls -d -1 $PWD/*.f* | xargs -I{} cp "{}" dirx |
This file contains 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 | |
''' | |
Pure Python implementation of some numerical optimizers | |
Created on Jan 21, 2011 | |
@author Jiahao Chen | |
''' |
This file contains 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
python -c 'import multiprocessing as mp; print(mp.cpu_count())' |
This file contains 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
# This removes files where paths are listed in a file named "file.dat". | |
# for running, type: | |
# python3 script.py file.dat | |
import sys | |
import os | |
paths = sys.argv[1] | |
with open(paths) as f: | |
for line in f: | |
os.remove(line.rstrip('\n')) |
This file contains 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 all running jobs, take their JOB ID and delete them. | |
qstat | awk -F " " '{print $1}' | xargs qdel |
This file contains 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
## All the credit goes to Eelco Hoogendoorn | |
## http://stackoverflow.com/a/21032099/3349443 | |
def normalized(a, axis=-1, order=2): | |
norms = np.atleast_1d(np.linalg.norm(a, order, axis)) | |
norms[norms==0] = 1 | |
return a / np.expand_dims(norms, axis) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 codecs # to read html | |
from bs4 import BeautifulSoup # to parse html | |
import glob # to find all files with a pattern | |
pages = glob.glob("*.html") | |
for page in pages: | |
# loop through all files | |
name = page.split(".")[0] | |
print (name) | |
html=codecs.open(page, 'r') # read html |
OlderNewer