Skip to content

Instantly share code, notes, and snippets.

View florentmorin's full-sized avatar
🏠
Working from home

Florent Morin florentmorin

🏠
Working from home
View GitHub Profile
@navsing
navsing / iosSplash.swift
Created August 20, 2020 23:30
Recreate iOS style Welcome Screen to any app in 3 minutes
//
// Welcome.swift
// Playground
//
// Created by Nav Singh on 8/20/20.
//
import SwiftUI
struct Welcome: View {
@Clarko
Clarko / SearchField.swift
Last active December 9, 2021 22:34
SwiftUI search field with a keyboard focus binding
// ⚠️ As of WWDC21 you can use SwiftUI .searchable
// https://developer.apple.com/documentation/swiftui/list/searchable(text:placement:)
//
// SearchField.swift
//
// Created by Clarko on 7/17/20.
//
// SwiftUI doesn't have a SearchField yet, so here's one from UIKit.
//
// The isEditing binding lets you react to keyboard focus changes,
@AvdLee
AvdLee / DarwinNotificationCenter.swift
Last active January 23, 2024 07:55
A notification center for Darwin Notifications. MIT License applies.
//
// DarwinNotificationCenter.swift
//
// Copyright © 2017 WeTransfer. All rights reserved.
//
import Foundation
/// A Darwin notification payload. It does not contain any userInfo, a Darwin notification is purely event handling.
public struct DarwinNotification {
@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