Skip to content

Instantly share code, notes, and snippets.

View trentjmorris's full-sized avatar
:octocat:
iOS Developer & AI Hobbyist

Trent Morris trentjmorris

:octocat:
iOS Developer & AI Hobbyist
View GitHub Profile
@peterfriese
peterfriese / Color+Codable.swift
Created March 19, 2021 11:00
Making Swift's Color codable
//
// Color+Codable.swift
// FirestoreCodableSamples
//
// Created by Peter Friese on 18.03.21.
//
import SwiftUI
// Inspired by https://cocoacasts.com/from-hex-to-uicolor-and-back-in-swift
@mac-cain13
mac-cain13 / AccessibleHStack.swift
Created July 9, 2020 07:19
SwiftUI - AccessibleHStack
//
// AccessibleHStack.swift
//
// Created by Mathijs Kadijk on 08/07/2020.
//
import SwiftUI
/// HStack that will switch to a VStack when the horizontal size class is compact and the content size category is set to an accessibility size option
struct AccessibleHStack<Content>: View where Content: View {
@chriseidhof
chriseidhof / swiftui.swift
Last active March 15, 2023 06:53
SwiftUI - iOS
import Combine
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
import SwiftUI
import UIKit
import os.log
import os
@westerlund
westerlund / FontSizesHelper.swift
Last active July 17, 2022 18:17
I made a really simple helper for using Dynamic Type with your own fonts
struct FontSizesHelper {
static func dynamicSize(for originalSize: CGFloat, category: UIContentSizeCategory = UIApplication.shared.preferredContentSizeCategory) -> CGFloat {
let modifyBy: CGFloat = {
switch category {
case .extraSmall: return -3
case .small: return -2
case .medium: return -1
case .large: return 0
case .extraLarge: return 2
case .extraExtraLarge: return 4
@cmikeb1
cmikeb1 / fetchCoinPrice.scpt
Created June 9, 2017 01:12
AppleScript to retrieve crypto currency prices
validate_sheet()
set coins to {}
-- retrieve the list of coins from number
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set cntRow to count row
set cntCol to count column
@tadija
tadija / Xcode Semi-Automatic Versioning.md
Last active August 11, 2022 19:55
Xcode Semi-Automatic Versioning | Bump Build Number | Bump Version Number

Xcode Semi-Automatic Versioning

Instructions:

First Things First

In order for agvtool to work properly you must first set
Project Settings / Build Settings / Versioning / Versioning System to Apple Generic.

Bump Build Number

  1. Create new shared scheme 'Bump Build Number'
@proxpero
proxpero / MergingOverlappingIntervals.swift
Last active September 25, 2022 17:06
Merging Overlapping Intervals (`Range<Int>`s) in Swift
//: [Merging Overlapping Intervals](https://www.shiftedup.com/2015/05/17/programming-challenge-merging-overlapping-intervals)
//: Xcode 7.0, Swift 2.0
/*: Given a collection of intervals, write a function that merges all overlapping intervals and prints them out.
For example, given [1, 3], [2, 6], [8, 10], and [7, 11], the function should print [1, 6], [7, 11]. Or given [5, 12], and [8, 10] the function should print [5, 12].
You can assume that the first element of each interval is always less or equal than the second element of the interval.
*/
//: Note: The challenge suggests that each interval is an `Array<Int>` where `interval.count == 2` and `interval[0] <= interval[1]`. In Swift, these intervals should be modeled by the `Range<Int>` type. I am altering the challenge to suit the language, I know. [TKO]
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}
@nicferrier
nicferrier / gist:2277987
Created April 1, 2012 19:34
Clone a git repo if it does not exist, or pull into it if it does exist
#!/bin/sh
REPOSRC=$1
LOCALREPO=$2
# We do it this way so that we can abstract if from just git later on
LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]
then
@mlconnor
mlconnor / country_date_formats.csv
Created February 22, 2012 20:49
Listing of countries with their preferred date formats, ISO3166 code, ISO629-2
ISO 3166 Country Code ISO639-2 Country Code Country ISO 3166 Country Code ISO639-2 Lang Language Date Format
ALB AL Albania sqi sq Albanian yyyy-MM-dd
ARE AE United Arab Emirates ara ar Arabic dd/MM/yyyy
ARG AR Argentina spa es Spanish dd/MM/yyyy
AUS AU Australia eng en English d/MM/yyyy
AUT AT Austria deu de German dd.MM.yyyy
BEL BE Belgium fra fr French d/MM/yyyy
BEL BE Belgium nld nl Dutch d/MM/yyyy
BGR BG Bulgaria bul bg Bulgarian yyyy-M-d
BHR BH Bahrain ara ar Arabic dd/MM/yyyy