Skip to content

Instantly share code, notes, and snippets.

View markbattistella's full-sized avatar
🐢
code. code. code

Mark Battistella markbattistella

🐢
code. code. code
View GitHub Profile
@markbattistella
markbattistella / PlatformCheck.swift
Created February 19, 2024 23:27
A Swift Utility for OS Environment Checks
//
// Author: Mark Battistella
// Website: https://markbattistella.com
//
#if os(iOS)
import UIKit
#else
import Foundation
#endif
@markbattistella
markbattistella / auto-increment.sh
Created December 27, 2023 05:32
Auto-increment Xcode project number
#!/bin/sh
#
# auto-increment.sh
# Author: Mark Battistella
# Website: https://markbattistella.com
#
# get the path for the config file
CONFIG_FILE="${PROJECT_DIR}/Shared/Data/Config.xcconfig"
@markbattistella
markbattistella / youtubeEmbed
Created November 11, 2023 23:49
Open Youtube in new window
javascript:(function(){
if(window.location.host === 'www.youtube.com' && window.location.pathname === '/watch'){
var videoId = window.location.search.split('v=')[1];
var ampersandPosition = videoId.indexOf('&');
if(ampersandPosition != -1) {
videoId = videoId.substring(0, ampersandPosition);
}
var embedUrl = 'https://www.youtube.com/embed/' + videoId;
window.open(embedUrl, 'youtube', 'width=1920,height=1080');
}
@markbattistella
markbattistella / IDETemplateMacros.plist
Created September 1, 2023 06:30
Template for IDETemplateMacros.plist when creating Xcode projects
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
// Project: ___PROJECTNAME___
// Author: ___FULLUSERNAME___
// Website: ___WEBSITE___
//
final class CoreDataManager {
// -- singleton initalisation
static let shared = CoreDataManager()
var container: NSPersistentContainer
// -- managed object context
var managedObjectContext: NSManagedObjectContext {
container.viewContext
@markbattistella
markbattistella / GetSize.swift
Last active October 28, 2022 23:22
Retrieve the size of an element within SwiftUI
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct ContentView: View {
@State var hStackSize: CGSize = .zero
var body: some View {
@markbattistella
markbattistella / MaskingView.swift
Last active December 30, 2022 11:13
Hide the details of a View when resigning a SwiftUI app to background
struct MaskingViewModifier: ViewModifier {
@Environment(\.scenePhase)
private var scenePhase
@State private var selectedPhase: ScenePhase?
func body(content: Content) -> some View {
ZStack {
content