Skip to content

Instantly share code, notes, and snippets.

@yHomework
yHomework / DarwinNotificationCenter.swift
Created September 10, 2020 16:55 — forked from AvdLee/DarwinNotificationCenter.swift
A notification center for Darwin Notifications. MIT License applies.
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
import Foundation
/// A Darwin notification payload. It does not contain any userInfo, a Darwin notification is purely event handling.
public struct DarwinNotification {
@yHomework
yHomework / ForPerformance.playground
Created September 10, 2020 16:58 — forked from AvdLee/ForPerformance.playground
For each vs for loop performance
//: Playground - noun: a place where people can play
import XCTest
class MyTests: XCTestCase {
lazy var testData: [Int] = {
return (0..<1000).map { Int($0) }
}()
@yHomework
yHomework / Publisher+Unwrap.swift
Created September 10, 2020 17:21 — forked from rpassis/Publisher+Unwrap.swift
Combine Recipe - Unwrapping an optional type operator
public protocol OptionalType {
associatedtype Wrapped
var value: Wrapped? { get }
}
extension Optional: OptionalType {
public var value: Wrapped? {
return self
}
}
@yHomework
yHomework / Keyboard.swift
Created September 12, 2020 12:21 — forked from nickffox/Keyboard.swift
Adjusting a SwiftUI View for the Keyboard.
import Combine
final class Keyboard: ObservableObject {
// MARK: - Published Properties
@Published var state: Keyboard.State = .default
// MARK: - Private Properties
@yHomework
yHomework / Working-With-XCode
Created September 16, 2020 09:13 — forked from quoha/Working-With-XCode
Using XCode with github
Using XCode with github
=======================
0. These steps were pulled from the documentation on github
1. Create an empty repository on GitHub
do not initialize with a README
2. Note the SSH path to the new repository
git@github.com:quoha/derp-octo-sansa.git
//------------------------------------------------------------------------
// The SwiftUI Lab: Advanced SwiftUI Animations
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths)
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect)
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier)
//------------------------------------------------------------------------
import SwiftUI
struct ContentView: View {
// Safely Modifying The View State (SwiftUI)
// https://swiftui-lab.com
// https://swiftui-lab.com/state-changes
import SwiftUI
struct CustomView: View {
var body: some View {
NavigationView {
@yHomework
yHomework / Calendar.swift
Created October 4, 2020 18:38 — forked from mecid/Calendar.swift
SwiftUI Calendar view using LazyVGrid
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
@yHomework
yHomework / DocsIcon.swift
Created October 4, 2020 23:58 — forked from erikbasargin/DocsIcon.swift
How cut a Text shape from your View in SwiftUI?
import PlaygroundSupport
import SwiftUI
struct DocsView: View {
var body: some View {
iconBody.frame(height: 200).mask(
ZStack(alignment: .bottomLeading) {
Rectangle()
.fill(Color.white)
Text("DOCs")
@yHomework
yHomework / Info.plist
Created October 15, 2020 08:30 — forked from blochberger/Info.plist
macOS/iOS TLS 1.3 Support
<?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>NSExceptionDomains</key>
<dict>
<key>www.howsmyssl.com</key>
<dict>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.3</string>