This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "SPI.h" | |
#include "Adafruit_WS2801.h" | |
const int numStrands = 1; // number of LED strands to address | |
const int strandLEDs = 50; //Number of LEDs per strand | |
const int numLED = strandLEDs*numStrands; //Total number of LEDs | |
uint8_t analogPin = 14; // A0 - Potentiometer wiper (middle terminal) connected to analog pin 0 | |
uint8_t buttonPin = 15; // A1 | |
uint8_t dataPin = 17; // A3 - Analog pins used to simplify wiring. By using Analog pins we only need to have wires on one side of the Arduino Nano |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <vector> | |
#include <WiFi.h> | |
#include <PubSubClient.h> | |
#include <ArduinoJson.h> | |
#include "led.h" | |
#include "secrets.h" | |
const char *DEVICE_ID = "esp32_presence"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<title>Rug Pattern Editor</title> | |
<style> | |
body { | |
margin: 0; | |
font-family: sans-serif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/ancestry-product-and-technology/swiftui-pro-tips-preferencekey-360505ff8fbb | |
import SwiftUI | |
struct TotalWidth { | |
struct Key: PreferenceKey { | |
static var defaultValue: CGFloat = 0.0 | |
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { | |
value = max(value, nextValue()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the dimensions of each square | |
image_width, image_height = image.size | |
num_squares = 6 # 6x6 grid | |
square_width = image_width // num_squares | |
square_height = image_height // num_squares | |
# Function to calculate average color of a region | |
def average_color(region): | |
return np.mean(region.reshape(-1, 3), axis=0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://nonstrict.eu/blog/2023/stretching-an-audio-file-using-swift/ | |
import Foundation | |
import AVFoundation | |
func scaleAudio(inputURL: URL, toDuration targetDuration: CMTime, outputURL: URL) async throws { | |
// Load info from the input audio file | |
let inputAudioAsset = AVAsset(url: inputURL) | |
let inputAudioDuration = await inputAudioAsset.load(.duration) | |
let inputAudioTimeRange = CMTimeRange(start: .zero, duration: inputAudioDuration) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put the following code into a new VisionOS 2 beta project and run it | |
// inside a real device (hand tracking will fail in the simulator) | |
// interacting with the door on the hinge will separate it from the hinge | |
import SwiftUI | |
import RealityKit | |
import ARKit | |
let mat1 = UnlitMaterial(color: .blue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using SixLabors.ImageSharp; | |
using SixLabors.ImageSharp.Processing; | |
using SixLabors.ImageSharp.PixelFormats; | |
using Image = SixLabors.ImageSharp.Image; | |
using SixLabors.ImageSharp.Formats.Png; | |
class Program | |
{ | |
static readonly PngEncoder encoder = new() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static readonly StringBuilder buffer = new StringBuilder(); | |
void Main() | |
{ | |
// first mod adds transpiler | |
Console.WriteLine("// APPLYING PATCH 1"); | |
var h1 = new Harmony("test1"); | |
h1.CreateClassProcessor(typeof(Patch1)).Patch(); | |
// second mod adds transpiler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
Test.Run(); | |
var harmony = new Harmony("test"); | |
harmony.PatchCategory("category1"); | |
Test.Run(); | |
harmony.PatchCategory("category2"); | |
Test.Run(); |
NewerOlder