Skip to content

Instantly share code, notes, and snippets.

View warpling's full-sized avatar

Ryan McLeod warpling

View GitHub Profile
@warpling
warpling / CAMediaTimingFunction+Extended.swift
Last active April 12, 2024 10:33
CAMediaTimingFunctions (Swift 4)
//
// CAMediaTimingFunctions+Extended.swift
// Geiger
//
// Created by Ryan McLeod on 1/22/19.
// Copyright © 2019 Grow Pixel. All rights reserved.
//
import UIKit
@warpling
warpling / BillboardSystem.swift
Last active September 18, 2023 12:57
Billboarding System/Component for RealityKit (you supply headPosition)
import RealityKit
struct BillboardSystem: System {
static let query = EntityQuery(where: .has(BillboardComponent.self))
init(scene: RealityKit.Scene) {}
func update(context: SceneUpdateContext) {
context.scene.performQuery(Self.query).forEach { entity in
@warpling
warpling / Moon.h
Last active July 26, 2023 07:16
🌔 Drawing an accurate moon with UIBezierPath
//
// Moon.h
// Blackbox
//
// Created by Ryan McLeod on 12/2/14.
// Copyright (c) 2014 Ryan McLeod. All rights reserved.
//
#import <UIKit/UIKit.h>
@warpling
warpling / UIBezierPath+AttributedString.swift
Last active January 10, 2023 05:22
AttributedString to UIBezierPath
extension UIBezierPath {
// Source: https://github.com/aderussell/string-to-CGPathRef/blob/0bd9350dc2100029f3ddb8d9667384841549ecd6/ARCGPathFromString/ARCGPathFromString.m
convenience init(attributedString: NSAttributedString) {
let letters = CGMutablePath()
let line = CTLineCreateWithAttributedString(attributedString as CFAttributedString)
let runArray = CTLineGetGlyphRuns(line)
@warpling
warpling / CAMediaTimingFunction.swift
Last active June 14, 2022 11:15
Better CAMediaTimingFunctions
//
// CAMediaTimingFunction.swift
import UIKit
extension CAMediaTimingFunction {
static let linear = CAMediaTimingFunction(name: .linear)
static let easeOut = CAMediaTimingFunction(name: .easeOut)
@warpling
warpling / UIBezierPathLength.swift
Created July 21, 2016 20:38 — forked from janselv/UIBezierPathLength.swift
Get total iOS CGPath length as an extension of UIBezierPath written in swift
// The MIT License (MIT)
//
// Copyright (c) 2016 Jansel Valentin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@warpling
warpling / extraUIActivityTypes.m
Created November 24, 2016 07:42
Extra UIActivityTypes
// UIActivityTypes
NSString * const UIActivityTypePostToInstagram = @"com.burbn.instagram.shareextension";
NSString * const UIActivityTypeFacebookMessenger = @"com.facebook.Messenger.ShareExtension";
NSString * const UIActivityTypeWhatsApp = @"net.whatsapp.WhatsApp.ShareExtension";
NSString * const UIActivityTypeTelegraph = @"ph.telegra.Telegraph.Share";
NSString * const UIActivityTypeGmail = @"com.google.Gmail.ShareExtension";
NSString * const UIActivityTypeTencent = @"com.tencent.mqq.ShareExtension";
NSString * const UIActivityTypeViber = @"com.viber.app-share-extension";
NSString * const UIActivityTypeTumblr = @"com.tumblr.tumblr.Share-With-Tumblr";
NSString * const UIActivityTypeSkype = @"com.skype.skype.sharingextension";
@warpling
warpling / UIColor+ContrastChecker.swift
Created September 28, 2020 12:15
Color Extensions
//
// UIColor+ContrastChecker.swift
// Stay Inside
//
// Created by Ryan McLeod on 5/6/20.
// Copyright © 2020 Grow Pixel. All rights reserved.
//
import UIKit
@warpling
warpling / RegexExample
Created December 14, 2019 14:06
Help me create a regex that captures the first quoted string and the second quoted string!
/* This is not important but maybe useful to the regex */
"this.is.a.reverse-dns.thing" = "Blackbox “Stealth” T-Shirt";
/* This is not important but maybe useful to the regex */
"this.is.another.reverse-dns.thing-it.can.have-hyphens" = "I’m a long string.
I also have line breaks and sometimes \"escaped quotation marks\"
📦 Oh and emojis.";
@warpling
warpling / Mento.playground
Last active August 1, 2019 20:11
Copying Tinder's "mentos" button animation (based on tweet: https://twitter.com/warpling/status/930567671015358464?s=20)
//: Playground - noun: a place where people can play
import UIKit
class Mento: UIView {
// The thickness ratio of our mento, 1.0 being a perfect sphere.
let mentoThicknessScale: CGFloat = 0.60
let shape: UIView = {