Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / String+AES.swift
Created December 14, 2020 19:35 — forked from matsuda/String+AES.swift
AES encryption in Swift
import CommonCrypto
// MARK: AES128 暗号、復号化
public extension String {
func aesEncrypt(key: String, iv: String) -> String? {
guard
let data = self.data(using: .utf8),
let key = key.data(using: .utf8),
let iv = iv.data(using: .utf8),
@seanlilmateus
seanlilmateus / RelativeSizeLayout.swift
Created March 25, 2023 06:59 — forked from ole/RelativeSizeLayout.swift
A SwiftUI layout and modifier for working with relative sizes ("50 % of your container"). https://oleb.net/2023/swiftui-relative-size/
import SwiftUI
extension View {
/// Proposes a percentage of its received proposed size to `self`.
///
/// This modifier multiplies the proposed size it receives from its parent
/// with the given factors for width and height.
///
/// If the parent proposes `nil` or `.infinity` to us in any dimension,
/// we’ll forward these values to our child view unchanged.
@seanlilmateus
seanlilmateus / AdvancedToolbarWindow.swift
Created March 18, 2023 07:08 — forked from stephancasas/AdvancedToolbarWindow.swift
A SwiftUI-compatible window for macOS with advanced toolbar configurability.
//
// AdvancedToolbarWindow.swift
//
// Created by Stephan Casas on 3/17/23.
//
import SwiftUI;
import AppKit;
class AdvancedToolbarWindow<MainContent: View, TitleToolbarContent: View>: NSWindow, NSToolbarDelegate {
//
// ContentView.swift
// AppleMusicLyricsPlayer
//
// Created by Magesh Sridhar on 2/5/23.
//
import SwiftUI
import AVKit
@seanlilmateus
seanlilmateus / PhotosStylePicker-Final.swift
Created December 29, 2022 00:08 — forked from HarshilShah/PhotosStylePicker-Final.swift
A SwiftUI picker that tries to match the Years/Months/Days/All Photos palette in the Library tab of Photos for iOS
import SwiftUI
protocol TitleProvider {
var title: String { get }
}
extension ColorScheme {
var dual: ColorScheme {
switch self {
case .light: return .dark
@seanlilmateus
seanlilmateus / NSPersistentContainer+extension.swift
Created December 18, 2022 13:08 — forked from atomicbird/NSPersistentContainer+extension.swift
Back up and restore Core Data persistent stores
//
// NSPersistentContainer+extension.swift
// CDMoveDemo
//
// Created by Tom Harrington on 5/12/20.
// Copyright © 2020 Atomic Bird LLC. All rights reserved.
//
import Foundation
import CoreData
@seanlilmateus
seanlilmateus / result.swift
Last active November 15, 2022 13:59
Result in Swift, Error handling in swift rust inspired...
#!/usr/bin/env xcrun swift -i
import Foundation
enum Result<T, E> {
/*
We can't use this at the moment due to a LLVM Error:
error: unimplemented IR generation feature non-fixed multi-payload enum layout
LLVM ERROR: unimplemented IRGen feature! non-fixed multi-payload enum layout
@seanlilmateus
seanlilmateus / Caddyfile
Created June 6, 2022 09:57 — forked from Finkregh/Caddyfile
nextcloud php-fpm caddy 2
(headers) {
header {
-Server
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-XSS-Protection "1; mode=block"
X-Permitted-Cross-Domain-Policies "none"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
X-Robots-Tag "nine"
Permissions-Policy interest-cohort=()
@seanlilmateus
seanlilmateus / URLProtocolMock.swift
Created November 2, 2022 22:07 — forked from soujohnreis/URLProtocolMock.swift
Mock URLSession using URLProtocol
class URLProtocolMock: URLProtocol {
/// Dictionary maps URLs to tuples of error, data, and response
static var mockURLs = [URL?: (error: Error?, data: Data?, response: HTTPURLResponse?)]()
override class func canInit(with request: URLRequest) -> Bool {
// Handle all types of requests
return true
}
override class func canonicalRequest(for request: URLRequest) -> URLRequest {
@seanlilmateus
seanlilmateus / 1.README.md
Created October 1, 2022 10:09 — forked from brettohland/1.README.md
ISBN example with FormatStyle, AttributedStringFormatStyle, ParseableFormatStyle conformance.

Supporting FormatStyle & ParseableFormatStyle To Your Custom Types

A full example of adding String and AttributedString output to our custom types, as well as adding the ability to parse String values into your custom type.

Read the blog post

See the Xcode Playground

ko-fi