Skip to content

Instantly share code, notes, and snippets.

@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
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

@jessicard
jessicard / macarons.md
Last active February 3, 2023 03:53
Macarons!

Basic macaron shell recipe

  • This will make approximately 100 shells, or about 4 dozen cookies
  • When practicing, I generally half this recipe to only make 1 sheet of cookies
  • When making macarons, you will generally flavor the filling but not the shells
  • You want to make the macarons the day before the event. You will store them in the refrigerator over night, and then take them out a few hours before to come to room temperature. This is because macarons are best when "ripened", or allowed to sit for at least one night and have the filling seep into the shells a bit. Otherwise, straight out of the oven, they can be too crunchy or hard
  • Macarons shells freeze well! Filled macarons can also freeze well depending on the filling. Buttercream fillings freeze great. Put the cookies into an airtight container before freezing
  • Everyones baking temperature and baking time vary depending on their oven - you might have to experiment a bit!
  • _I always separate egg whites myself by cracking the egg, p
import Cocoa
import MASShortcut
func pow() {
let rect = NSScreen.mainScreen()?.frame
let window = NSWindow(contentRect: rect!, styleMask: NSBorderlessWindowMask, backing: .Buffered, `defer`: false)
window.backgroundColor = NSColor.clearColor()
window.opaque = false
window.alphaValue = 1
window.makeKeyAndOrderFront(NSApplication.sharedApplication())
@steipete
steipete / gist:12c73d1b4dc1e933e15d
Last active June 26, 2019 22:48
Since some asked, these are the specs for my new hell machine. (https://twitter.com/steipete/status/697675524286627840). I got most of the parts on Amazon, keep an eye out for their warehouse deals, great savings for usually just damaged boxes.
Fractal Design Define S Black
Corsair CP-9020094-EU RMX Serie RM1000X ATX/EPS (if you don't do SLI 850W is good enough)
Asus ROG Maximus VIII Hero Gaming Mainboard
Corsair CMK32GX4M4A2400C14 Vengeance LPX 32GB
Intel Core™ i7-6700K
Noctua NH-D15S
Samsung Basic MZ-7KE1T0BW 850 Pro SSD (no space for an PCI-E version...)
Western Digital WD40EZRX Caviar Green 4TB (optional)
@daehn
daehn / Searchable.swift
Last active April 23, 2019 03:05
Swift protocols and protocol extensions to easily add and delete conforming instances to Spotlight. Blog post can be found here: http://silvandaehn.com/2015/09/25/Simplifying-CoreSpotlight/
import UIKit
import CoreSpotlight
import MobileCoreServices
public typealias Completion = NSError? -> Void
// MARK: - Searchable Protocol
public protocol Searchable {
static var spotlightDomainIdentifier: String { get }
@daehn
daehn / Levenshtein.swift
Last active August 28, 2017 02:19
Calculate the Levenshtein-Distance between two Strings in Swift
extension String {
subscript(index: Int) -> Character {
return self[startIndex.advancedBy(index)]
}
subscript(range: Range<Int>) -> String {
let start = startIndex.advancedBy(range.startIndex)
let end = startIndex.advancedBy(range.endIndex)
@steipete
steipete / UIPopoverPresentationController+PSPDFAdditions.m
Last active June 27, 2016 18:20
If you're annoyed about the incorrect arrow presentation on popovers (https://twitter.com/steipete/status/624521051855319040) use this category. Oh, and file a radar! I did.
@implementation UIPopoverPresentationController (PSPDFAdditions)
+ (void)load {
PSPDFSwizzleMethodImplementation(self, @selector(containerViewWillLayoutSubviews), ^(UIPopoverPresentationController *_self) {
// Refresh bar button view internals
[_self pspdf_updateBarButtonView];
((void( *)(id, SEL))objc_msgSend)(_self, PSPDFPrefixedSelector(containerViewWillLayoutSubviews));
});
}
@nevyn
nevyn / LICENSE.md
Last active December 23, 2017 08:43
A generic NSError presenter for iOS, like -[UIApp presentError::::]. Depends on some Lookback internals that should be easy to remove, but I need to sleep

The MIT License (MIT)

Copyright (c) 2015 Lookback

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@steipete
steipete / Warnings.xcconfig
Last active February 1, 2020 15:06
The warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// Warnings.xcconfig
//
// The list of warnings we (don’t) use, and the reasons why.
//
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
//
// :MARK: - Warnings not to be promoted:
@wessmith
wessmith / pod-install-post-checkout.sh
Last active August 29, 2015 14:01
pod install post-checkout script
#!/bin/bash
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
if [[ $BRANCH_SWITCH == "1" && $PREVIOUS_HEAD != $NEW_HEAD ]]; then
# Kill the simulator.
SIM=`pgrep 'iPhone Simulator'`