Skip to content

Instantly share code, notes, and snippets.

View mikebuss's full-sized avatar

Mike Buss mikebuss

View GitHub Profile
@mikebuss
mikebuss / grid.tsx
Created June 9, 2025 16:11
Grid in React-Three-Fiber
const Grid = ({ number = 10, lineWidth = 0.026, height = 0.1 }) => {
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
return (
// Renders a grid and crosses as instances
<Instances position={[0, -3.02, 0]}>
<planeGeometry args={[lineWidth, height]} />
<meshBasicMaterial color="#999" />
{Array.from({ length: number }, (_, y) =>
Array.from({ length: number }, (_, x) => (
<group key={x + ':' + y} position={[x * 2 - Math.floor(number / 2) * 2, -0.01, y * 2 - Math.floor(number / 2) * 2]}>
@mikebuss
mikebuss / CalibrationVisual.tsx
Created June 8, 2025 00:48
Calibration Visual for Blog
'use client'
import React, { useRef, useEffect, useState } from 'react'
import { Canvas, useFrame } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'
import * as THREE from 'three'
function randomPointInUnitSphere(): THREE.Vector3 {
const u = Math.random()
const v = Math.random()
@mikebuss
mikebuss / floyd-steinberg.py
Created February 8, 2024 01:03
Floyd Steinberg Dithering
import sys
import io
import os
import traceback
from wand.image import Image as WandImage
from wand.color import Color
from PIL import Image
IMAGE_WIDTH = 800
IMAGE_HEIGHT = 480
@mikebuss
mikebuss / s3_uploader.rb
Last active March 16, 2020 20:16
Partial script for uploading to S3 in Ruby
require "aws-sdk"
require_relative "errors"
class S3Uploader
AWS_ACCESS_KEY = ENV["AWS_ACCESS_KEY"]
AWS_SECRET_KEY = ENV["AWS_SECRET_KEY"]
AWS_BUCKET_NAME = ENV["AWS_BUCKET_NAME"]
AWS_REGION = ENV["AWS_REGION"] || "us-east-1"
AWS_FILE_PREFIX = ENV["AWS_FILE_PREFIX"] || "bm"
@mikebuss
mikebuss / simple-device-query.swift
Created January 28, 2020 00:02
Query Devices in Swift
func queryForDevices() {
let rPi = URL(string: "http://10.3.141.1:8080/devices")!
let task = URLSession.shared.dataTask(with: rPi) {(data, response, error) in
guard let data = data else { return }
print(String(data: data, encoding: .utf8)!)
}
task.resume()
}
@mikebuss
mikebuss / router.go
Created January 27, 2020 23:54
Simple Go Server
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
http.HandleFunc("/devices", HandleDeviceRequest)
@mikebuss
mikebuss / PhraseRecognitionExample.cs
Created January 25, 2020 19:29
PhraseRecognitionExample
using System.Collections.Generic;
using UnityEngine.Windows.Speech;
using System.Linq;
public class PhraseRecognitionExample : MonoBehaviour
{
// Holds all of the keywords and their actions
Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
// Called before the first frame update
@mikebuss
mikebuss / cbot.sh
Last active January 29, 2019 00:51
certbot-renewal
echo "Updating certbot..."
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-apache
echo "Printing version..."
certbot --version
@mikebuss
mikebuss / decode-json-swift.swift
Created January 25, 2019 21:46
Decode [Any] and [String: Any] Swift 4
//
//
// Adapted from:
//
// Original: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24
// Adds encoding: https://github.com/3D4Medical/glTFSceneKit/blob/master/Sources/glTFSceneKit/GLTF/JSONCodingKeys.swift
// Adds fix for null inside arrays causing infinite loop: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24#gistcomment-2807855
//
struct JSONCodingKeys: CodingKey {
var stringValue: String
@mikebuss
mikebuss / math-helper.swift
Created November 4, 2018 01:01
math-helper.swift
class MathHelper {
lazy var pi: Double = {
// Calculate pi to a crazy number of digits
return resultOfCalculation
}()
}