Skip to content

Instantly share code, notes, and snippets.

View roymckenzie's full-sized avatar

Roy McKenzie roymckenzie

View GitHub Profile
@roymckenzie
roymckenzie / wpdebug.sh
Created April 24, 2024 01:15
wpdebug.sh - WordPress Debugging Shell Script
#!/bin/bash
# Script Name: Script Name: wpdebug.sh
# Description: A script for enabling or disabling WordPress debugging mode in the wp-config.php file.
# Author: Roy McKenzie
# Date: April 23, 2024
# Version: 1.0
#
# Usage: ./wpdebug.sh [install|uninstall|enable|disable|tail|delete]
#
# Options:
@roymckenzie
roymckenzie / Icon.ts
Created October 20, 2023 09:52
Mithril.js - Tailwind/SVG Icons
import m from 'mithril';
import trashIcon from '../../../public/trash.svg?raw';
import bars3 from '../../../public/bars-3.svg?raw';
import bars4 from '../../../public/bars-4.svg?raw';
const IconMap = {
trash: trashIcon,
'bars-3': bars3,
'bars-4': bars4
};
{
"+1": "👍",
"-1": "👎",
"100": "💯",
"1234": "🔢",
"8ball": "🎱",
"ab": "🆎",
"abc": "🔤",
"abcd": "🔡",
"accept": "🉑",
@roymckenzie
roymckenzie / NotificationPermissionController.swift
Last active February 24, 2017 23:00
Easily request permissions in iOS 9 and iOS 10
import UIKit
import UserNotifications
import PropellerPromise
struct NotificationPermissionController {
static var permissionsEnabled: Bool {
guard let settings = UIApplication.shared.currentUserNotificationSettings else {
return false
}
@roymckenzie
roymckenzie / CloudKitSyncable.swift
Last active January 27, 2017 22:00
Protocol for Realm Objects that I want to sync with CloudKit
protocol CloudKitSyncable {
var id: String { get }
var recordID: CKRecordID { get }
var synced: Date? { get }
var modified: Date { get }
var deleted: Date? { get }
var record: CKRecord { get }
var recordChangeTag: String? { get }
var recordOwnerName: String? { get }
}
@roymckenzie
roymckenzie / CloudKitAppDelegate.swift
Last active January 30, 2017 17:19
AppDelegate implementation for CloudKit
import UIKit
import UserNotifications
import CloudKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
final class DataDisplayViewController: UIViewController {
private var realmNotificationToken: NotificationToken?
override func viewDidLoad() {
super.viewDidLoad()
startRealmNotification()
}
@roymckenzie
roymckenzie / CloudKitBasics.swift
Last active August 10, 2022 12:01
Basic Subscription and Fetch manager and setup for CloudKit
import UIKit
import CloudKit
import RealmSwift
/// Handles common methods for subscriptions across multiple databases
enum CloudKitDatabaseSubscription: String {
case `private`
case `public`
}
@roymckenzie
roymckenzie / PrivateDatabaseSubscription.swift
Last active January 27, 2017 17:36
Private Database Subscription
import CloudKit
// Create subscription with an internal identifier
let subscription = CKDatabaseSubscription(subscriptionID: "internalSubscriptionIdentifier")
// Create an operation to save the subscription
let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription],
subscriptionIDsToDelete: nil)
// Add the operation to the private database
CKContainer.default()
@roymckenzie
roymckenzie / fastfile.rb
Last active October 25, 2016 01:00
Date based version number generator for fast lane (YYYYMMDD.0)
platform :ios do
lane :beta do
# ...
increment_build_number(xcodeproj: "ProjectName.xcodeproj",
build_number: date_based_build_number)
end
# Generate todays date formatted for version
def today_formatted
Date.today.strftime('%Y%m%d')