Skip to content

Instantly share code, notes, and snippets.

View hborders's full-sized avatar

Heath Borders hborders

View GitHub Profile
@hborders
hborders / JiveCommon.podspec
Created October 24, 2015 16:10
Problems integrating Crashlytics and Fabric into a cocoapods project that consumes a Swift pod.
#
# Be sure to run `pod lib lint JiveCommon.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# Any lines starting with a # are optional, but encouraged
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
@hborders
hborders / WeakTestTests.m
Created March 1, 2016 05:30
Is self guaranteed to stay alive until the end of a method call if it was referenced from within a __weak lvalue?
//
// WeakTestTests.m
// WeakTestTests
//
// Created by Borders, Heath on 2/29/16.
// Copyright © 2016 Heath Borders. All rights reserved.
//
#import <XCTest/XCTest.h>
@hborders
hborders / PlaygroundTests.m
Created May 3, 2016 15:49
Testing whether NSMutableArray is biased towards insertion and removal at the end
#import <XCTest/XCTest.h>
@interface PlaygroundTests : XCTestCase
@end
@implementation PlaygroundTests
static const NSUInteger length = 100000000;
@hborders
hborders / PlaygroundTests.m
Last active September 13, 2016 19:49
Why ivars are safer than private properties for private data.
//
// PlaygroundTests.m
// PlaygroundTests
//
// Created by Borders, Heath on 3/9/16.
// Copyright © 2016 Twitch. All rights reserved.
//
#import <XCTest/XCTest.h>
@hborders
hborders / decimalize_git_hash.bash
Last active January 7, 2023 13:56
Print the given git hash + a prepended "1" in decimal form
#!/bin/bash -euo pipefail
if [ ${#} -eq 0 ]
then
# read from STDIN
MAYBE_GIT_HASH=$( cat )
else
MAYBE_GIT_HASH="${1}"
fi
@hborders
hborders / minutes_since_date.bash
Created September 14, 2016 18:16
Print the number of minutes since a given date
#!/bin/bash -euo pipefail
if [ ${#} -eq 0 ]
then
# read from STDIN
DATE=$( cat )
else
DATE="${1}"
fi
@hborders
hborders / versions.bash
Created September 14, 2016 18:18
A script run within Xcode's `Run Script` build phase that outputs version info into `versions.h`, which we prepend onto our Info.plist template.
#!/bin/bash -euo pipefail
# When we increment TW_BUNDLE_SHORT_VERSION_STRING
# also update TW_BUNDLE_SHORT_VERSION_DATE to the current date/time
# we don't have to be very exact, but it should be updated at least
# once every 18 months because iTunes requires that a CFBundleVersion
# be at most 18 characters long, and DECIMALIZED_GIT_HASH will be
# at most 10 characters long. Thus, MINUTES_SINCE_DATE needs to be
# at most 7 characters long so we can use the format:
# ${MINUTES_SINCE_DATE}.${DECIMALIZED_GIT_HASH}
@hborders
hborders / git_hash_from_cfbundleversion.bash
Created September 14, 2016 18:19
Convert a `CFBundleVersion` string constructed with `versions.bash` into a short revision of a git commit hash
#!/bin/bash -euo pipefail
if [ ${#} -eq 0 ]
then
# read from STDIN
MAYBE_CFBUNDLEVERSION=$( cat )
else
MAYBE_CFBUNDLEVERSION="${1}"
fi
@hborders
hborders / NSCFMutableSetWithOpaquePointersTests.m
Last active September 24, 2016 00:41
Shows that CFMutableSetRef doesn't transfer CFSetCallBacks to NSSet returned from setByAddingObject:
#define HJBAssertNotSame(expression1, expression2, ...) \
XCTAssert((expression1) != (expression2), \
__VA_ARGS__)
- (void)testCFMutableSetWithOpaquePointersCopiedToNSSetByAddingDoesNotKeepOpaquePointerBehavior
{
NSString * _Nonnull string1 = [@"ab" stringByAppendingString:@"cd"];
NSString * _Nonnull string2 = [@"a" stringByAppendingString:@"bcd"];
TWAssertNotSame(string1,
@hborders
hborders / TWFoundation.tree
Last active February 10, 2017 16:22
TWFoundation tree
TWFoundation.podspec # the podspec that our Twitch iOS App and the TWFoundationHost project below consume
TWFoundation
├── Podfile # Configures TWFoundationHost and TWFoundationHostTests
├── Podfile.lock
├── Pods
│   ├── ... # Pods stuff
├── TWFoundation
│   ├── NSArray+TWFoundation.h
│   ├── NSArray+TWFoundation.m
| ├── ... # More TWFoundation classes