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
@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();
ModelShare License Version 1.0
Copyright (c) [Year], [Your Name/Your Company's Name]. All rights reserved.
1. DEFINITIONS:
"Content" refers to all data, text, images, graphics, videos, and other materials available on [Your Website URL].
"Model" refers to any machine learning, deep learning, artificial intelligence model, or algorithm.

% IANA WHOIS server % for more information on IANA, visit http://www.iana.org % This query returned 1 object

refer: whois.verisign-grs.com

domain: COM

organisation: VeriSign Global Registry Services address: 12061 Bluemont Way

import Foundation
import Vision
import AppKit
func performOCR(on image: NSImage, completion: @escaping ([String: Any]) -> Void) {
guard let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil) else {
print("Error: Unable to get CGImage from NSImage.")
exit(1)
}
@schappim
schappim / prompt.txt
Last active February 8, 2023 23:18
A large language model prompt to extract nutritional data from a label from OCR data
# This prompt takes a string of text and returns a JSON object with the following information.
# If the text value is not available for a key, skip the key
# Extract the following information from the following "Nutrition Data OCR" as a JSON object:
{
"energy_kj_per_100g": [integer],
"energy_kj_per_serving": [integer],
"protein_g_per_100g": [float],
"protein_g_per_serving": [float],
"fat_total_g_per_100g": [float],
<script defer src="https://unpkg.com/alpinejs@3.10.3/dist/cdn.min.js"></script>
<script type="text/javascript">
window.changeImageURLs = function() {
return {
changeTheURLs() {
// get the current product URL without the query string
var currentURL = window.location.href.split('?')[0];