Skip to content

Instantly share code, notes, and snippets.

View SharpCoder's full-sized avatar

Joshua Cole SharpCoder

View GitHub Profile
SharpCoder / infra-stack.js
Created October 28, 2023 16:09
Express server in fargate with cdk
const {
aws_route53: route53,
aws_certificatemanager: acm,
aws_ecs: ecs,
aws_ec2: ec2,
aws_ecr_assets: ecr_assets,
aws_elasticloadbalancingv2: elbv2,
SharpCoder /
Last active August 29, 2023 00:39
A 2D (XY) robotic platform

A 2D (XY) Robotic Platform

Here are the files for my 2d robotic platform. Each file is meant to be fabricated on a 3d printer (except the assembly.scad file, which is really just a visualization for the final build).

SharpCoder / logic.ts
Last active March 24, 2023 14:48
Sphere/Cuboid Collision
function getAABB(rect: Cuboid) {
const result = {
min: [rect.x, rect.y, rect.z],
max: [rect.x + rect.w, rect.y + rect.h, rect.z + rect.d],
// Swap the vertices if the min/max is reversed
// because of orientation or whatever.
for (let i = 0; i < 3; i++) {
if (result.max[i] < result.min[i]) {
SharpCoder /
Last active March 6, 2023 16:01
Absolute Orientation Problem

Absolute Orientation Problem

This project is all about calculating the position of a telescope. I derive absolute orientation using a magnetometer sensor and accelerometer sensor. By absolute orientation, I mean deriving the euler angles of the telescope. The root problem I'm facing is that the yaw reading experiences a mostly linear error after pitching the device beyond a specific threshold. (About 50 degrees or so).

Reproducing the Problem

To consistently observe the error, a simple experiment can be performed which reliably yields the problem.


SharpCoder /
Last active February 8, 2023 16:21
Space Math in Rust
use chrono::prelude::*;
use std::f64::consts::PI;
type Float = f64;
#[derive(Copy, Clone)]
pub struct GpsCoordinate {
pub latitude: Angle,
SharpCoder / grate.scad
Created January 17, 2023 16:10
Grate for zenith space command controller
SPACING = 1.5;
W = 25;
H = 100;
module grate(W, H, SPACING) {
for (i = [0:W/SPACING/2]) {
translate([(SPACING * 2 * i) - ((W-SPACING)/2), 0, 0])
square([SPACING, H], center=true);
SharpCoder /
Last active December 17, 2022 01:27
Bit-Smooshing over Serial

Bit Smoosher

This algorithm will take a 10/12/14 bit word and distribute it among 2 8-bit words. But in a lossless, efficient way. Why might someone want this? Well, it lets you stream uniquely sized words over 8-bit serial. That's why I need it anyway. Here's an example:

Suppose you have an 8-bit serial port and you want to stream 12-bit audio at 8kHz. Well, serial is typically maxing out around 115200 bits/s. You can't just use 2 bytes per datapoint, because you'll generate too much content. In order to solve

SharpCoder / finder-splitter.scad
Created June 30, 2022 14:49
2-way telescope splitter
mount_base_w = 32.4;
mount_top_w = 23.8;
mount_depth = 10.0;
splitter_stem = 7;
splitter_height = 30;
platform_length = 45;
platform_angle = 22.5;
SharpCoder / evernote.css
Last active August 18, 2022 14:13
Evernote theme for Trilium Notes
@font-face {
font-family: 'Roboto-Regular';
font-style: normal;
font-weight: 400;
src: url('/custom/fonts/Roboto-Regular.woff2') format('woff2');
:root {
--main-bg: var(--white);
--main-text: #000;
SharpCoder /
Created March 14, 2022 16:29
Basic interpolation method written in rust
pub fn interpolate(start: u32, end: u32, elapsed: u64, duration: u64) -> u32 {
// Calculate step
let x0 = 0f32;
let y0 = min(start, end) as f32;
let x1 = duration as f32;
let y1 = max(end, start) as f32;
let x = min(elapsed, duration) as f32;
let delta = (x * ((y1 - y0)/(x1 - x0))) as u32;
if start > end {
return start - delta;