Skip to content

Instantly share code, notes, and snippets.

View spuder's full-sized avatar

Spencer Owen spuder

View GitHub Profile
@spuder
spuder / CAD .zshrc
Last active March 28, 2022 18:50
Bash create git repo for CAd files
# 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

Produces 360 images

This uses --animate which doesn't work with more than 3 frames when running in a docker container spuder/openscad-dockerhub#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 / gist:8274987
Created January 5, 2014 22:37
Vagrant - post create
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#config.vm.box = "PuppetlabsCent64"
#config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box"
config.vm.box = "Debian-7-2"
@spuder
spuder / sync_time.sh
Created August 24, 2021 01:41
Helium Miner status
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 April 19, 2021 01:34
Use an ATTiny 85 to 'push' momentary button
#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
@spuder
spuder / redash.job
Last active January 6, 2021 01:58
ReDash Nomad job #nomad
# 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 / chef-http-client.rb
Created April 1, 2016 20:43
A working, but ugly way to fetch from a url
ruby_block 'get build' do
block do
require "net/https"
require "uri"
require "json"
uri = URI.parse("http://nexus.example.com/nexus/service/local/repositories/foobar/content/master-5678.zip?describe=info")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
@spuder
spuder / README.md
Last active July 21, 2019 19:17 — forked from bastman/README.md
parse erb templates from command line (standalone, cli, json)

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 ?

These are almost stock betaflight settings, except I've turned down the P's and D's

# Betaflight / CRAZYBEEF3FR (CBFR) 3.5.3 Nov 14 2018 / 23:20:22 (61d5abf00) MSP API: 1.40

board_name CRAZYBEEF3FR
manufacturer_id 
name spuder

feature -DYNAMIC_FILTER
@spuder
spuder / f5.md
Last active January 26, 2019 00:06
f5 powershell cmdlets

Add-PSSnapin iControlSnapin;

Api docs https://devcentral.f5.com/wiki/iControl.APIReference.ashx

Authenticate to F5

if ( (Get-PSSnapin -Name iControlSnapin -ErrorAction SilentlyContinue) -eq $null ) {Add-PsSnapin iControlSnapin -ErrorAction Stop}
$F5Connected = ((Get-F5.iControl).initialized -and (Get-F5.iControl).ConnectionInfo.hostname -eq $LoadBalancer)
if ($F5Connected) {
    Write-Verbose "F5 connection already initialized"