Skip to content

Instantly share code, notes, and snippets.

Avatar

Spencer Owen spuder

View GitHub Profile
View openscad-gif.md

Produces 360 images

This uses --animate which doesn't work with more than 3 frames when running in a docker container https://github.com/spuder/openscad-dockerhub/issues/2

openscad /dev/null -D '$vpt = [0,0,0];' -D '$vpd = 20; $vpr = [0,$t * 360,0];' -o 'foo.png' -D 'cube([2,3,4]);' --imgsize=250,250 --animate 360 --colorscheme "Tomorrow Night"

The following all work, but not very well

@spuder
spuder / CAD .zshrc
Last active Jan 10, 2022
Bash create git repo for CAd files
View CAD .zshrc
# A bash function that will create a new git repo and configure the user.email
# Usage: Add this to your ~/.bashrc or ~/.bash_profile or ~/.zshrc files
function f360 {
_basepath="${HOME}/Code/github/spuder"
if [[ -z "$1" ]]; then echo "Usage: f360 foobar"; return 1; fi
if [[ ! -d "${_basepath}" ]]; then echo "${_basepath} doesn't exist"; return 1; fi
if [[ -d "${_basepath}/$1" ]]; then echo "Directory ${_basepath}/${1} already exists"; return 1; fi
echo "Creating ${_basepath}/${1}"
mkdir $_basepath/$1
cd $_basepath/$1
@spuder
spuder / sync_time.sh
Created Aug 24, 2021
Helium Miner status
View sync_time.sh
export ANIMAL=angry-purple-tiger #replace with your miner
hotspot=$(curl -s https://api.helium.io/v1/hotspots/name/${ANIMAL})
# TODO: error if result != 1
miner_height=$(echo $hotspot | jq -r '.data[].status.height')
chain_height=$(echo $hotspot | jq -r '.data[].block')
percentage=$(bc <<<"scale=6; $miner_height / $chain_height")
echo "=== ${ANIMAL} ==="
echo miner_height = ${miner_height}
echo chain_height = ${chain_height}
echo lag = $((${chain_height}-${miner_height}))
@spuder
spuder / attiny85.ino
Last active Apr 19, 2021
Use an ATTiny 85 to 'push' momentary button
View attiny85.ino
#include <avr/sleep.h>
#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)
int buttonPin = 0; // phyisical pin 5
int ledPin = 4; // physical pin 3
void setup() {
// https://www.notion.so/spencerowen/AtTiny-85-automated-chicken-coop-heater-596304ab6b3145769b92ddffdeb16b6f
// https://arduino.stackexchange.com/a/66655/27311
View gist:11c71258554c944b0b4241a4a10cfe01
Process: WindowServer [277]
Path: /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/Resources/WindowServer
Identifier: WindowServer
Version: 600.00 (451.4)
Code Type: X86-64 (Native)
Parent Process: launchd [1]
Responsible: WindowServer [277]
User ID: 88
Date/Time: 2021-03-01 10:41:43.651 -0700
@spuder
spuder / redash.job
Last active Jan 6, 2021
ReDash Nomad job #nomad
View redash.job
# Based on this documentation
# https://redash.io/help/open-source/setup#-Docker
# https://github.com/getredash/setup/blob/master/data/docker-compose.yml
job "redash" {
# region = ""
datacenters = ["dc1"]
type = "service"
@spuder
spuder / LICENSE
Last active Nov 21, 2019
Script to help recover nomad servers that have lost leadership
View LICENSE
Mozilla Public License, version 2.0
1. Definitions
1.1. "Contributor"
means each individual or legal entity that creates, contributes to the
creation of, or owns Covered Software.
1.2. "Contributor Version"
@spuder
spuder / README.md
Last active Jul 21, 2019 — forked from bastman/README.md
parse erb templates from command line (standalone, cli, json)
View README.md

Goal

  • provide cli command to render erb template
  • template params (bindings) to be provided using json format
  • use inputs from file (template.erb, params.json)
  • use inputs from cli options / parameters
  • render output to stdout OR to file

Why ?

@spuder
spuder / PrintWeek.workflow
Created Jan 21, 2019
Apple Script to print out the entire week in calendar
View PrintWeek.workflow
on run {input, parameters}
--
tell application "Calendar" to quit
delay 2
tell application "Calendar"
activate
end tell
-- Press ⌘P
delay 0.5
View baby-hawk-colby.md
# Betaflight / OMNIBUS (OMNI) 3.2.2 Nov 11 2017 / 00:38:45 (77782e602) MSP API: 1.36
name Babyhawk R

feature -RX_PPM
feature RX_SERIAL
feature RSSI_ADC
feature AIRMODE
feature ANTI_GRAVITY
feature DYNAMIC_FILTER