Skip to content

Instantly share code, notes, and snippets.

View paweldudek's full-sized avatar
Drinking coffee. Lots of it.

Pawel Dudek paweldudek

Drinking coffee. Lots of it.
View GitHub Profile
#!/usr/bin/env ruby
$actions = [
'Time to stand up.',
'Grab the ball.',
'Sit down.'
]
def take_action
current_action = $actions.shift
@orkoden
orkoden / tddberlin_iOS_notes.md
Last active May 18, 2021 08:43
Notes from TDD iOS Notes

TDD Workshop Notes

http://tdd-workshop.uikonf.com

Twitter hashtag #tddberlin

Mobile Central Europe Conference in Warsaw in Feb 2015

Resources

Reading

/*
Erica Sadun, http://ericasadun.com
Cross Platform Defines
Apple Platforms Only
Will update to #if canImport() when available
*/
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active July 12, 2024 03:33
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

import SwiftUI
// Note: There are some issues with using these modifiers inside of ButtonStyles on macOS. Please see https://twitter.com/noahsark769/status/1288256379640139776?s=20 for more info.
struct ConditionalContent<TrueContent: View, FalseContent: View>: View {
let value: Bool
let trueContent: () -> TrueContent
let falseContent: () -> FalseContent
@ViewBuilder var body: some View {