Skip to content

Instantly share code, notes, and snippets.

View kos9kus's full-sized avatar
😶‍🌫️
Always coding

Kos kos9kus

😶‍🌫️
Always coding
View GitHub Profile
@corrieriluca
corrieriluca / App-Store-Connect-API-Python.md
Last active October 15, 2024 04:36
Connection to the App Store Connect API using Python3
@nicklockwood
nicklockwood / Withable.swift
Created January 28, 2019 12:06
Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active November 15, 2024 01:56
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

@fxm90
fxm90 / WebViewExampleViewController.swift
Last active October 24, 2024 17:52
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit
@ahbou
ahbou / ComposeView.swift
Last active July 12, 2019 03:30
iPhone X InputAccessoryView Fix
//
// ComposeView.swift
import UIKit
class ComposeView: UIView {
// ........
// Other layout code and methods
// ........
// Similar to defer in Swift
#define pspdf_defer_block_name_with_prefix(prefix, suffix) prefix ## suffix
#define pspdf_defer_block_name(suffix) pspdf_defer_block_name_with_prefix(pspdf_defer_, suffix)
#define pspdf_defer __strong void(^pspdf_defer_block_name(__LINE__))(void) __attribute__((cleanup(pspdf_defer_cleanup_block), unused)) = ^
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
static void pspdf_defer_cleanup_block(__strong void(^*block)(void)) {
(*block)();
}
#pragma clang diagnostic pop
@untalfranfernandez
untalfranfernandez / Equatable.swift
Last active July 26, 2020 18:22
Swift: Subclases and Equatable protocol
class Superclass : Equatable {
let foo: Int
init(foo: Int) { self.foo = foo }
func equal(to: Superclass) -> Bool {
return foo == to.foo
}
}
@bsmith11
bsmith11 / BackAnimationController.swift
Created October 11, 2016 00:02
Rough implementation of `UINavigationController`s default pop animation
import UIKit
class BackAnimationController: NSObject {
private let duration = 0.35
private let fromContainerView = UIView(frame: .zero)
private let toContainerView = UIView(frame: .zero)
private let dimmingView = DimmingView(frame: .zero)
private let shadowImageView = UIImageView(frame: .zero)
}
@steipete
steipete / SpinlockTestTests.swift
Last active August 29, 2023 08:47 — forked from RomanTruba/Synchronization_test_iOS_SDK10
Updated for Xcode 8, Swift 3; added os_unfair_lock
//
// SpinlockTestTests.swift
// SpinlockTestTests
//
// Created by Peter Steinberger on 04/10/2016.
// Copyright © 2016 PSPDFKit GmbH. All rights reserved.
//
import XCTest
@AKiniyalocts
AKiniyalocts / Scrolling.m
Created September 26, 2016 14:47
Scrolling a tableview along with a cursor inside of a UITextView
-(void)textViewDidChangeSelection:(UITextView *)textView {
CGPoint cursorPosition = [textView caretRectForPosition:textView.selectedTextRange.start].origin;
[self.tableView scrollRectToVisible:CGRectMake(cursorPosition.x, cursorPosition.y
, textView.frame.size.width, textView.frame.size.height) animated:YES];
}