Skip to content

Instantly share code, notes, and snippets.

View deckerego's full-sized avatar

John Ellis deckerego

View GitHub Profile
@deckerego
deckerego / prusacam
Last active January 12, 2024 14:09
Send an (old) RPi camera still to Prusa Connect
* * * * * pi raspistill -n -q 80 -w 960 -h 720 -e jpg -t 1000 -o - | curl -v -H 'Token: TOKEN' -H 'Content-Type: application/jpg' -H 'Fingerprint: FINGERPRINT' https://webcam.connect.prusa3d.com/c/snapshot -T -
@deckerego
deckerego / action_fingerprint.sh
Created June 29, 2023 20:28
Find the TLS fingerprint for GitHub Actions token server
#!/bin/bash
openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 2>/dev/null < /dev/null | \
openssl x509 -fingerprint -sha1 -noout | \
grep Fingerprint | \
tr -d ':' | \
tr '[:upper:]' '[:lower:]' | \
cut -f2 -d=
@deckerego
deckerego / terraform.tf
Last active October 7, 2022 03:05
Redirect HTTP traffic using Application Load Balancers
locals {
public_zones = {
"domainone.egg" = "FEEDFACEBEEF"
"domaintwo.egg" = "BEEFBEEFFACE"
"domainthree.egg" = "FACEFEEDFACE"
}
}
resource "aws_default_vpc" "default" {}
@deckerego
deckerego / redirect.tf
Last active October 7, 2022 03:06
HTTP (only) redirect for alternate domains using S3
locals {
www_zones = {
"www.domainone.egg" = "FEEDFACEBEEFFEED"
"www.domaintwo.egg" = "BEEFBEEFFEEDFACE"
"www.domainthree.egg" = "FACEFACEFEEDFACE"
}
}
resource "aws_s3_bucket" "redirect-www-bucket" {
for_each = local.www_zones
@deckerego
deckerego / iterate_network.js
Last active May 25, 2021 02:13
IPv4 Network Info Calculator & Iterator
function getIPv4Range(networkString) {
const networkdef = networkString.split('/');
const netmask = parseInt(networkdef[1])
const bitmask = 32 - netmask;
const quads = networkdef[0].split('.');
const addrbin =
(parseInt(quads[0]) << 24) +
(parseInt(quads[1]) << 16) +
(parseInt(quads[2]) << 8) +
parseInt(quads[3]);
@deckerego
deckerego / mynodeapp
Created March 5, 2021 19:41
An LSB init script that runs a node app as a daemon
#! /bin/bash
### BEGIN INIT INFO
# Provides: mynodeapp
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: A Node app that runs in the background
# Description: A Node app that runs in the background
### END INIT INFO
@deckerego
deckerego / boot.py
Last active November 22, 2020 14:33
A busy/free desktop indicator for the Adafruit Circuit Playground Express. See https://github.com/deckerego/busy-free_indicator for the full version.
import board
import digitalio
import storage
# Only allow code.py updates when turned off
switch = digitalio.DigitalInOut(board.D7)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
storage.remount("/", not switch.value)
@deckerego
deckerego / Dockerfile
Last active October 10, 2020 12:37
Docker image for troubleshooting networking issues (e.g. figuring out why VPC Endpoints don't work in ECS)
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y openssh-server dnsutils telnet netcat vim
RUN mkdir /var/run/sshd
RUN echo 'root:f33df4ced3adb33f' | chpasswd
RUN sed -i 's/#*PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
@deckerego
deckerego / fix_blender_282.sh
Created May 31, 2020 19:09
Fix Blender 2.82 permissions in MacOS
#!/bin/sh
sudo find /Applications/Blender.app -perm +111 -type f -exec chmod og+x {} \;
sudo find /Applications/Blender.app -type d -exec chmod og+x {} \;
@deckerego
deckerego / code.py
Last active December 15, 2019 03:34
Helper lamp with varying color temperature and brightness
import analogio
import simpleio
import board
import time
import neopixel
import touchio
from digitalio import DigitalInOut, Direction, Pull
# NeoPixels
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=False)