Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph Catrambone JosephCatrambone

View GitHub Profile
@JosephCatrambone
JosephCatrambone / lib.rs
Last active Jan 18, 2023
Embedding GPT-2 in Godot via Rust
View lib.rs
mod ml_thread;
use gdnative::prelude::{godot_print, methods, Method, NativeClass, Node as GDNode, InitHandle, godot_init};
use ml_thread::start_language_model_thread;
use std::sync::mpsc::{channel, Receiver, RecvError, Sender, SendError};
const MAX_INPUT_LENGTH: usize = 512;
const BATCH_SIZE: usize = 1;
@JosephCatrambone
JosephCatrambone / union_find.py
Created Jul 11, 2022
A Union-Find / Disjoint-Set Python class
View union_find.py
class UnionFind:
def __init__(self):
self.parents = dict()
def add(self, node_id:int):
self.parents[node_id] = node_id
def union(self, node_a:int, node_b:int):
min_parent = min(self.parents[node_a], self.parents[node_b])
self.parents[node_a] = min_parent
@JosephCatrambone
JosephCatrambone / tinypico_wireless_morse_keyboard.ino
Created May 15, 2022
TinyPICO BlueTooth BLE Morse Keyboard
View tinypico_wireless_morse_keyboard.ino
#include <BleKeyboard.h>
#include <TinyPICO.h>
TinyPICO tinypico = TinyPICO();
BleKeyboard keyboard; // keyboard("Name", "manufacturer", battery_level_100)
// a .-
// b -...
// c -.-.
// d -..
@JosephCatrambone
JosephCatrambone / DecisionTree.gd
Created Feb 25, 2022
Basic Decision Tree in GDScript
View DecisionTree.gd
# Sample Usage:
# var day_features = [
# # freezing, raining, foggy, sunny
# [0, 1, 0, 0],
# [0, 0, 0, 1],
# [0, 0, 0, 0],
# [0, 0, 1, 0],
# [1, 0, 0, 1],
# [1, 1, 0, 0],
# [1, 0, 1, 0],
@JosephCatrambone
JosephCatrambone / decision_tree.rs
Created Apr 7, 2021
A Rust-language decision tree implementation with no external dependencies.
View decision_tree.rs
//use serde::{Serialize, Deserialize};
use std::collections::HashMap;
// If you have serde, serialization is available with this derive chain:
//#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[derive(Clone, Debug, Default)]
pub struct DecisionTree {
feature: usize,
threshold: f32,
@JosephCatrambone
JosephCatrambone / basic_backprop.py
Created Feb 23, 2021
Reverse Mode Automatic Differentiation
View basic_backprop.py
import numpy
import random
class Graph:
def __init__(self):
self.nodes = list()
self.last_tape = None
def forward(self, variables, output_node):
for n in self.nodes:
n.forward(variables)
@JosephCatrambone
JosephCatrambone / owa.tracker-combined-latest.minified.js
Created Feb 5, 2021
owa.tracker-combined-latest.minified.js - The Great Suspender Breakdown
View owa.tracker-combined-latest.minified.js
(function(exports) {
if (!this.JSON) {
this.JSON = {};
}
(function() {
"use strict";
function f(n) {
return n < 10 ? "0" + n : n;
}
if (typeof Date.prototype.toJSON !== "function") {
@JosephCatrambone
JosephCatrambone / gan.py
Created Sep 7, 2020
Cleaned PyTorch GAN Code
View gan.py
import numpy
from pathlib import Path
import sys
import torch
from torch import nn
import torchvision
from torchvision import datasets
from torchvision import transforms
@JosephCatrambone
JosephCatrambone / CameraController.gd
Created Apr 7, 2020
Godot Orbital Camera Controller
View CameraController.gd
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 Dec 15, 2019
The Raspberry Pi code running my mom's Christmas present.
View sketch_artist.py
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