Skip to content

Instantly share code, notes, and snippets.

View dev4dev's full-sized avatar
💭
Beep Boop Beep

Alex Antonyuk dev4dev

💭
Beep Boop Beep
View GitHub Profile
@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
@dsabanin
dsabanin / enable-xcode-debug-menu.sh
Last active November 7, 2022 16:17
Enable internal Xcode debug menu in Xcode 11
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode
sudo touch /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode/AppleInternal.plist
# Don't forget to restart Xcode
@stephanecopin
stephanecopin / Publishers+CombineLatestMany.swift
Created February 13, 2020 00:58
An implemention of `CombineLatestMany` for Combine (Swift), which takes takes an array of `Publisher` and return a collection of values, based on their latest value.
import Combine
private protocol LockImplementation {
mutating func lock()
mutating func `try`() -> Bool
mutating func unlock()
}
private struct UnfairLock: LockImplementation {
private var unfairLock = os_unfair_lock_s()
@zntfdr
zntfdr / firebase-iOS-breakdown.swift
Last active March 27, 2024 15:06
Firebase iOS Version breakdown
// How to:
// 1. Open the Firebase Analytics Dashboard
// 2. Scroll to bottom, where you see the "Users by Device model" widget
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
// 5. Make sure to select “OS with version” and not “OS Version”
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
// 7. Click “Download file” on the new side bar, then “Download CSV"
// 8. Open the file and select the iOS/Android breakdown raw data
// 9. Replace the sample data in this script with your data
@fnky
fnky / ANSI.md
Last active April 18, 2024 15:47
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@JofArnold
JofArnold / Login.m
Last active October 26, 2022 13:31
Using promises in React Native modules with Swift
// Created by react-native-create-bridge
// import RCTBridgeModule
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#elif __has_include(“RCTBridgeModule.h”)
#import “RCTBridgeModule.h”
#else
#import “React/RCTBridgeModule.h” // Required when used as a Pod in a Swift project
#endif
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 16, 2024 01:02
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@lattner
lattner / TaskConcurrencyManifesto.md
Last active April 18, 2024 09:44
Swift Concurrency Manifesto
@algal
algal / PKCS12.swift
Last active March 21, 2024 07:13
Reading PKCS12 with Swift in Foundation
// xcode 7.3
import Foundation
/**
Struct representing values returned by `SecPKCS12Import` from the Security framework.
This is what Cocoa and CocoaTouch can tell you about a PKCS12 file.
*/
@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active April 8, 2024 18:07
The best FRP iOS resources.

Videos