Skip to content

Instantly share code, notes, and snippets.

Avatar

John Ellis deckerego

View GitHub Profile
@deckerego
deckerego / iterate_network.js
Last active May 25, 2021
IPv4 Network Info Calculator & Iterator
View iterate_network.js
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 Mar 5, 2021
An LSB init script that runs a node app as a daemon
View mynodeapp
#! /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 Nov 22, 2020
A busy/free desktop indicator for the Adafruit Circuit Playground Express. See https://github.com/deckerego/busy-free_indicator for the full version.
View boot.py
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 Oct 10, 2020
Docker image for troubleshooting networking issues (e.g. figuring out why VPC Endpoints don't work in ECS)
View Dockerfile
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
Fix Blender 2.82 permissions in MacOS
View fix_blender_282.sh
#!/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 Dec 15, 2019
Helper lamp with varying color temperature and brightness
View code.py
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)
@deckerego
deckerego / code.py
Created Nov 5, 2019
Audio level meter with Circuit Playground Express
View code.py
import array
import math
import time
import neopixel
import audiobusio
import board
def avg(values):
return sum(values) / len(values)
@deckerego
deckerego / code.py
Last active Dec 8, 2019
Use a remote control to change the lights on a Circuit Playground Express
View code.py
import pulseio
import board
import time
import neopixel
import touchio
import adafruit_irremote
from digitalio import DigitalInOut, Direction, Pull
power = True
color = (255, 255, 255)
@deckerego
deckerego / code.py
Created Nov 4, 2019
Create a campfire effect with a Circuit Playground Express. Copy a crackle.wav audio file for the sound effect, and toggle the switch to mute/unmute.
View code.py
from time import sleep
from random import random
from board import SPEAKER, SLIDE_SWITCH, SPEAKER_ENABLE, NEOPIXEL
from neopixel import NeoPixel
from digitalio import DigitalInOut, Direction, Pull
from audioio import WaveFile
from audioio import AudioOut
from simpleio import map_range
# NeoPixels
@deckerego
deckerego / code.py
Created Nov 2, 2019
Multi-sensor Feedback with Circuit Playground Express
View code.py
# Circuit Playground NeoPixel
import time
import board
import neopixel
import busio
import analogio
import digitalio
import simpleio
import adafruit_thermistor
import adafruit_lis3dh