Skip to content

Instantly share code, notes, and snippets.

@projectfebr
projectfebr / Mobius 2019
Created January 3, 2024 10:17 — forked from katleta3000/Mobius 2019
Список материалу к докладу "Работаем с сетью эффективно" Ртищев Евгения для Mobius 2019 22-23 мая
1. Очень крутая книжка по сетям (стек OSI) – Charles Severance “Introduction to Network: How the Internet works”
2. URLCache – https://nshipster.com/nsurlcache/
3. Ресёрч HTTP-кеширования с использованием URLCache https://qnoid.com/2016/04/10/A-primer-in-HTTP-caching-and-its-native-support-by-iOS.html
4. Анализ доступности сети:
* SimplePing – https://developer.apple.com/library/archive/samplecode/SimplePing/Introduction/Intro.html
* https://github.com/dustturtle/RealReachability
* https://github.com/ankitthakur/SwiftPing
* https://github.com/lmirosevic/GBPing
* https://github.com/rwbutler/Connectivity
* Баг с 2009 года – https://lists.apple.com/archives/macnetworkprog/2009/May/msg00056.html
@projectfebr
projectfebr / Обертки.txt
Last active November 21, 2023 12:03
Обертки
1) Потокобезопасное свойство @SynchronizedLock
https://habr.com/ru/articles/774890/
2) Упрощаем работу с UserDefaults. Обертки
https://habr.com/ru/articles/774888/
3) Работа с Динамическими Цветами
https://habr.com/ru/articles/774884/
import UIKit
import UserNotifications
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
private let pushAppLaunchRule = PushAppLaunchRule()
var window: UIWindow?
func sceneDidBecomeActive(_ scene: UIScene) {
import Foundation
/// Про многопоточность 2. GCD
/// https://habr.com/ru/post/578752/
/// Работа с DispatchGroup в Swift
/// https://supereasydev.medium.com/работа-с-dispatchgroup-в-swift-a2969aeca7c
let dispatchGroup = DispatchGroup()
let queue1 = DispatchQueue(label: "queue1", qos: .background , attributes: [.initiallyInactive, .concurrent])
let queue2 = DispatchQueue(label: "queue2", qos: .utility, attributes: [.initiallyInactive, .concurrent])
// Разное интересное по многопоточности:
// Featured-секция, для любителей архивной документации от Apple:
1. https://developer.apple.com/library/archive/technotes/tn/tn2028.html#//apple_ref/doc/uid/DTS10003065 - про внутренности потоков в MAC OS X в сравнении с MAC OS 9
2. https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/About/About.html - Kernel Programming guide, вы же понимаете, что там будет, да :D
// Для любителей WWDC:
1. https://developer.apple.com/videos/play/wwdc2015/718/ - GCD раз.
protocol ViewCode {
func buildLayout()
func buildViewHierarchy()
func buildConstraints()
func configureView()
}
extension ViewCode {
func buildLayout() {
buildViewHierarchy()
@projectfebr
projectfebr / TouchesPassView.swift
Created June 30, 2022 08:41
стандартной реализации класса UIView не предусмотрена возможность создания контейнера, пропускающего нажатия сквозь себя, но позволяющего обрабатывать тачи его сабвьюхами.
class TouchesPassView: UIView {
override func hitTest(_ point: CGPoint,
with event: UIEvent?) -> UIView?
{
let view = super.hitTest(point, with: event)
if view === self {
return nil
}
return view
@projectfebr
projectfebr / ButtonWithTouchSize.swift
Created June 30, 2022 08:40
Расширение области для тапа
class ButtonWithTouchSize: UIButton {
var touchAreaPadding: UIEdgeInsets?
override func point(inside point: CGPoint,
with event: UIEvent?) -> Bool
{
guard let insets = touchAreaPadding else {
return super.point(inside: point, with: event)
}
let rect = UIEdgeInsetsInsetRect(bounds, insets.inverted())
return rect.contains(point)
@projectfebr
projectfebr / point_inside.swift
Created June 30, 2022 08:38
point(inside:) для subview за пределами bounds родительской view
override func point(inside point: CGPoint,
with event: UIEvent?) -> Bool
{
let inside = super.point(inside: point, with: event)
if !inside {
for subview in subviews {
let pointInSubview = subview.convert(point, from: self)
if subview.point(inside: pointInSubview, with: event) {
return true
}
@projectfebr
projectfebr / bad_blocs.md
Created September 22, 2021 08:34 — forked from PlugFox/bad_blocs.md
БИНГО ошибок при создании BLoC'а

БИНГО ошибок при создании BLoC'а

ОШИБКИ:

  1. Начать писать логику непосредственно в mapEventToState,
    он у вас быстренько превратится в нечитаемую портянку и придете жаловаться на бойлерплейт.
    Если правильно готовить блок, то бойлерплейтом там и не пахнет,
    эвенты + стейты + блок умещаются все вместе на 1-2 экранах.
    Все запредельно воздушно, даже не надо создавать отдельные файлы под эвенты и стейты.
    Все ультра емко получается.