Skip to content

Instantly share code, notes, and snippets.

Exey Panteleev Exey

Block or report user

Report or block Exey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AnyTransition.swift
import SwiftUI
extension AnyTransition {
static var moveUpAndFade: AnyTransition {
let insertion = AnyTransition.move(edge: .top).combined(with: .opacity)
let removal = AnyTransition.move(edge: .top).combined(with: .opacity)
return .asymmetric(insertion: insertion, removal: removal)
}
View MatrixUtilities.swift
import simd
extension float4x4 {
init(scaleBy s: Float) {
self.init(SIMD4<Float>(s, 0, 0, 0),
SIMD4<Float>(0, s, 0, 0),
SIMD4<Float>(0, 0, s, 0),
SIMD4<Float>(0, 0, 0, 1))
}
View TextureShader.metal
#include <metal_stdlib>
using namespace metal;
struct VertexIn {
float3 position [[attribute(0)]];
float2 texCoords [[attribute(1)]];
};
struct VertexOut {
float4 position [[position]];
View MaterialShader.metal
#include <metal_stdlib>
using namespace metal;
struct VertexIn {
float3 position [[attribute(0)]];
float3 normal [[attribute(1)]];
};
struct VertexOut {
float4 position [[position]];
View UITabBarSwiftUIHiding.swift
extension UITabBar {
/// // TabBar Hide Mechanism
/// @Published var hideTabBar = false
/// var tabBarSubscriberCancellable: AnyCancellable?
open override func setNeedsDisplay() {
super.setNeedsDisplay()
// tricky subscribe
let coreApp: CoreAppService = ServiceLocator.shared.inject()
if coreApp.tabBarSubscriberCancellable == nil {
View LazyView.swift
import SwiftUI
private struct LazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
View DateExt.Swift
//
// Date.swift
// Tripster
//
// Created by Exey Panteleev on 29.08.2019.
// Copyright © 2019 Exey Panteleev. All rights reserved.
//
import Foundation
View UUID4.swift
//
// UUID4.swift
//
// Created by exey on 17.03.2020.
// Copyright © 2020 Exey Panteleev. All rights reserved.
//
extension UInt8 {
func hexString(padded:Bool = true) -> String {
let dict:[Character] = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]
@Exey
Exey / MostFrequentNumber.swift
Created Feb 7, 2020
Most Frequent Number Task
View MostFrequentNumber.swift
// Utils for bit operations
enum Bit {
case zero, one
func asInt() -> Int { self == .one ? 1 : 0}
}
// to bytes(UInt8)
func bitsToBytes(bits: [Bit]) -> [UInt8] {
let numBits = bits.count
let numBytes = (numBits + 7)/8
var bytes = [UInt8](repeating: 0, count: numBytes)
@Exey
Exey / DebouncerPlayground.swift
Last active Nov 27, 2019
Debouncer with Argument
View DebouncerPlayground.swift
import Foundation
// Debouncer
func debounce(delay: TimeInterval, action: @escaping (String)->Void) -> (String)->Void {
let callback = DebounceCallback(action)
var timer: Timer?
return { arg in
if let timer = timer { timer.invalidate() } // invalidate the last timer
timer = Timer(timeInterval: delay,
target: callback,
You can’t perform that action at this time.