Skip to content

Instantly share code, notes, and snippets.

@rdeits
rdeits / matlab.py
Created August 30, 2013 23:18
SublimeLinter for MATLAB
import re
import subprocess
from .base_linter import BaseLinter
CONFIG = {
'language': 'MATLAB',
'lint_args': '{filename}'
}
@rdeits
rdeits / gist:7728981
Created December 1, 2013 05:47
Numberjack OSX fix
diff --git a/make.project b/make.project
index 481c090..2dd1ce3 100644
--- a/make.project
+++ b/make.project
@@ -27,7 +27,7 @@ PYVERSION := $(shell python -V 2>&1 | \
ifeq ($(OSTYPE),darwin)
BUNDLE = -bundle -undefined suppress
-CFLAGS += -flat_namespace
+CFLAGS += -flat_namespace -lstdc++
function git() {
case $* in
commit* ) shift 1;
case $* in
*--author* )
command git commit "$@" ;;
* ) echo "Commit Failed: On this shared machine, you must set --author=\"Firstname Lastname\" manually when you commit";;
esac ;;
* ) command git "$@" ;;
esac
# Pkg.add("ForwardDiff") # Just do this once to install the package
using ForwardDiff
J(T) = ([1. 2.] * inv([T[1] T[2]^2; T[3]^2 T[4]^3]) * [1; 2])[1]
g = ForwardDiff.gradient(J)
J([1., 2., 3., 4.])
g([1.,2.,3.,4.])
import forcespro as fp
import numpy as np
NUM_FRICTION_CONE_BASIS_VECTORS = 4
stages = fp.MultistageProblem(1)
stages.dims[0]['n'] = NUM_FRICTION_CONE_BASIS_VECTORS # dimension of decision variables
stages.dims[0]['r'] = 0 # number of eq constraints
stages.dims[0]['l'] = NUM_FRICTION_CONE_BASIS_VECTORS # number of lower bounds
stages.dims[0]['u'] = 0 # number of upper bounds
"""
@wrappedallocs(expr)
Given an expression, this macro wraps that expression inside a new function
which will evaluate that expression and measure the amount of memory allocated
by the expression. Wrapping the expression in a new function allows for more
accurate memory allocation detection when using global variables (e.g. when
at the REPL).
For example, `@wrappedallocs(x + y)` produces:
using JuMP
using SCS
using Gurobi
# Objective is min. 1/2 x'Qx + q'x
Q = [1 0.1; 0.1 1]
q = [-3., 4]
## Solve with SCS
m = Model(solver=SCSSolver())
@rdeits
rdeits / director_python_vis.md
Created June 17, 2017 03:07
3D Visualizations from Python using Director

(for the Julia version of this code, check out the demo.ipynb notebook in https://github.com/rdeits/DrakeVisualizer.jl)

Installation

Easy: Pre-built binaries

Pre-built binary versions of Director are available from http://people.csail.mit.edu/patmarion/software/director/releases/. All of the features described here are known to work with version 0.1.0-35-g26aa674 but newer versions should work too. Just download the appropriate file for your operating system and extract the files.

Harder: Build from source

WARNING: An error occurred during inference. Type inference is now partially disabled.
Base.MethodError(f=typeof(Core.Inference.convert)(), args=(Base.AssertionError, "invalid age range update"), world=0x0000000000000ac2)
rec_backtrace at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/stackwalk.c:84
record_backtrace at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:245 [inlined]
jl_throw at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:564
jl_method_error_bare at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1478
jl_method_error at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1496
jl_lookup_generic_ at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1910
jl_apply_generic at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/gf.c:1930
Type at ./coreimg.jl:14