Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
LBNotificationBanner *banner = [LBNotificationBanner new];
[overlay addSubview:banner];
banner.translatesAutoresizingMaskIntoConstraints = NO;
LBInstallConstraint(banner, Top, Equal, overlay, Top, 1, margin);
LBInstallConstraint(banner, Left, Equal, overlay, Left, 1, margin);
LBInstallConstraint(banner, Right, Equal, overlay, Right, 1, margin);
#define LBGuard(cond, ...) \
BOOL __COND_SUCCESSFUL_AT ## __LINE__ = (cond); \
if(!__COND_SUCCESSFUL_AT ## __LINE__) {\
NSString *failureReason = [NSString stringWithFormat:__VA_ARGS__]; \
NSAssert(NO, @"Guard failed: %@: %@", @#cond, failureReason); \
NSLog(@"Guard failed: %@: %@", @#cond, failureReason);\
} \
if(__COND_SUCCESSFUL_AT ## __LINE__) {}
- (void)appendEncodedSampleBuffer:(CMSampleBufferRef)encodedSampleBuffer addTrimAtStart:(int)trimDuration fromSource:(id)source
{
if(!_hasWrittenTrim) {
GFLog(GFDebug, @"Adding trim to sample buffer from %@", source);
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(CMSampleBufferGetFormatDescription(encodedSampleBuffer));
CMSetAttachment(encodedSampleBuffer, kCMSampleBufferAttachmentKey_TrimDurationAtStart, (id)CFAutorelease(
CMTimeCopyAsDictionary(
CMTimeMake(trimDuration, asbd->mSampleRate),
kCFAllocatorDefault
(lldb) po _webView
<WKWebView: 0x6080001a24c0>
(lldb) po [_webView subviews]
<__NSArrayM 0x6000002426a0>(
<WKView: 0x608000140bb0>
)
(lldb) po [[[_webView subviews] firstObject] subviews]
@nevyn
nevyn / GFGetVersion.h
Last active January 13, 2016 19:15
Git version into info.plist. Add GenerateGFVersion.sh as a build step first in your build process.
#import <Foundation/Foundation.h>
/// Retrieve version number of this library, roughly as outputted by git describe
extern NSString *GFGetVersion(void);
@nevyn
nevyn / LookbackActivator.plist
Last active January 4, 2016 16:59
Both "about to register" and "registered" are printed, and shortly after Springboard crashes :( This is the entirety of the source in this dylib.
<?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>Filter</key>
<dict>
<key>Bundles</key>
<array>
<string>com.apple.springboard</string>
</array>
// Buttom of the stack. and it just keeps going like this until stack runs out of memory.
frame #11034: 0x00201c7b CoinPurse`std::__1::function<void (std::__1::error_code const&, std::__1::array<unsigned char, 16ul> const&)>::function<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >(std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&>, std::__1::enable_if<__callable<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >::value, void>::type*) [inlined] std::__1::__function::__func<std::__1::__bind<std::__1::function<void (this=0x0981a5a0, __f=0xbfffc738, __a=0xbfffc170)>&, std::__1::placeholders::__ph<1>&>, std::__1::allocator<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >, void (std::__1::error_code const&, std::__1::array<unsigned char, 16ul> const&)>::__func(std::__1::__bin
@nevyn
nevyn / TCStream.h
Created November 19, 2013 22:42
Simple helpers for working with common data types on NSData-backed input and output streams.
#import <Foundation/Foundation.h>
/** @category TCInputStream
@abstract Reads Big Endian data in convenient sizes
*/
@interface NSInputStream (TCInputStream)
- (int8_t)readByte;
- (uint16_t)readShort;
- (uint32_t)readInt;
- (uint64_t)readLongLong;
@implementation MeteorClient (GFTask)
- (SPTask*)gf_sendMethod:(NSString*)method parameters:(NSArray*)params
{
SPTaskCompletionSource *source = [SPTaskCompletionSource new];
[self sendWithMethodName:method parameters:params responseCallback:^(NSDictionary *response, NSError *error) {
if(error) {
[source failWithError:error];
} else {
[source completeWithValue:response];
@nevyn
nevyn / chain.m
Last active December 26, 2015 22:19
// Wait for logout, then re-login
[[[loginController waitForLogoutCompletion] chain:^SPTask *(id value) {
return [loginController waitForLoginCompletion];
}] addCallback:^(id value) {
self.view.window.userInteractionEnabled = YES;
[self.introDelegate introFlow:self finishedSuccessfully:YES didMerge:YES];
self.introDelegate = nil;
}];