Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JosephCatrambone
JosephCatrambone / CameraController.gd
Created April 7, 2020 05:48
Godot Orbital Camera Controller
extends Camera
export var follow_target_path:NodePath = ""
var follow_target:Node
export var follow_distance:float = 5.0
export var follow_height:float = 1.0
export var mouse_sensitivity_x:float = 0.005
export var mouse_sensitivity_y:float = 0.005
var last_mouse_delta:Vector2 = Vector2()
@JosephCatrambone
JosephCatrambone / sketch_artist.py
Created December 15, 2019 04:23
The Raspberry Pi code running my mom's Christmas present.
import numpy
import picamera
import picamera.array
import random
import RPi.GPIO as GPIO
from time import sleep
camera_width = 320
camera_height = 240
arma_pin = 32
@JosephCatrambone
JosephCatrambone / lineseekablefile.py
Created December 4, 2019 23:13
A simple file wrapper to allow seeking to specific lines at random.
class LineSeekableFile:
def __init__(self, seekable):
self.fin = seekable
self.line_map = list() # Map from line index -> file position.
self.line_map.append(0)
while seekable.readline():
self.line_map.append(seekable.tell())
def __getitem__(self, index):
# NOTE: This assumes that you're not reading the file sequentially. For that, just use 'for line in file'.
@JosephCatrambone
JosephCatrambone / unionfind.rs
Created October 5, 2019 06:04
Disjoint-Set / Union-Find - A simple
/*
UnionFind.rs
A simple single-file UnionFind/Disjoint-Set implementation.
AUTHOR: Joseph Catrambone <jo.jcat@gmail.com> (c) 2019
LICENSE: MIT
/// Example Usage:
///
/// ```
/// let uf = UnionFind::<char>::new();
@JosephCatrambone
JosephCatrambone / 10958Search.py
Created February 8, 2019 15:43
Searching for a solution to the 10958 problem.
# -*- coding: utf-8 -*-
"""
(c) 2019 Joseph Catrambone, Xoana LTD. Releasewd under MIT License.
"""
# Create 10958 using, in order, 1, 2, 3, 4, 5, 6, 7, 8, 9.
# Let's phrase this as a search problem.
# Concat only applies if the underlying operands are digits, not products. I.e, one could go concat(1, 2) -> 12, but not concat(1+2, 3) -> 33.
@JosephCatrambone
JosephCatrambone / depth_guess.py
Created December 22, 2018 20:02
A quick and dirty Python file for loading and training on the NYU depth dataset.
#!/usr/bin/env python
from PIL import Image
from glob import iglob
import h5py
import tensorflow as tf
import numpy
import logging
import itertools
@JosephCatrambone
JosephCatrambone / Projection Issue
Created October 20, 2018 18:37
Trying to debug an issue with point projection.
import numpy
import math
def make_sphere(steps=512):
points = list()
colors = list()
for s in range(steps):
y = math.sin((8 * s / float(steps)) * 2 * math.pi)
x = math.cos((32 * s / float(steps)) * 2 * math.pi)

Keybase proof

I hereby claim:

  • I am JosephCatrambone on github.
  • I am josephcatrambone (https://keybase.io/josephcatrambone) on keybase.
  • I have a public key whose fingerprint is E974 FC47 9D86 9756 4EE7 C912 2D23 E135 F6F0 661B

To claim this, I am signing this object:

@JosephCatrambone
JosephCatrambone / octree.py
Last active March 7, 2018 05:47
A small octree implementation in pure python that supports arbitrary point dimensions and uses naive splitting.
#!/usr/bin/env python
#author: Joseph Catrambone
"""
Copyright 2018 Joseph Catrambone
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OU
@JosephCatrambone
JosephCatrambone / TriangleLineIntersection.js
Last active November 23, 2017 20:37
Companion Code for the Article on Ray Triangle Intersection
//@author Joseph Catrambone
// See https://www.josephcatrambone.com/?p=967 for the original blog post and the derivation of all formulas.
class Point {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
dot(other) {