Skip to content

Instantly share code, notes, and snippets.

@catlan
catlan / README.md
Last active May 10, 2024 15:04 — forked from zrxq/.lldbinit
Execute lldb command and open its output in Kaleidoscope diff

Diff output of two lldb commands

Setup

  1. Copy the contents of the last snippet (lldbinit) from the gist page, and paste into your .lldbinit file. This makes the ksdiff macro known inside lldb.
  2. Put file ksdiff.py in ~/.lldb/
  3. sudo pip install temp
  4. Restart Xcode debug session

Example

(lldb) ksdiff ;

public struct Error: ErrorType {
let source: String; let reason: String
public init(_ source: String = __FILE__, _ reason: String) {
self.reason = reason; self.source = source
}
}
protocol Contextualizable {}
extension Contextualizable {
func functionContext(function : String = __FUNCTION__) -> String {
@steipete
steipete / NSData+PSPDFFoundation.m
Last active March 21, 2017 16:00
Haven't done much with dispatch_io yet so I'd appreciate a few more eyeballs on this. Am I closing things correctly in all error conditions? Are there other knobs I could change to make things even faster? (I know I've been lazy on the NSError's)
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) {
NSCParameterAssert(fileURL);
dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL);
__block dispatch_io_t readChannel;
void (^processIntError)(int intError) = ^(int intError) {
if (intError != 0) {
PSPDFLogWarning(@"Stream error: %d", intError);
if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}];
@nevan
nevan / gist:3e1174f27e753db4731e
Last active January 9, 2022 19:04
WWDC 2015 Session Videos
https://developer.apple.com/videos/wwdc/2015/?id=101 101 Keynote
https://developer.apple.com/videos/wwdc/2015/?id=102 102 Platforms State of the Union
https://developer.apple.com/videos/wwdc/2015/?id=103 103 Apple Design Awards
https://developer.apple.com/videos/wwdc/2015/?id=104 104 What's New in Xcode
https://developer.apple.com/videos/wwdc/2015/?id=105 105 Introducing WatchKit for watchOS 2
https://developer.apple.com/videos/wwdc/2015/?id=106 106 What's New in Swift
https://developer.apple.com/videos/wwdc/2015/?id=107 107 What's New in Cocoa Touch
https://developer.apple.com/videos/wwdc/2015/?id=108 108 Building Watch Apps
https://developer.apple.com/videos/wwdc/2015/?id=112 112 Think Audacious
https://developer.apple.com/videos/wwdc/2015/?id=201 201 iOS Accessibility
@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@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
@andymatuschak
andymatuschak / CollectionViewDataSource.swift
Last active February 12, 2021 09:44
Type-safe value-oriented collection view data source
//
// CollectionViewDataSource.swift
// Khan Academy
//
// Created by Andy Matuschak on 10/14/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
@indragiek
indragiek / RandomNumbers.swift
Last active November 26, 2015 16:26
Random number generator in Swift
public struct RandomNumberGenerator: SequenceType {
let range: Range<Int>
let count: Int
public init(range: Range<Int>, count: Int) {
self.range = range
self.count = count
}
public func generate() -> GeneratorOf<Int> {
@tonyarnold
tonyarnold / download-wwdc-vids.sh
Last active August 29, 2015 14:02
Downloads all of the available WWDC2014 videos (assuming you have access to them), skipping any that are already downloaded and resuming any that aren't. Requires wget, which can be installed via homebrew. Original credit goes to Krzysztof: https://twitter.com/merowing_/status/474071685826883584. You'll need to be running wget 1.15 or later for …
echo "Downloading HD Videos…"
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g' | xargs -n1 wget -N -c
echo "Downloading SD Videos…"
curl https://developer.apple.com/videos/wwdc/2014/ | grep -iIoh 'http.*._sd_.*dl=1">SD' | sed -e 's/\?dl=1">SD//g' | xargs -n1 wget -N -c
echo "Downloading PDFs…"
@calebd
calebd / ArrayHelpers.swift
Last active November 4, 2022 15:17
Swift Helpers
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {