Skip to content

Instantly share code, notes, and snippets.

@nickgravish
nickgravish / ipython_mpl_interact.py
Last active October 7, 2015 17:33
Interact for matplotlib plotting, data exploration
def test_foo(k):
t = np.linspace(0,1,1000)
plt.figure(figsize=(8,2.5))
plt.plot(t, np.sin(t*k))
interact(test_foo, k=(0,1000))
# for new ipython
%load_ext rpy2.ipython
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
import rpy2.robjects.packages as rpackages
from rpy2.robjects.vectors import StrVector
# This now installs the packages, so only need to run once
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=2) # select the first mirror in the list
@nickgravish
nickgravish / opencv_install_snippet.md
Last active August 24, 2016 20:24
Installation code for compiling opencv3 with ffmpeg on mac

adopted from https://scivision.co/anaconda-python-opencv3/

cmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DENABLE_AVX=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_IPP=ON -DWITH_TBB=ON -DWITH_EIGEN=ON -DWITH_V4L=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") -DPYTHON_EXECUTABLE=$(which python3) -DPYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -FFMPEG_INCLUDE_DIR " /usr/local/Cellar/ffmpeg/2.5.3/include/" -FFMPEG_LIB_DIR "/usr/local/Cellar/ffmpeg/2.5.3/lib" -WITH_FFMPEG 1 -BUIILD_opencv_python2 ..

on the laptop

cmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DENABLE_AVX=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_IPP=ON -DWITH_TBB=ON -DWITH_EIGEN=ON -DWITH_V4L=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMA
@nickgravish
nickgravish / rpy2_install.md
Last active June 8, 2017 11:08
Rpy2 installation annoyances

Starting with R installed from the download on the CRAN website.

install rpy2 from source using

python setup.py build install     

running the unit test gives

@nickgravish
nickgravish / note.md
Last active February 15, 2016 20:56
Adding custom python modules to my config

To add a custom python module so that I can access it everywhere

  1. Make the python module, use a simple directory structure
  ~/Python/modulename/
    -> readme.md
    -> modulename/
 -> __init__.py
@nickgravish
nickgravish / poupcad_install.md
Last active April 21, 2016 22:31
popupcad install on a mac

How to setup a python environment for running bleeding edge popupcad

Here are the steps to run the development version of popupcad on a Mac OSX (Yosemite).

Install commands to be copy and pasted into the command line

yes | conda create -n popupcad_env python=3.4
source activate popupcad_env
@nickgravish
nickgravish / Pyqtgraph_notes.md
Last active August 16, 2016 20:20
Install instructions and notes for pyqtgraph
@nickgravish
nickgravish / gist:ece1b12dba96f8a111d0b2816500c04e
Last active August 28, 2016 19:29
Science environment setup in python
@nickgravish
nickgravish / snippets.md
Created August 25, 2016 22:25
Python science import snippets for Jupyter

import matplotlib # for pycharm
matplotlib.backend('Qt4Agg') # for pycharm

import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt