Skip to content

Instantly share code, notes, and snippets.

View philosopherdog's full-sized avatar

Steve Thompson philosopherdog

View GitHub Profile

Declaring models

class Dog: Object {

  dynamic var id = ""

  dynamic var name = ""

 dynamic var tempVariable = ""
public struct AnyEquatable: Equatable {
private let value: Any
private let equals: Any -> Bool
public init<E: Equatable>(_ value: E) {
self.value = value
self.equals = { ($0 as? E == value) ?? false }
}
}
@philosopherdog
philosopherdog / CountdownTests.swift
Created August 16, 2021 23:48 — forked from JonnyBeeGod/CountdownTests.swift
This code allows for testing UNNotificationCenter and UNNotificationSettings
func testNotifications() {
// map all authorizationStatus with expected Result
let authorizationStatusMap: [UNAuthorizationStatus: Int] = [.authorized: 1, .denied: 0, .notDetermined: 0, .provisional: 1]
UNNotificationSettings.swizzleAuthorizationStatus()
authorizationStatusMap.forEach { (key: UNAuthorizationStatus, value: Int) in
UNNotificationSettings.fakeAuthorizationStatus = key
let mockCenter = UserNotificationCenterMock()
let mockCoder = MockNSCoder()
import Foundation
final class Sample: NSObject {
@objc dynamic var name: String = ""
}
class MyObj: NSObject {
@objc dynamic var test: String = ""
}
extension NSObjectProtocol where Self: NSObject {
//
// ContentMapper.swift
//
//
// Created by Antoine van der Lee on 09/03/2021.
//
import Foundation
import ContentKit
@philosopherdog
philosopherdog / CustomStringConvertible.swift
Last active December 8, 2021 14:51 — forked from khramtsoff/CustomStringConvertible.swift
CustomStringConvertible prints memory address
import Foundation
extension CustomStringConvertible {
var description: String {
var description: String = "\(type(of: self))("
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {

Videos

@philosopherdog
philosopherdog / hosting-on-github.md
Created May 25, 2019 18:50 — forked from TylerFisher/hosting-on-github.md
Basic steps for hosting on Github

Steps for Hosting a Website on GitHub

  1. Create a GitHub account on github.com.
  2. Download either [GitHub for Mac][1] or [GitHub for Windows][2], depending on your operating system. Open the app and log in using the account you just created.
  3. (On Mac): After you login, click advanced and make sure that your name and email are correct. Then, click "Install Command Line Tools", just in case you want to start using the command line later in life.
  4. Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the "Push to GitHub?" box is checked.
  5. Move your website's files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level directory.
  6. Back in the GitHub application, you should see your files in the left column. Make sure they are all checked. If so, enter a mess
@philosopherdog
philosopherdog / CURL-cheatsheet.md
Created January 25, 2018 18:57 — forked from Kartones/CURL-cheatsheet.md
CURL Cheatsheet
  • XML GET
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
  • JSON GET
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
  • JSON PUT
@philosopherdog
philosopherdog / FakeUserDefaults.swift
Created January 4, 2017 01:34
Swift NSUserDefaults Fake for Testing
// Copyright (c) 2014 Mark Grimes. All rights reserved.
import Foundation
class FakeUserDefaults : NSUserDefaults {
typealias FakeDefaults = Dictionary<String, AnyObject?>
var data : FakeDefaults
override init?(suiteName suitename: String) {