Skip to content

Instantly share code, notes, and snippets.

View dillera's full-sized avatar

Andrew Diller dillera

View GitHub Profile
import sys
from PIL import Image
import struct
# Define the Apple II HRG palette
palette = [
(0, 0, 0), # Black
(114, 38, 64), # Deep Red
(64, 51, 127), # Dark Blue
(255, 0, 255), # Purple
@dillera
dillera / setup-systemd.bash
Last active June 12, 2024 02:53
BASH commands to save a systemd service file to start the udp_firewall.js script on boot.
cat <<'EOF' > /etc/systemd/system/udp-firewall.service
[Unit]
Description=UDP Firewall Service
After=network.target
[Service]
ExecStart=/usr/bin/node /usr/local/bin/udp_firewall.js
Restart=always
User=root
@dillera
dillera / udp_firewall.js
Created June 12, 2024 02:00
BASH command to save a node script that will listen on port 6677 for IP address from a SubText BBS
cat <<'EOF' > /usr/local/bin/udp_firewall.js
const dgram = require('dgram');
const { exec } = require('child_process');
const PORT = 6677;
const server = dgram.createSocket('udp4');
server.on('listening', () => {
@dillera
dillera / set_iptable_rules.bash
Created June 12, 2024 01:59
A set of commands to setup iptables for the firewall host
cat <<EOF | sudo bash
# Flush existing rules and set default policies
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -t raw -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
@dillera
dillera / udp_capture.py
Created June 7, 2024 14:41
Small Python script to capture UDP traffic and display the payload
import pyshark
import logging
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def packet_handler(pkt):
try:
if 'UDP' in pkt:
src_addr = pkt.ip.src
@dillera
dillera / index.html
Created May 22, 2024 02:00
FujiNet Flasher Auto Manifest
cat <<'EOF' > index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ESP Web Tools with Dynamic Manifest</title>
<style>
#spinner {
display: none;
@dillera
dillera / HTTP.cpp
Created May 11, 2024 01:06
refactored http.cpp
NetworkProtocolHTTP::~NetworkProtocolHTTP()
{
for (int i = 0; i < collect_headers_count; i++)
if (collect_headers[i] != nullptr)
{
free(collect_headers[i]);
collect_headers[i] = nullptr;
}
}
@dillera
dillera / create-startup.bash
Created November 22, 2023 20:46
A bash script that will create a systemd startup file using local env vars for security
#!/bin/bash
#
# create flask startup scripts for flask apps.
# a typical path: /home/ubuntu/yourProject
# with a venv at: /home/ubuntu/yourProject/venv
#
# adiller oct 2023
#
#################################################################
# Function to display usage notes
@dillera
dillera / gist:3efa529674685b2d23e996fff29d54cc
Created September 19, 2023 13:52
simple openAI translation service
python3 -m venv venv
source venv/bin/activate
pip install Flask openai
python ./app.py
----------------------------------------------
from flask import Flask, request, jsonify
@dillera
dillera / mastodon_backup.sh
Created December 23, 2022 21:06 — forked from nolanlawson/mastodon_backup.sh
Script to back up a Mastodon instance (for non-dockerized installs)
#!/usr/bin/env bash
#
# Make a backup file of a Mastodon instance. The backup file is a TGZ containing
# the Postgres dump as well as the /public/system (media) files and the
# .env.production file. For loading the dump file contents, see:
# https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Migration-guide.md
#
# Usage: ./mastodon_backup.sh my_dump_file.tgz
#
# Advanced usage: MASTODON_LIVE_DIRECTORY=/path/to/live ./mastodon_backup.sh my_dump_file.tgz