Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
@hum-n
hum-n / Civic.terminal
Last active June 4, 2022 10:59
macOS Terminal theme based on Civic Xcode 8 theme (WWDC 2016 colors)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjE0NTA5ODAzOTIgMC4xNDkwMTk2MDc4IDAuMTg4MjM1Mjk0MQAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@steventroughtonsmith
steventroughtonsmith / gist:6788b6c340a0aa52345a
Created October 27, 2015 05:19
Run OS X Screen Saver as Wallpaper
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background
public enum TruncateMode {
case Head, Middle, Tail
}
public extension String {
/// Truncates a string to a maximum length in grapheme clusters using the
/// specified mode. If `addEllipsis` is `true`, the resulting string
/// including the ellipsis will be no longer than `maxLength`.
func truncateToLength(maxLength: Int, mode: TruncateMode = .Tail, addEllipsis: Bool = false) -> String {
if maxLength <= 0 {
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@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:
@steipete
steipete / Defaults.xcconfig
Last active February 1, 2020 15:06
The prelude to the warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// Defaults.xcconfig
//
// Common customizations/sanitizations of the platform defaults for our projects.
//
// For compatibility reasons, the iOS platform has a couple of not–so–sensible defaults.
// This file collects, and annotates the deviations from these defaults.
//
// :NOTE: Some of the settings herein may be redundant for newly created projects/targets:
// Xcode’s project/target templates take several (but not all!) of these issues into account.
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";