Skip to content

Instantly share code, notes, and snippets.

View kvchen's full-sized avatar

Kevin Chen kvchen

View GitHub Profile
#!/usr/bin/env python
import click
import matplotlib.pyplot as plt
import mkl
import numpy as np
import ray
from functools import wraps
from ray.array.distributed import core as rdc
fn = RectBivariateSpline(np.arange(height), np.arange(width), img[:, :, i], kx=1, ky=1)
# coords is a size (n, 2) array of (y, x) coordinates
interpolated_values = fn(coords[:, 0], coords[:, 1], grid=False)
# interpolated_values should have shape (n,)
def img_to_fn(img):
"""Converts a 2d image into a function that can interpolate between pixels
in the image.
"""
height, width, num_channels = img.shape
# TODO: Find a better way to do this
channel_fns = [
RectBivariateSpline(np.arange(height), np.arange(width), img[:, :, i],
kx=1, ky=1)
import numpy as np
import scipy
import ray
class DistCSRMatrix(object):
def __init__(self, shape, object_ids=None, stripe_size=10):
assert len(shape) == 2, 'Sparse matrix must be 2-dimensional'
self.shape = shape
def load_poses(poses_path):
unraveled_poses = np.loadtxt(poses_path,
delimiter=',',
usecols=range(12))
return unraveled_poses.reshape(-1, 3, 4)
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
(sys:load "libs/core/instruments.xtm")
(sys:load "libs/core/audio_dsp.xtm")
(sys:load "libs/external/instruments_ext.xtm")
(define drum-path "/Users/kevinchen/code/dafunk/salamander/OH/")
(bind-func saw_synth_note_c
(lambda (data:NoteInitData* nargs:i64 dargs:SAMPLE*)
(let ((sawl (saw_c 0.))
"""
Author: Kevin Chen
Adapted from [Wiiboard-simple](https://code.google.com/p/wiiboard-simple/)
for Python 3.
"""
import bluetooth
from collections import namedtuple
from enum import Enum
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don"t touch unless you know what you"re doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.provider "virtualbox" do |vb|
@kvchen
kvchen / flake8_setup.md
Last active October 2, 2015 02:15
Set up flake8 in SublimeText

Lint your code in SublimeText

don't be a filthy casual

  1. Install flake8 via pip install flake8. Make sure you can run the flake8 executable from your command line.
  2. Install Package Control in SublimeText via the following instructions. Make sure to pick the block of code that matches your version of SublimeText.
  3. Reopen SublimeText after installing.
  4. Use Ctrl+Shift+P (or Cmd+Shift+P if you're on a Mac), then type install to search for the option that says: Package Control: Install Package. Select it.
  5. Search for the package called SublimeLinter. Install it.
  6. Use the same method to install SublimeLinter-flake8.