Skip to content

Instantly share code, notes, and snippets.

View rowwingman's full-sized avatar

Maksym Prokopchuk rowwingman

View GitHub Profile
@rowwingman
rowwingman / libdispatch-efficiency-tips.md
Created April 3, 2022 19:14 — forked from tclementdev/libdispatch-efficiency-tips.md
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

@rowwingman
rowwingman / IDType
Last active July 29, 2020 15:49
Generic IDType
import Foundation
public protocol IDType {
associatedtype Value
var value: Value { get }
}
public struct ID<Value>: IDType, Equatable, Hashable where Value: Hashable {
public let value: Value
@rowwingman
rowwingman / README.md
Created September 13, 2018 12:53 — forked from acrookston/README.md
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@rowwingman
rowwingman / generate-ssh-key.sh
Created August 28, 2018 11:52 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
//
// GradientView.swift
// Aura
//
// Created by Egor Sakhabaev on 23.07.17.
// Copyright © 2017 Egor Sakhabaev. All rights reserved.
//
import UIKit
@rowwingman
rowwingman / AsynchronousOperation.swift
Created January 9, 2018 11:14 — forked from Sorix/AsynchronousOperation.swift
Subclass of NSOperation to make it asynchronous in Swift 3
//
// AsynchronousOperation.swift
//
// Created by Vasily Ulianov on 09.02.17.
// Copyright © 2017 Vasily Ulianov. All rights reserved.
//
import Foundation
/// Subclass of `Operation` that add support of asynchronous operations.
@rowwingman
rowwingman / AsynchronousOperation.swift
Created January 9, 2018 11:13 — forked from calebd/AsynchronousOperation.swift
Concurrent NSOperation in Swift
import Foundation
/// An abstract class that makes building simple asynchronous operations easy.
/// Subclasses must implement `execute()` to perform any work and call
/// `finish()` when they are done. All `NSOperation` work will be handled
/// automatically.
open class AsynchronousOperation: Operation {
// MARK: - Properties
@rowwingman
rowwingman / .swiftlint.yml
Created December 27, 2017 16:26
SwiftLint with disabled all rules that are enabled by default
disabled_rules:
- block_based_kvo
- class_delegate_protocol
- closing_brace
- closure_parameter_position
- colon
- comma
- compiler_protocol_init
- control_statement
- cyclomatic_complexity
@rowwingman
rowwingman / Environments
Created September 17, 2017 18:36
Python
// Create environment:
python3 -m venv env
// Run environment:
. env/bin/activate
// install package:
pip install name_of_package
// example
pip install requests