Skip to content

Instantly share code, notes, and snippets.

View seifscape's full-sized avatar
:octocat:

Seif Kobrosly seifscape

:octocat:
View GitHub Profile
extension StringProtocol {
subscript(_ offset: Int) -> String.Element {
if offset >= 0 {
self[index(startIndex, offsetBy: offset)]
} else {
self[index(endIndex, offsetBy: offset)]
}
}
import SwiftUI
private struct OnLoad: ViewModifier {
let action: () -> Void
@State private var loaded = false
func body(content: Content) -> some View {
content.onAppear {
if !loaded {
loaded = true
import SwiftUI
private struct OnFirstAppear: ViewModifier {
let perform: () -> Void
@State private var firstTime = true
func body(content: Content) -> some View {
content.onAppear {
if firstTime {
@seifscape
seifscape / WorkoutSplit.swift
Created November 28, 2023 00:20 — forked from shaundon/WorkoutSplit.swift
Convert an array of HKQuantitySample into splits.
import Foundation
import HealthKit
struct WorkoutSplit: Hashable {
let label: String
let distance: HKQuantity
let duration: TimeInterval
}
extension WorkoutSplit {
@seifscape
seifscape / WorkoutSplit.swift
Created November 28, 2023 00:20 — forked from shaundon/WorkoutSplit.swift
Convert an array of HKQuantitySample into splits.
import Foundation
import HealthKit
struct WorkoutSplit: Hashable {
let label: String
let distance: HKQuantity
let duration: TimeInterval
}
extension WorkoutSplit {
@seifscape
seifscape / iterm2-solarized.md
Created January 5, 2023 23:41 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@seifscape
seifscape / CurvedUIView.swift
Created May 18, 2022 16:22 — forked from anitaa1990/CurvedUIView.swift
A Swift extension of UIView to display a curved view
import UIKit
extension UIView {
/* Usage Example
* bgView.addBottomRoundedEdge(desiredCurve: 1.5)
*/
func addBottomRoundedEdge(desiredCurve: CGFloat?) {
@seifscape
seifscape / ContentSizePagingCollectionDelegate.swift
Created May 17, 2022 02:28 — forked from danielCarlosCE/ContentSizePagingCollectionDelegate.swift
Horizontal paging for collections based on the content size
//
// ContentSizePagingCollectionDelegate.swift
// CardsCarousel
//
// Created by Daniel Carlos Souza Carvalho on 2/20/21.
//
import UIKit
/// Horizontal paging for collections based on the content size
@seifscape
seifscape / BetterXcodeJumpToCounterpartSwift.org
Created December 3, 2019 19:10 — forked from danielmartin/BetterXcodeJumpToCounterpartSwift.org
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@seifscape
seifscape / BetterXcodeJumpToCounterpartSwift.org
Created December 3, 2019 19:10 — forked from danielmartin/BetterXcodeJumpToCounterpartSwift.org
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"