Skip to content

Instantly share code, notes, and snippets.

View SharpCoder's full-sized avatar
🛰️
inventing

Joshua Cole SharpCoder

🛰️
inventing
View GitHub Profile
pub fn get_color(&mut self, time: u64) -> Color {
// Take the current time we are interested in (typically
// system uptime in milliseconds) and modulus it by
// the total time of our gradient so we end up with
// a point between 0 and the total_time.
let normalized_time = time % self.total_time;
// The internal representation for this builder pattern
// is a linked-list, so do some sanity checks.
if self.root.is_none() {
return self.color;
This is how I wire up an ESP8266 and the power-on sequence I use to initialize the device.
It seems really hard to find such simple information, so here it is in this gist for all eternity.
------
VCC - 3.3v
GND - Gnd
RST - High
En - High
Rx - Tx
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
nvm_has() {
type "$1" > /dev/null 2>&1
}
nvm_install_dir() {
command printf %s "${NVM_DIR:-"$HOME/.nvm"}"
@SharpCoder
SharpCoder / IARR.md
Created April 28, 2021 15:29
IARR Atmospheric Correction Algorithm

Algorithm

There is surprisingly very little information about what the actual IARR algorithm is. IARR stands for Internal Average Relative Reflectance and the idea is that you extract the spectral information from the raw data by measuring the mean spectrum of the whole image. Every pixel vector is normalised by this global spectral mean to produce a 'relative reflectance' image. The psuedo-code for this algorithm is as follows:

for each band
   compute mean
for each pixel in a particular bad
   divide by the computed mean for this band
@SharpCoder
SharpCoder / HMC5883L.cpp
Last active April 19, 2021 22:29
HMC5883L Magnetometer Code
#include "compass.h"
// COMPASS_MULTIPLIERS are calibrated per sensor and require an rigorous
// test environment. See README.md for more information.
int16_t COMPASS_MULTIPLIERS[360] = {
-213, -215, -213, -213, -213, -211, -208, -208, -204, -208, -206, -204, -204, -202, -200, -200, -200, -200, -202, -196, -196, -196, -196, -196, -196, -196, -192, -196, -192, -192, -192, -192, -192, -190, -189, -189, -189, -189, -189, -189, -189, -189, -189, -189, -187, -188, -185, -189, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -185, -189, -185, -185, -185, -185, -185, -185, -185, -185, -189, -189, -187, -189, -185, -189, -189, -189, -189, -189, -192, -189, -190, -190, -190, -192, -192, -192, -192, -192, -196, -192, -196, -196, -196, -196, -196, -196, -196, -196, -200, -200, -200, -196, -200, -200, -200, -201, -204, -204, -200, -204, -204, -204, -204, -204, -204, -208, -208, -208, -208, -213, -213, -208, -208, -208, -208, -213, -213
@SharpCoder
SharpCoder / cache.rs
Last active September 29, 2020 05:27
use std::fs;
use std::path::Path;
pub trait Cache {
fn write_file(&self, bucket: String, path: String, contents: String);
fn write_json<Z : serde::ser::Serialize >(&self, bucket: String, path: String, model: Z);
fn read_file(&self, bucket: String, path: String) -> Option<Vec<u8>>;
fn read_json<Z : serde::de::DeserializeOwned>(&self, bucket: String, path: String) -> Option<Z>;
}
# Install mtrack driver 0.5.0++
# Save this file to /usr/share/X11/xorg.conf.d/50-mtrack.conf
# This config is specialized for MacBook Air 2012 (5,2)
Section "InputClass"
MatchIsTouchpad "on"
Identifier "Touchpads"
MatchDevicePath "/dev/input/event*"
Driver "mtrack"
# The faster you move, the more distance pointer will travel, using "polynomial" profile
Option "AccelerationProfile" "2"
@SharpCoder
SharpCoder / README.md
Last active April 3, 2020 20:53
Contributing Guidelines - for Makers

Contributing Guidelines

Hello! We're so glad you are interested in producing components for the extraordinarily in-demand PPE face shields which our local hospitals desperately need. To help facilitate this endeavor, we've created these guidelines to help make the process clear and simple.

What to make

Any and all components are currently in-demand. So feel free to make whichever one you are comfortable and setup to create. At this time, we are okay with accepting just shields, or just frames, or both.

3D Printed File

Once you're ready to go, feel free to start 3D printing or cutting the acrylic parts. We are standardizing on a single model, to help with the logistics of sourcing all the necessary components.

include <openfusion.scad>
include <gears.scad>
//
bolt_bore = 6.2;
bearing_bore = 19.1 + 3.2;
limb_height = 6;
bearing_padding = 0;
@SharpCoder
SharpCoder / sigilpack.cpp
Created February 2, 2020 21:19
Hexagon Sigil Arduino Code
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 7
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 2
// Declare our NeoPixel strip object: