Skip to content

Instantly share code, notes, and snippets.

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

Otter james-william-r

  • MoveThrough
  • United Kingdom
  • 18:31 (UTC)
View GitHub Profile
@krummler
krummler / String+EmojiCheck.swift
Last active September 3, 2024 11:40
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 {
@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
@krabs-github
krabs-github / JavaScript - Determine if Hex Color is Light or Dark.js
Last active October 8, 2024 10:31
[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];
@dkun7944
dkun7944 / CDView.swift
Last active October 20, 2024 01:38
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {