This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func observeNotifications(name: NSNotification.Name) -> AnyPublisher<Notification, Never> { | |
return Publishers.Deferred<AnyPublisher<Notification, Never>> { | |
var observer: NSObjectProtocol? | |
return AnyPublisher { subscriber in | |
observer = NotificationCenter.default.addObserver(forName: name, object: nil, queue: nil) { notification in | |
_ = subscriber.receive(notification) | |
} | |
} | |
.handleEvents(receiveCancel: { | |
if let observer = observer { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calling functions | |
expression CATransaction.flush() | |
call CATransaction.flush() | |
# Assigning variables | |
expression didLoad = true | |
command alias assign expression -- | |
assign didLoad = true | |
# Symbolic breakpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Python commands before | |
## | |
def my_command(debugger, input, ctx, result, _): | |
# do stuff | |
pass | |
def __lldb_init_module(debugger, _): | |
debugger.HandleCommand( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swift_demangle(Symbol, Name) :- | |
Command = ['swift-demangle', '-compact', Symbol], | |
setup_call_cleanup( | |
process_create(path(xcrun), Command, [stdout(pipe(Out))]), | |
read_string(Out, "\n", "", _, Name), | |
close(Out) | |
). | |
usr_symbol(USR, Symbol) :- | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import __builtin__ | |
from itertools import islice | |
# See https://sourceware.org/gdb/current/onlinedocs/gdb/Convenience-Funs.html | |
# breakpoint command add -F '_caller_is("theCaller")' | |
# breakpoint command add -F 'not _caller_is("theCaller")' | |
def _caller_is(name): | |
def check(frame, loc, _): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is an example provided by Facebook are for non-commercial testing and | |
* evaluation purposes only. | |
* | |
* Facebook reserves all rights not expressly granted. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL | |
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Examples: | |
# hdrtomod objc/runtime.h | |
# hdrtomod mach-o/dyld.h | |
# hdrtomod Foundation/Foundation.h | |
hdrtomod() { | |
readonly header=$1 | |
echo "#import <$header>" \ | |
| clang -fmodules -fsyntax-only -x objective-c -Xclang -ast-dump - \ | |
| grep ImportDecl \ | |
| egrep -o 'implicit \S+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b hitTest:withEvent: | |
break command add -s python -o 'print frame.EvaluateExpression("$arg1").description; return False' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <libkern/OSAtomic.h> | |
@interface NSArray (ConcurrentMap) | |
- (NSArray*)semaphore_map:(id (^)(id))block; | |
- (NSArray*)serial_map:(id (^)(id))block; | |
- (NSArray*)spinlock_map:(id (^)(id))block; | |
@end | |
@implementation NSArray (ConcurrentMap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void (^myBlock)(int); | |
__block __weak __typeof__(myBlock) myRecursiveBlock = myBlock = ^(int x) { | |
if (x > 5) { | |
return; | |
} else { | |
myRecursiveBlock(x + 1); | |
} | |
}; | |
myBlock(1); |