Skip to content

Instantly share code, notes, and snippets.

View eldaroid's full-sized avatar
🎯
Focusing

Попов Эльдар eldaroid

🎯
Focusing
View GitHub Profile
@eldaroid
eldaroid / LifeCycleSceneDelegate.swift
Last active October 7, 2024 19:03
RU: Исследуем жизненный цикл iOS Scene (методы SceneDelegate). EN: Exploring the iOS Scene lifecycle (SceneDelegate methods)
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
// Настройка окна приложения
window = UIWindow(windowScene: windowScene)
let initialViewController = ViewController()
window?.rootViewController = initialViewController
@eldaroid
eldaroid / LifeCycleAppDelegate.swift
Last active October 7, 2024 19:03
RU: Исследуем жизненный цикл iOS приложения (методы AppDelegate). EN: Exploring the iOS app lifecycle (AppDelegate methods)
import UIKit
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
// 1 начальная настройка перед завершением запуска
func application(
_ application: UIApplication,
willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
@eldaroid
eldaroid / PingIPsRange.sh
Last active October 7, 2024 19:04
RU: Скрипт проверяет доступность IP-адресов в указанном диапазоне. Он пингует каждый IP-адрес в сети 192.168.0.x и выводит сообщение, если адрес доступен. EN: The script checks the availability of IP addresses in the specified range. It pings each IP address in the 192.168.0.x network and displays a message if the address is available
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <number_of_ips>"
exit 1
fi
if ! [[ $1 =~ ^[0-9]+$ ]] || [ $1 -lt 0 ] || [ $1 -gt 255 ]; then
echo "Error: The argument must be a number in the range from 0 to 255."
exit 1
@eldaroid
eldaroid / Collection+Utils.swift
Last active October 7, 2024 19:04
RU: Удобный и настраиваемый способ навигации между разделами (вкладками) информации с помощью эффекта matchedGeometryEffect. EN: Convenient and customizable way to navigate between sections (tabs) of information with matchedGeometryEffect
public extension Collection {
subscript(safe index: Index) -> Element? {
indices.contains(index) ? self[index] : nil
}
}
@eldaroid
eldaroid / TagsModel.swift
Last active October 13, 2024 04:03
RU: Реализация макета Selectable Aligned Tags с поддержкой переносов строк и выравнивания. EN: Implementation Selectable Aligned Tags layout that supports line breaks and alignment
public struct TagsModel: Identifiable, Hashable, Equatable {
public let id: String
public var title: String
public var tooltip: String?
public var isSelected: Bool
public init(
id: String = UUID().uuidString,
title: String,
isSelected: Bool = false,