Skip to content

Instantly share code, notes, and snippets.

View AndrewWalker's full-sized avatar

Andrew Walker AndrewWalker

  • Melbourne, Australia
View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
import glob
import os
def simple_pendulum_deriv(x, t, m, g, l):
"""The simple pendulum subject to zero damping and zero control input
Based on material from the MIT OCW subject "Underactuated Robotics"
@AndrewWalker
AndrewWalker / brick_vi_mtime_sol.py
Created May 26, 2012 12:39
Double integrator minimum time value iteration
# This is a python port of the minimum time solution of the double integrator
# (with no damping) minimum time value iteration problem, based on the course notes of
# MIT OCWs Underactuated robotics.
#
# The original material that this work is derived from is:
#
# Prof. Russel Tedrake, Underactuated Robotics, Spring 2009. (Massachusetts Institute of # Technology: MIT OpenCouseWare), http://ocw.mit.edu (Accessed May 2012). License:
# Creative Commons BY-NC-SA
import sys
@AndrewWalker
AndrewWalker / ninvlaplace.py
Last active November 30, 2018 17:37
Numerical Inverse of the Laplace Transform
# Based on "Approximate Inversion of the Laplace Transform" by Cheng and Sidauruk,
# in the Mathematica Journal, vol 4, issue 2, 1994
import scipy.misc
fact = scipy.misc.factorial
def csteh(n, i):
acc = 0.0
for k in xrange(int(np.floor((i+1)/2.0)), int(min(i, n/2.0))+1):
num = k**(n/2.0) * fact(2 * k)
# IPython notebook build process for Ubuntu 12.04 from pypi
#
# This is probably very far from good practice for docker, but it's a demonstration
# of how to get very precise control of an environment that suitable for testing
#
# docker build -t ipynb .
# docker run -t -i -p 127.0.0.1:8888:8888 ipynb
FROM ubuntu
@AndrewWalker
AndrewWalker / SConstruct
Last active August 29, 2015 14:21
Stupid things to do with SCons
import scommon
scommon.sconscript_validator(Environment)
menv = Environment()
menv.SConscript('SConscript', exports=['menv'])
@AndrewWalker
AndrewWalker / main.py
Last active May 22, 2016 04:11
stackoverflow-answer-37210684
from clang.cindex import *
def is_function_call(funcdecl, c):
""" Determine where a call-expression cursor refers to a particular function declaration
"""
defn = c.get_definition()
return (defn is not None) and (defn == funcdecl)
def fully_qualified(c):
""" Retrieve a fully qualified function name (with namespaces)
@AndrewWalker
AndrewWalker / ssh_copy_id.py
Created December 28, 2016 05:37
Pure python replacement for ssh_copy_id
import argparse
import sys
import os
def ssh_copy_id(host='localhost', ssh='ssh', keyfile='~/id_rsa.pub', sshopts=()):
opts = ' '.join('-o ' + opt for opt in sshopts )
cmd = 'cat %(keyfile)s | %(ssh)s %(opts)s %(host)s \'umask 077; mkdir -p .ssh; cat >> .ssh/authorized_keys\''
os.system(cmd % locals())
if __name__ == "__main__":