Skip to content

Instantly share code, notes, and snippets.

View renssies's full-sized avatar

Rens Verhoeven renssies

View GitHub Profile
import ORSSerial
/// An example of an extension of the ORSSerialPacketDescriptor that enables identifying delimited packets.
public class DelimitedSerialPacketDescriptor: ORSSerialPacketDescriptor {
private(set) public var delimiter: Data?
convenience public init(delimiter: Data, maximumPacketLength maxPacketLength: UInt, userInfo: AnyObject?, responseEvaluator: @escaping ORSSerialPacketEvaluator) {
self.init(maximumPacketLength: maxPacketLength, userInfo: userInfo, responseEvaluator: responseEvaluator)
@renssies
renssies / TVControl.ino
Created February 8, 2024 23:34
Control LG WebOS TV using ESP32 and Arduino (PlatformIO)
/*
Control a LG WebOS TV using ESP32. This file is made using PlatformIO but Arduino should be supported as well.
*/
// Arduino libraries
#include <Arduino.h>
// ESP32 Framework libraries
@renssies
renssies / UIBezierPathExtensions.swift
Created July 6, 2020 16:15
Create a rounded UIBezierPath with a different corner radius per corner
extension UIBezierPath {
/// Defines a corner of a rounded rectangle path.
public enum RoundedRectCorner {
case topLeft
case topRight
case bottomLeft
case bottomRight
case all
}
@renssies
renssies / UIBezierPathExtensions.swift
Last active October 25, 2023 14:14
Rounded UIBezierPath without clamping bug
extension UIBezierPath {
/// Creates a rounded rectangle without clamping the corner radius the 1/3 of the rects width or height.
/// This can be used to workout a bug in the standard `UIBezierPath(roundedRect:cornerRadius)`.
///
/// It will however clamp the corner radius to a max of half the width or height of the rect, this is to avoid incorrect drawing.
/// - Parameters:
/// - rect: The rectangle that defines the basic shape of the path
/// - cornerRadius: The radius of each corner oval. A value of 0 results in a rectangle without rounded corners. Values larger than half the rectangle’s width or height are clamped appropriately to half the width or height.
convenience init(unclampedRoundedRect rect: CGRect, cornerRadius: CGFloat) {