Skip to content

Instantly share code, notes, and snippets.

View r2007's full-sized avatar

Mu Bo r2007

  • China
View GitHub Profile
@r2007
r2007 / history_vol.py
Created April 25, 2016 13:29 — forked from johntyree/history_vol.py
Calculate annualized volatility from historical data.
#/usr/bin/env python
from pandas import np
from pandas.io.data import DataReader
def historical_volatility(sym, days):
"Return the annualized stddev of daily log returns of `sym`."
try:
quotes = DataReader(sym, 'yahoo')['Close'][-days:]
@r2007
r2007 / gpg-import-and-export-instructions.md
Created February 3, 2016 12:00 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

%%javascript
require.config({
paths: {
d3: '//cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.min'
}
});
@r2007
r2007 / self-signed certificate
Last active November 5, 2015 14:27
1 line self-signed certificate
openssl req -x509 -newkey rsa:2048 -keyout server.key -out server.crt -nodes -days 365
# for web2py
cache
databases
errors
sessions
uploads
# inherit https://github.com/github/gitignore/blob/master/Python.gitignore
*.py[co]
@r2007
r2007 / scikit.sh
Last active October 20, 2015 02:57
install scikit-learn
apt-get update
apt-get install -y pkg-config libopenblas-dev liblapack-dev git-core build-essential gfortran python-dev curl libfreetype6-dev libjpeg-dev libhdf5-dev liblzo2-dev libbz2-dev
curl https://bootstrap.pypa.io/get-pip.py | python
pip install cython
pip install numpy
pip install six
pip install pillow
pip install scikit-image
pip install scipy
pip install scikit-learn