Skip to content

Instantly share code, notes, and snippets.

View itchix's full-sized avatar

Scot Scriven itchix

  • Trainsweateat
  • Angers France
View GitHub Profile
@ghislainfrs
ghislainfrs / EAN13CheckDigitHelper.swift
Last active April 1, 2020 15:28
Generate EAN13 check digit in Swift
//
// EAN13CheckDigitHelper.swift
//
import Foundation
public struct EAN13CheckDigitHelper {
public enum EAN13Error: Error {
case mustOnlyContainDigits
case mustBe12DigitsLong
@Amzd
Amzd / UIKitTabView.swift
Last active January 2, 2025 02:53
UIKitTabView. SwiftUI tab bar view that respects navigation stacks when tabs are switched (unlike the TabView implementation)
/// An iOS style TabView that doesn't reset it's childrens navigation stacks when tabs are switched.
public struct UIKitTabView: View {
private var viewControllers: [UIHostingController<AnyView>]
private var selectedIndex: Binding<Int>?
@State private var fallbackSelectedIndex: Int = 0
public init(selectedIndex: Binding<Int>? = nil, @TabBuilder _ views: () -> [Tab]) {
self.viewControllers = views().map {
let host = UIHostingController(rootView: $0.view)
host.tabBarItem = $0.barItem
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
let index = CGFloat(integerLiteral: tabBar.items!.index(of: item)!)
let itemWidth = indicatorImage?.frame.width
let newCenterX = (itemWidth! / 2) + (itemWidth! * index)
UIView.animate(withDuration: 0.3) {
self.indicatorImage?.center.x = newCenterX
}
}
//
// RealmSwift+Codable.swift
//
// Created by Michael Gray on 8/16/17.
//
import Foundation
import RealmSwift
// swiftlint:disable line_length identifier_name
image: gitlab/dind
stages:
- build
- deploy
build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
@smswz
smswz / GridLayout.swift
Last active July 3, 2023 15:51
A simple custom grid UICollectionViewLayout
// MIT License
//
// Copyright (c) 2016 stable|kernel
//
// 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:
@yannhowe
yannhowe / .gitlab.ci.yml
Created September 26, 2016 18:06
.gitlab.ci.yml for SSH with private key.
# Image neeeds to have ssh-client
image: docker:git
services:
- docker:dind
stages:
- staging
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
@ibeex
ibeex / foo.log
Created August 4, 2012 13:46
Flask logging example
A warning occurred (42 apples)
An error occurred