Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anyuzx
anyuzx / extract_pid.md
Created February 19, 2017 00:42
extract pid from ps aux command
ps aux | grep name | grep -v grep
ps aux | grep name | grep -v grep | awk '{print $2}'
@anyuzx
anyuzx / save_sparse_matrix.py
Created October 3, 2016 16:46
save spicy sparse matrix/array object to file
from scipy import sparse, io
m = sparse.csr_matrix([[0,0,0],[1,0,0],[0,1,0]])
m # <3x3 sparse matrix of type '<type 'numpy.int64'>' with 2 stored elements in Compressed Sparse Row format>
io.mmwrite("test.mtx", m)
del m
newm = io.mmread("test.mtx")
newm # <3x3 sparse matrix of type '<type 'numpy.int32'>' with 2 stored elements in COOrdinate format>
@anyuzx
anyuzx / acf.py
Created September 28, 2016 04:15
autocorrelation in python
# Since there is no real autocorrelation compute function in python and numpy
# I write my own one
import numpy as np
# Suppose data array represent a time series data
# each element represent data at given time
# Assume time are equally spaced
def acf(data):
mean = np.mean(data)
@anyuzx
anyuzx / lammps_compute_gyration.md
Last active February 28, 2017 22:24
walk through LAMMPS compute_gyration.h and compute_gyration.cpp

Notes about LAMMPS source codes, compute_gyration.h and compute_gyration.cpp.

compute_gyration.h

#ifdef COMPUTE_CLASS

ComputeStyle(gyration,ComputeGyration)

#else
@anyuzx
anyuzx / 0_reuse_code.js
Created February 24, 2016 21:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console