Skip to content

Instantly share code, notes, and snippets.

View krzysztofzablocki's full-sized avatar

Krzysztof Zabłocki krzysztofzablocki

View GitHub Profile
@adityadaniel
adityadaniel / dependencies.stencil
Created January 31, 2023 15:56
Test Dependency TCA Sourcery Template
{% for type in types.all where type.implements.DependencyKey %}
#if DEBUG
extension {{ type.name }}: TestDependencyKey {
{{ type.accessLevel }} static let testValue = {{ type.name }}(
{% for var in type.variables %}
{% if var.typeName.closure.actualReturnTypeName|contains:"Void"| %}
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: ())
{% elif var.typeName.closure.actualReturnTypeName|contains:"Effect" %}
{{ var.name }}: unimplemented("\(Self.self).{{ var.name }} is unimplemented", placeholder: Effect.none)
{% elif var.typeName.closure.actualReturnTypeName.isArray %}
@steipete
steipete / Sparkle.swift
Last active May 5, 2021 15:18
Sparkle + SwiftUI
lass AppUpdateHandler: ObservableObject {
#if SPARKLE
private let delegateHandler = SparkleDelegateHandler()
let sparkle: SPUStandardUpdaterController
init() {
// Setup sparkle updater
// https://docs.microsoft.com/en-us/appcenter/distribution/sparkleupdates
// https://rambo.codes/posts/2021-01-08-distributing-mac-apps-outside-the-app-store
sparkle = SPUStandardUpdaterController(updaterDelegate: delegateHandler, userDriverDelegate: delegateHandler)
@steipete
steipete / View.swift
Created April 4, 2021 13:43
Accept dropping a file onto SwiftUI (both iOS and macOS)
.onDrop(of: [.fileURL], isTargeted: nil) { providers in
if let loadableProvider = providers.first(where: { $0.canLoadObject(ofClass: URL.self) }) {
_ = loadableProvider.loadObject(ofClass: URL.self) { fileURL, _ in
if let fileURL = fileURL, fileURL.pathExtension.lowercased() == "zip" {
self.logger.info("Dropped \(fileURL.path)")
DispatchQueue.main.async {
importer.open(zipArchiveURL: fileURL)
}
}
}
// Copyright (c) 2021 Manuel Maly
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@manmal
manmal / SharedState.swift
Last active April 25, 2021 08:18
Shared State for The Composable Architecture - Make state accessible to sub components
// Copyright (c) 2021 Manuel Maly
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@tajnymag
tajnymag / tinder.user.js
Last active March 10, 2024 18:59
Tinder Deblur Userscript (ARCHIVED and DEPRECATED, see https://github.com/tajnymag/tinder-deblur)
// ==UserScript==
// @name Tinder Deblur
// @namespace Violentmonkey Scripts
// @match https://tinder.com/*
// @grant none
// @version 1.4
// @author Tajnymag
// @downloadURL https://raw.githubusercontent.com/tajnymag/tinder-deblur/main/tinder.user.js
// @description Simple script using the official Tinder API to get clean photos of the users who liked you
// ==/UserScript==
@IanKeen
IanKeen / Example_Complex.swift
Last active January 23, 2024 07:53
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
struct User: Equatable {
var firstName: String
var lastName: String
}
@main
struct MyApp: App {
@State var value = User(firstName: "", lastName: "")
@State var showEdit = false
import CloudKit
import Combine
/// Fetches the user's CloudKit Account status.
///
/// - Parameter container: The container to check the status in.
///
/// - Returns: A deferred future that resolves to the user's CloudKit Account status.
func getAccountStatus(for container: CKContainer) -> AnyPublisher<CKAccountStatus, Error> {
Deferred {
@smic
smic / BorderlessWindow.swift
Last active July 7, 2023 20:19
Extension to create borderless windows in SwiftUI
import SwiftUI
extension CGRect {
fileprivate func point(anchor: UnitPoint) -> CGPoint {
var point = self.origin
point.x += self.size.width * anchor.x
#if os(macOS)
point.y += self.size.height * (1 - anchor.y)
#else
point.y += self.size.height * anchor.y