Skip to content

Instantly share code, notes, and snippets.

View rawburt's full-sized avatar

Robert Peterson rawburt

View GitHub Profile
@pwab
pwab / line.gd
Created February 17, 2018 16:51
[Godot 3] Line2D intersection points implemented with CollisionShapes
# This implementation is based on CollisionShapes and RayCasts.
# It has one major flaw: It detects intersections of different lines and not only of the line itself.
# I'm pretty sure this can be circumvented by changing the collision_layers of each line
# or by keeping track of each line and then excluding their collision_bodies when ray casting
# or by removing all the collision bodies when intersection_scanning is done
extends Line2D
var intersections = [] # Keep track of every intersection
var segments = [] # Keep track of every segment
@bellbind
bellbind / lisp.js
Last active December 6, 2016 07:37
[es6][nodejs]lisp REPL interpreter with Promise
// lisp interpreter
// for nodejs-v5: node --es_staging lisp.js
"use strict";
function tokenize(code) {
const comment = /;.*$/gm;
const token = /\(|\)|'|,@?|`|"(?:[^"]|\\")*"|[^\s"'`,\(\)]+/g;
return code.replace(comment, "").match(token) || [];
}
function parse(tokens, depth, tree) {