Skip to content

Instantly share code, notes, and snippets.

View james-william-r's full-sized avatar

James james-william-r

View GitHub Profile
@dkun7944
dkun7944 / CDView.swift
Last active July 17, 2024 03:27
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {
@krabs-github
krabs-github / JavaScript - Determine if Hex Color is Light or Dark.js
Last active July 12, 2024 20:21
[JavaScript - Determine if Hex Color is Light or Dark] JavaScript - Determine if Hex Color is Light or Dark #JavaScript
function lightOrDark(color) {
// Check the format of the color, HEX or RGB?
if (color.match(/^rgb/)) {
// If HEX --> store the red, green, blue values in separate variables
color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
r = color[1];
g = color[2];
@Gujci
Gujci / StripePaymentCardTextField.swift
Created July 2, 2020 08:57
SwiftUI wrapper around the STPPaymentCardTextField from Stripe
struct StripePaymentCardTextField: UIViewRepresentable {
@Binding var cardParams: STPPaymentMethodCardParams
@Binding var isValid: Bool
func makeUIView(context: Context) -> STPPaymentCardTextField {
let input = STPPaymentCardTextField()
input.borderWidth = 0
input.delegate = context.coordinator
return input
@krummler
krummler / String+EmojiCheck.swift
Last active December 26, 2023 10:21
Emoji Checking for Swift 5.0 and up
import Foundation
extension Character {
/// A simple emoji is one scalar and presented to the user as an Emoji
var isSimpleEmoji: Bool {
return unicodeScalars.count == 1 && unicodeScalars.first?.properties.isEmojiPresentation ?? false
}
/// Checks if the scalars will be merged into and emoji
var isCombinedIntoEmoji: Bool {