Skip to content

Instantly share code, notes, and snippets.

View folkertdev's full-sized avatar

Folkert de Vries folkertdev

View GitHub Profile
@folkertdev
folkertdev / lagrangePolynomial.py
Created September 27, 2015 14:12
A sympy-based Lagrange polynomial constructor
"""
A sympy-based Lagrange polynomial constructor.
Given a set of function inputs and outputs, the lagrangePolynomial function will construct an
expression that for every input gives the corresponding output. For intermediate values,
the polynomial interpolates (giving varying results based on the shape of your input).
This is useful when the result needs to be used outside of Python, because the
expression can easily be copied. To convert the expression to a python function object,
use sympy.lambdify.
"""
@folkertdev
folkertdev / newtonPolynomial.py
Created September 27, 2015 13:59
A sympy-based newton polynomial constructor.
"""
A sympy-based newton polynomial constructor.
Given a set of function inputs and outputs, the newtonPolynomial function will construct an
expression that for every input gives the corresponding output. For intermediate values,
the polynomial interpolates (giving varying results based on the shape of your input).
This is useful when the result needs to be used outside of Python, because the
expression can easily be copied. To convert the expression to a python function object,
use sympy.lambdify.
@folkertdev
folkertdev / resample.py
Last active August 29, 2015 14:27
An improvement idea for the Freestyle resample method. Improvements include inline vector operations, next(it) for pairwise iteration and a for instead of while loop.
# pairwise is defined in utils.py and a very handy function
def pairwise(iterable):
a, b = tee(iterable)
next(b, None)
return zip(a, b)
def resample(stroke, sampling=5.0):
new_vertices = []
for a, b in pairwise(stroke):
new_vertices.append(a)
@folkertdev
folkertdev / chrome-reload.sh
Created July 3, 2015 19:56
Reload current chrome tab on a file change
#!/bin/bash
# inspired by
# http://linux.die.net/man/1/inotifywait
# http://razius.com/articles/auto-refreshing-google-chrome-on-file-changes/
# http://unix.stackexchange.com/questions/37258/refresh-reload-active-browser-tab-from-command-line
# Usage:
# ./chrome-refresh.sh /folder/to/watch /some/folder/file_to_watch.html
TIME_FORMAT='%F %H:%M'
@folkertdev
folkertdev / 0_reuse_code.js
Created August 8, 2014 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console