Skip to content

Instantly share code, notes, and snippets.

@moble
moble / AddDirToNames.py
Last active December 16, 2015 06:28
Add '.dir' to the end of every group in the root of an h5 file
#! /usr/bin/env python
import sys
import h5py
for filename in sys.argv[1:] :
with h5py.File(filename, 'r+') as f :
for group in list(f) :
f[group+'.dir'] = f[group]
del(f[group])
@moble
moble / SetupRemoteNotebookServers.ipynb
Last active August 29, 2015 13:56
Simple notebook to set up ipython notebook on remote servers and access it easily over ssh from the local computer.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / WhitespaceCleanup.sh
Created March 20, 2014 19:08
Use Emacs to clean up whitespace in a whole bunch of files
# Remove trailing whitespace, and replace tabs with the appropriate number of spaces
for file in `find . -name "*.?pp"`; do
echo "$file"; /usr/local/bin/emacs --batch "$file" \
--eval '(setq-default indent-tabs-mode nil)' \
--eval '(whitespace-cleanup)' \
-f 'save-buffer'
done
@moble
moble / gist:d6b3b5db911a2ca758f5
Created May 1, 2014 20:56
Crazy `multiple definition` error at link time
g++ -pthread -shared build/temp.linux-x86_64-2.7/Quaternions/Quaternions.o build/temp.linux-x86_64-2.7/Quaternions/IntegrateAngularVelocity.o build/temp.linux-x86_64-2.7/Quaternions/Utilities.o build/temp.linux-x86_64-2.7/PostNewtonian/C++/PNEvolution.o build/temp.linux-x86_64-2.7/PostNewtonian/C++/PNEvolution_Q.o build/temp.linux-x86_64-2.7/PostNewtonian/C++/PNWaveformModes.o build/temp.linux-x86_64-2.7/SphericalFunctions/Combinatorics.o build/temp.linux-x86_64-2.7/SphericalFunctions/WignerDMatrices.o build/temp.linux-x86_64-2.7/SphericalFunctions/SWSHs.o build/temp.linux-x86_64-2.7/SpacetimeAlgebra/SpacetimeAlgebra.o build/temp.linux-x86_64-2.7/Utilities.o build/temp.linux-x86_64-2.7/Waveforms.o build/temp.linux-x86_64-2.7/PNWaveforms.o build/temp.linux-x86_64-2.7/Scri.o build/temp.linux-x86_64-2.7/SWIG/GWFrames_wrap.o -Lspinsfast/lib -L/usr/local/gsl/1.16/lib -L/usr/local/fftw3-3.2.2/lib -lgsl -lgslcblas -lfftw3 -lspinsfast -o build/lib.linux-x86_64-2.7/_GWFrames.so -fPIC
build/temp.linux-x86_64-2.7/Wavefo
@moble
moble / EasySSH.ipynb
Last active August 29, 2015 14:01
Easy ssh
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / NumbaODEExample.ipynb
Last active July 6, 2021 18:32
Show how to speed up scipy.integrate.odeint simply by decorating the right-hand side with numba's jit function
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moble
moble / README.md
Last active August 29, 2015 14:10
Show how to efficiently store and access Wigner 3j coefficients when one of the j values is <=2

The notebook is viewable as such here. The storage isn't strictly as efficient as it could be, but it's pretty darn good. And the size of that storage only goes as jmax**2.

@moble
moble / README.md
Last active August 29, 2015 14:10
Show how to efficiently store and access Wigner 3j coefficients when one of the m values is <=2

The notebook is viewable as such here. The storage isn't quite as efficient as it could be, but I think it's about as good as can be expected with simple indexing. The size of that storage only goes as jmax**4.

@moble
moble / randomwords.py
Created January 9, 2015 06:42
Generate passphrase randomly, but memorably
#! /usr/bin/env python
"""Generate a sequence of random words for use in a password/passphrase
On my Mac, the `words` file referenced in the script has 235886 (roughly 2**18)
entries. If you select N of those words randomly, you get roughly 18*N bits of
entropy for a password.
I like to generate a list about 10 words long, then choose about 6 of them to
form a sentence -- a ridiculous sentence, but still a sentence. You might have
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.