Skip to content

Instantly share code, notes, and snippets.

View VAndrJ's full-sized avatar

VAndrJ VAndrJ

  • Ukraine
View GitHub Profile
@VAndrJ
VAndrJ / SpreadsheetView.swift
Created August 16, 2024 13:34 — forked from natpenguin/SpreadsheetView.swift
A view like spreadsheet in SwiftUI
import SwiftUI
struct SpreadsheetView<ColumnView: View, RowView: View, ContentView: View, Column: Hashable, Row: Hashable>: View {
init(
columns: [Column],
rows: [Row],
columnWidth: CGFloat,
columnHeight: CGFloat,
rowWidth: CGFloat,
rowHeight: CGFloat,
@VAndrJ
VAndrJ / AlertModifierWithoutProblem.swift
Last active August 17, 2024 07:35
Alert close problem MRE.
import SwiftUI
@main
struct ExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
@VAndrJ
VAndrJ / TestObservableBindableApp.swift
Created August 9, 2024 09:53
ObservableObject vs Observable vs State MRE
import SwiftUI
import Observation
@main
struct TestObservableBindableApp: App {
@State var observableObjectModel = ObservableObjectModel()
@State var observableModel = ObservableModel()
var body: some Scene {
WindowGroup {
@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