Skip to content

Instantly share code, notes, and snippets.

View TizianoCoroneo's full-sized avatar
👹
Playing type-level Sudoku

TizianoCoroneo TizianoCoroneo

👹
Playing type-level Sudoku
View GitHub Profile
@TizianoCoroneo
TizianoCoroneo / cast.swift
Last active May 9, 2024 07:20
Swift 5.10 - Cast [Any] to a tuple
private func cast<each Result>(
_ values: [Any],
to r: (repeat each Result).Type = (repeat each Result).self
) throws -> (repeat each Result) {
var count = 0
return try (repeat castElement(values, to: (each Result).self, index: &count))
}
private func castElement<R>(
_ values: [Any],
**Privacy Policy**
Tiziano Coroneo built the Colors of Mana app as a Freemium app. This SERVICE is provided by Tiziano Coroneo at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at Colors of Mana unless otherwise defined in this Privacy Policy.
# Privacy Policy
Tiziano Coroneo built Death Wish as a Commercial app. This SERVICE is provided by Tiziano Coroneo and is intended for use as is.
I do not collect any form of personal information, nor use any form of analytics to collect information on user behavior or other anonymous information.
What you do with this app is completely 100% not my business.
# Changes to This Privacy Policy
I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page.
This policy is effective as of 2021-11-28
# Contact Us
@TizianoCoroneo
TizianoCoroneo / gist:ce0e9cab877b9dab59c0650308fca4de
Created April 24, 2021 15:08
Cool home navbar scrolling animation in SwiftUI
import SwiftUI
struct ContentView: View {
@State var currentOffset: CGFloat = 0
@State var topMessagePadding: CGFloat = 30
@State var fadeAlpha: Double = 0
@State var navBarFadeAlpha: Double = 0
@State var imageVerticalOffset: CGFloat = 0
@TizianoCoroneo
TizianoCoroneo / DontTrustThisSelector.swift
Created August 6, 2020 16:24
Closure based Selector
import Foundation
import PlaygroundSupport
import UIKit
final class Sel {
static let target = DummyClass.shared
final class DummyClass {

Keybase proof

I hereby claim:

  • I am tizianocoroneo on github.
  • I am tizianocoroneo (https://keybase.io/tizianocoroneo) on keybase.
  • I have a public key ASAxKa9FW3eoS3gdULNeVDY3Qf3hNgIiUUgVnMtoX6rGnQo

To claim this, I am signing this object:

@TizianoCoroneo
TizianoCoroneo / TypeLevelFizzBuzz.swift
Last active May 29, 2024 10:22
Type level FizzBuzz in Swift 5.10
func namespace(_ f: () -> ()) -> () { f() }
// A fizz buzz implementation in Swift
namespace {
let range = 1...100
let result = range.map { (n: Int) -> String in
switch (n % 3, n % 5) {
case (0, 0): "Fizz Buzz"
case (0, _): "Fizz"
@TizianoCoroneo
TizianoCoroneo / EvenOrOdd.swift
Last active June 7, 2019 19:32
Even or Odd property delegate playground in Swift 5.1
import Foundation
/*:
The goal is to have some kind of "even box" type that can contain only even numbers, and a "odd box" that can contain only odd numbers.
With that setup, it is possible to define some operations between "boxes" to check at compile time if the result of an expression will be even or odd.
*/
/**
A protocol in common for `Even<T>` and `Odd<T>`.
@TizianoCoroneo
TizianoCoroneo / Type level Even or Odd.swift
Last active April 10, 2019 09:09
Type level Even or Odd in Swift 4.2
import Foundation
/*:
Run this in a Swift playground!
The goal is to have some kind of "even box" type that can contain only even numbers, and a "odd box" that can contain only odd numbers.
With that setup, it is possible to define some operations between "boxes" to check at compile time if the result of an expression will be even or odd.
*/
/**
@TizianoCoroneo
TizianoCoroneo / ListComprehension.swift
Last active December 28, 2017 21:46
Haskell style List Comprehensions in Swift 4
import Foundation
typealias Format<A, B> = Component<A, B>
typealias Source<A> = Component<A, A>
typealias Filter<A> = Component<A, A>
enum Component<A, B> {
case format((A) -> B)
case sources([A])
case filter((A) -> Bool)