This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from the Blender Freestyle code | |
static PyObject *Stroke_viewedges_begin(BPy_Stroke *self) | |
{ | |
PyObject *output = PyTuple_New(self->s->viewedges_size()); | |
std::vector<ViewEdge*>::iterator ve_it = self->s->viewedges_begin(), ve_end = self->s->viewedges_end(); | |
for (unsigned int i = 0; ve_it != ve_end; ++ve_it, ++i) { | |
PyTuple_SET_ITEM(output, i, BPy_ViewEdge_from_ViewEdge(*(*ve_it))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pyVertexNatureUP0D(nature): | |
""" Generator function as predicate. about 50% slower, but it works """ | |
while True: | |
print("doing work") | |
inter = yield | |
if inter is None: | |
continue | |
yield bool(inter.object.nature & nature) | |
it = Interface0DIterator(stroke) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Effective code. Nice and short | |
let | |
updateModel newEditor (Model generic _) = | |
Model generic (EditorView { apiToken = apiToken, staticToken = staticToken, editor = newEditor }) | |
in | |
Editor.State.update childMsg editor | |
|> mapChildCmd ChildEditorAction | |
|> outMsgUpdate updateModel editorOutMsg model | |
-- The magic that makes it possible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
original = | |
[ "..0...0.....1." | |
, "1....0....0.11" | |
, "...1...0......" | |
, "1...0........." | |
, "......0..1.0.0" | |
, "1..11..1..1..." | |
, "........0....." | |
, "1.1..1...11..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Read more about this program in the official Elm guide: | |
-- https://guide.elm-lang.org/architecture/effects/http.html | |
module Main exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Http |
OlderNewer