Skip to content

Instantly share code, notes, and snippets.

View nerdsRob's full-sized avatar
:shipit:

Rob Siwek nerdsRob

:shipit:
View GitHub Profile
@nerdsRob
nerdsRob / AppUtils
Created June 10, 2018 20:47
Util functions
import Foundation
import UIKit
struct AppUtils {
private static let byteCountFormatter: ByteCountFormatter = {
let formatter = ByteCountFormatter()
formatter.allowedUnits = [.useMB, .useKB]
formatter.countStyle = .memory
return formatter
}()
@nerdsRob
nerdsRob / Collection+Extensions
Created June 10, 2018 20:45
Safe index in collection
extension Collection {
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@nerdsRob
nerdsRob / homebrew linking
Last active August 29, 2015 13:57
homebrew unlink && link kegs
brew list -1 | while read line; do brew unlink $line; brew link $line; done
#import <objc/runtime.h>
#import <objc/message.h>
#import <QuartzCore/QuartzCore.h>
#define PROPERTY(propName) NSStringFromSelector(@selector(propName))
// A better assert. NSAssert is too runtime dependant, and assert() doesn't log.
// http://www.mikeash.com/pyblog/friday-qa-2013-05-03-proper-use-of-asserts.html
// Accepts both:
// - PSPDFAssert(x > 0);
// Takes string of Note + Octave
// Example:
// var frequency = getFrequency('C3');
var getFrequency = function (note) {
var notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'],
octave,
keyNumber;
if (note.length === 3) {
//
// See full source code :
// https://github.com/FLCLjp/VerifyFingerPrint
//
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([[challenge protectionSpace] authenticationMethod] == NSURLAuthenticationMethodServerTrust) {
SecTrustRef trustRef = [[challenge protectionSpace] serverTrust];
@nerdsRob
nerdsRob / build.sh
Created March 25, 2013 10:59 — forked from bayerj/build.sh
asdasd#in older versions of Xcode4 you may need to set PRODUCT_NAME manually
DIST_LIST=<TestFlight Distribution List name here>
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
LOG="/tmp/testflight.log"
DATE=$( /bin/date +"%Y-%m-%d" )
@nerdsRob
nerdsRob / ClassGetSubclasses
Created February 24, 2013 19:33
ObjC runtime: Get all subclasses ARC
NSArray *ClassGetSubclasses(Class parentClass)
{
int numClasses = objc_getClassList(NULL, 0);
Class *classes = NULL;
classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
NSMutableArray *result = [NSMutableArray array];
for (NSInteger i = 0; i < numClasses; i++) {
#define ObjectKeyPath(OBJECT, KEYPATH) \
((void)(NO && ((void)OBJECT.KEYPATH, NO)), @ # KEYPATH )
NSString *str = @"foobar";
NSLog(@"%@", [str valueForKey:ObjectKeyPath(str, length)]);