Skip to content

Instantly share code, notes, and snippets.

View pxpgraphics's full-sized avatar

Paris Xavier Pinkney pxpgraphics

View GitHub Profile
@mayoff
mayoff / SteppingSubscriber.swift
Created December 18, 2019 06:50
Custom Combine operator for stepping a publisher's signals through function
// See https://stackoverflow.com/q/59367202/77567
import Combine
import Foundation
extension Publisher {
func step(with stepper: @escaping (SteppingSubscriber<Output, Failure>.Event) -> ()) -> AnyCancellable {
let subscriber = SteppingSubscriber<Output, Failure>(stepper: stepper)
self.subscribe(subscriber)
return .init(subscriber)
@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

@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 16, 2024 05:10
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@modocache
modocache / swiftc -Xfrontend -debug-time-compilation
Last active April 12, 2022 22:34
Swift compilation time debugging options and their outputs
===-------------------------------------------------------------------------===
Swift compilation
===-------------------------------------------------------------------------===
Total Execution Time: 0.0307 seconds (0.1196 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
0.0043 ( 39.3%) 0.0091 ( 45.6%) 0.0133 ( 43.4%) 0.0547 ( 45.7%) performSema
0.0030 ( 27.5%) 0.0070 ( 35.2%) 0.0100 ( 32.5%) 0.0437 ( 36.5%) performSema-loadStdlib
0.0011 ( 10.0%) 0.0011 ( 5.4%) 0.0022 ( 7.0%) 0.0081 ( 6.7%) performSema-parseAndCheckTypes
0.0008 ( 7.0%) 0.0009 ( 4.4%) 0.0016 ( 5.3%) 0.0067 ( 5.6%) Type checking / Semantic analysis
@lattner
lattner / TaskConcurrencyManifesto.md
Last active November 15, 2024 05:45
Swift Concurrency Manifesto
@ddunbar
ddunbar / xcbuild-debugging-tricks.md
Last active September 16, 2024 08:54
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@EQuimper
EQuimper / git-aliases.md
Created June 1, 2017 01:40 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@NSExceptional
NSExceptional / XcodeBuildSettingsReference.md
Last active November 14, 2024 02:25
The Xcode Build Settings Reference in a searchable document, as of Xcode 8.3.2

Build settings reference

Active Build Action (ACTION)

A string identifying the build system action being performed.

Additional SDKs (ADDITIONAL_SDKS)

The locations of any sparse SDKs that should be layered on top of the one specified by Base SDK (SDKROOT). If more than one SDK is listed, the first one has highest precedence. Every SDK specified in this setting should be a "sparse" SDK, for example, not an SDK for an entire macOS release.

Alternate Install Group (ALTERNATE_GROUP)

@kharrison
kharrison / SwiftIntegerGuide.swift
Created February 17, 2017 16:43
Swift Integer Quick Guide
// -------------------------------------
// Swift Integer Quick Guide
// -------------------------------------
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
@tomduckering
tomduckering / ValueTransformer.swift
Last active October 25, 2018 23:49 — forked from gonzalezreal/ValueTransformer.swift
Type safe NSValueTransformer
import Foundation
private class BasicValueTransformer: ValueTransformer {
let transform: (AnyObject?) -> (AnyObject?)
init(transform: @escaping (AnyObject?) -> (AnyObject?)) {
self.transform = transform
}
// MARK: NSValueTransformer