Skip to content

Instantly share code, notes, and snippets.

View VAndrJ's full-sized avatar

VAndrJ VAndrJ

  • Ukraine
View GitHub Profile
@VAndrJ
VAndrJ / swift_compilation_performance.py
Created March 11, 2024 13:09
Swift compilation time benchmark
#!/usr/bin/env python3
import os
filenames = ["a", "b"]
codeMixed = [
'someFunc(data: SomeClass(data: SomeStruct(data: SomeStruct.Nested1.Nested2(point: CGPoint(x: {}, y: {})))))',
'someFunc(data: .init(data: .init(data: .init(point: .init(x: {}, y: {})))))'
]
for (i, filename) in enumerate(filenames):
@VAndrJ
VAndrJ / ContentView.swift
Created February 24, 2024 09:16
SwiftUI zIndex MRE
//
// ContentView.swift
// PosIndexMRE
//
// Created by VAndrJ on 24.02.2024.
//
import SwiftUI
struct ContentView: View {
@VAndrJ
VAndrJ / OnAppearCheck.swift
Created January 6, 2024 22:01
SwiftUI onAppear bug
//
// ContentView.swift
// OnAppearCheck
//
// Created by VAndrJ on 21.12.2023.
//
import SwiftUI
struct ContentView: View {
@VAndrJ
VAndrJ / swift_build_performance.py
Last active December 18, 2023 21:37
Swift built performance benchmark. Results using Xcode 14.3.1.
#!/usr/bin/env python3
import os
filenames = ["a", "b"]
code = [
'someFunc(SomeStruct(str: "Foo"))',
'someFunc(.init(str: "Foo"))'
]
for (i, filename) in enumerate(filenames):
@VAndrJ
VAndrJ / ASLayoutElement+Swift.swift
Last active August 1, 2023 07:58
Texture Layout Spec in Swift
public final class Row: ASStackLayoutSpec {
public convenience init(
spacing: CGFloat = 0,
main: ASStackLayoutJustifyContent = .start,
cross: ASStackLayoutAlignItems = .start,
wrap: ASStackLayoutFlexWrap = .noWrap,
alignContent: ASStackLayoutAlignContent = .start,
line: CGFloat = 0,
@LayoutSpecBuilder content: () -> [ASLayoutElement]
@VAndrJ
VAndrJ / gist:d1b96cfef253aa66b6b9ab151a659b00
Created April 2, 2023 09:44 — forked from CrookedNumber/gist:8964442
git: Removing the last commit

Removing the last commit

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

If you want to "uncommit" the commits, but keep the changes around for reworking, remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index, but leave the working tree around.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

@VAndrJ
VAndrJ / StateModel.swift
Created April 17, 2022 14:51
State managing.
//
// StateModel.swift
//
// Created by Volodymyr Andriienko on 11.04.2022.
//
import Foundation
import RxSwift
import RxCocoa
@VAndrJ
VAndrJ / FunctionComposition.swift
Created January 12, 2022 09:40
Function composition custom operators
infix operator |>: ForwardApplication
infix operator >>>: ForwardComposition
infix operator ~>: ForwardComposition
infix operator >=>: ForwardComposition
/// Function application
public func |> <A, R>(a: A, f: (A) -> R) -> R {
@VAndrJ
VAndrJ / PartialApplication.swift
Created January 12, 2022 07:53
Partial function application
/// Partial application of a function with 2 arguments
/// - Returns: Partially applied function (A) -> R
public func partial<A, B, R>(_ f: @escaping (A, B) -> R, _ a: Deferred, _ b: B) -> (A) -> R {
{ a in f(a, b) }
}
/// Partial application of a function with 2 arguments
/// - Returns: Partially applied function (B) -> R
public func partial<A, B, R>(_ f: @escaping (A, B) -> R, _ a: A, _ b: Deferred) -> (B) -> R {
{ b in f(a, b) }
@VAndrJ
VAndrJ / Currying.swift
Created January 12, 2022 07:46
Function currying
/// Currying for function with 2 arguments.
/// - Returns: A curried function (A) -> (B) -> R
public func curry<A, B, R>(_ f: @escaping (A, B) -> R) -> (A) -> (B) -> R {
{ a in { b in f(a, b) } }
}
/// Currying for function with 3 arguments.
/// - Returns: A curried function (A) -> (B) -> (C) -> R
public func curry<A, B, C, R>(_ f: @escaping (A, B, C) -> R) -> (A) -> (B) -> (C) -> R {
{ a in { b in { c in f(a, b, c) } } }