Skip to content

Instantly share code, notes, and snippets.

@goretkin
goretkin / hex.svg
Created May 13, 2021
matplotlib polycollection svg
View hex.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goretkin
goretkin / robot.jl
Last active May 12, 2021
swept volume computation for GridVAMP
View robot.jl
using LazySets: UnionSetArray, LineSegment, BallInf
using ReachabilityAnalysis
using Colors: @colorant_str
import LinearAlgebra
using CartesianIndexSets: CartesianIndexSet
import PlotUtils
using PlotUtils: RGBA
using RecipesBase
# https://github.com/JuliaReach/ReachabilityAnalysis.jl/issues/464
@goretkin
goretkin / atom-boot-repl.jl
Last active Apr 16, 2021
atom-boot-repl.jl
View atom-boot-repl.jl
# from https://raw.githubusercontent.com/JunoLab/atom-julia-client/a61023683d0a926d3496d1396c667c064e27bdd4/script/boot_repl.jl
using Pkg
let
# NOTE: No single quotes. File needs to be shorter than 2000 chars.
#=
if VERSION > v"0.7-"
port = parse(Int, popfirst!(Base.ARGS))
else
View semantic-line-break-em-dash.md

sentence-per-line, no em-dash spaces:

The food—which was delicious—reminded me of home. The food, which was delicious, reminded me of home.

clause-per-line, inconsistent em-dash spaces:

The food —which was delicious—

@goretkin
goretkin / laz.jl
Created Jun 16, 2020
lazy map field access
View laz.jl
using Test
using BenchmarkTools
using DataStructures: OrderedDict
using MappedArrays: mappedarray
# use the iterator interface
function foo(a)
r = nothing
for x in a
@goretkin
goretkin / curry.jl
Last active Jun 7, 2020
Julia `Bind`, defer evaluation for some symbolic reasoning
View curry.jl
# See https://github.com/JuliaLang/julia/pull/36180
using Base: tail
interleave(bind::Tuple{}, args::Tuple{}) = ()
interleave(bind::Tuple{}, args::Tuple) = error("more args than positions")
interleave(bind, args) = _interleave(first(bind), tail(bind), args)
# `nothing` indicates a position to be bound
_interleave(firstbind::Nothing, tailbind::Tuple, args::Tuple) = (
first(args), interleave(tailbind, tail(args))...)
@goretkin
goretkin / short-circuit-trivalent.jl
Last active Apr 23, 2020
short circuit trivalent logic
View short-circuit-trivalent.jl
import PrettyTables
macro and(p, q)
quote
vp = $(esc(p))
if !ismissing(vp)
if vp
$(esc(q))
else
false
View parameterization.jl
using LinearAlgebra: norm
using Zygote
using Plots
A = rand(2,2)
b = rand(2)
A = [0.511125 0.493421; 0.987115 0.260349]
b = [0.205398, 0.282329]
View segment_distance_gui.jl
using LinearAlgebra
using PyPlot
using GeometryTypes
using EnhancedGJK
using Setfield # https://github.com/jw3126/Setfield.jl
import Polyhedra
import CoordinateTransformations
View acrobot_missing_tip_body.urdf
<?xml version="1.0"?>
<robot name="DoublePendulum">
<link name="base_link">
<visual>
<geometry>
<box size=".2 .2 .2" />
</geometry>
<material name="green">
<color rgba="0 1 0 1" />