Skip to content

Instantly share code, notes, and snippets.

View schappim's full-sized avatar
💤
Sleeping . +10GMT

Marcus S schappim

💤
Sleeping . +10GMT
View GitHub Profile

How to Enable Load Balancer Health Checks in Hatchbox

A load balancer health check with Caddy ensures that backend servers are functioning properly by periodically sending requests and removing unresponsive servers from the pool.

To enable health checks, your application must have a relative path that returns a 200 status code.

Steps to enable health checks:

  1. Go to https://app.hatchbox.io/apps
  2. Click the "View" button for your application

Below is an example of how to set up a Raspberry Pi to record both video and audio using the Raspberry Pi NoIR Camera Module and an external USB microphone.

Requirements

  1. Raspberry Pi with Raspbian OS installed
  2. Raspberry Pi NoIR Camera Module
  3. USB microphone
  4. Python installed on the Raspberry Pi

Step-by-Step Guide

<div class="cart__row">
<label>
<input type="checkbox" name="attributes[Signature on Delivery]" value="Yes">
Signature on Delivery
</label>
</div>

To control the Raspberry Pi camera from Python, you can use the picamera library, which provides an easy-to-use interface for capturing images and videos. Here's a basic example to get you started:

  1. Install the picamera library:

    sudo apt update
    sudo apt install python3-picamera
  2. Capture an image:

@schappim
schappim / set_dns.sh
Last active June 27, 2024 22:24
Script to configure the DNS server on Debian-based Linux systems at boot
#!/bin/bash
# Set this to your desired DNS server
DNS_SERVER="8.8.8.8"
# Set the path for this script
SCRIPT_PATH="/usr/local/bin/set_dns.sh"
# Path to the resolv.conf file
RESOLV_CONF="/etc/resolv.conf"
@schappim
schappim / ph_sensor.py
Created May 6, 2024 05:52
To rewrite the provided Arduino code for use on a Raspberry Pi 4 using Python, you'll need to use a Python library for GPIO control and analog input. Raspberry Pi does not natively support analog input, so you will need an external ADC (Analog to Digital Converter) such as the MCP3008 to read the pH sensor. Here's how you can adapt your Arduino …
import time
import spidev
import RPi.GPIO as GPIO
# Set up SPI
spi = spidev.SpiDev()
spi.open(0, 0)
spi.max_speed_hz = 1000000
def read_adc(channel):
#define PH_SENSOR_PIN 0 // pH meter Analog output connected to Arduino Analog Input 0
const int NUM_SAMPLES = 10; // Number of samples to take for smoothing the value
const int NUM_SAMPLES_TO_AVERAGE = 6; // Number of center samples to average
unsigned long int averageValue; // Store the average value of the sensor feedback
float pHValue; // Store the calculated pH value
int sensorReadings[NUM_SAMPLES]; // Array to store sensor readings
int tempValue; // Temporary variable for sorting
@schappim
schappim / just_f-ing_ping.md
Last active February 17, 2024 06:15
Just F-ing Ping - Because sometimes you just want to f-ing ping!

Just F-ing Ping

Because sometimes you just want to f-ing ping!

Modern browsers, believing they are being clever, hide the protocol in the URL bar.

image

However, even if you only select the hostname, when you paste that URL into your terminal, you will encounter the following:

image

@schappim
schappim / example_shopify_customer_deletion.rb
Created January 5, 2024 04:02
This is an example of how to delete customers via the Shopify Admin API
require 'httparty'
require 'date'
class ShopifyClient
include HTTParty
base_uri 'https://{shop_domain}.myshopify.com/admin/api/2023-10'
def initialize(api_key, password)
self.class.basic_auth(api_key, password)
end
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x20 for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x20, 20, 4);
void setup() {
// Initialize the LCD
lcd.init(); // or lcd.begin();
lcd.backlight();