Skip to content

Instantly share code, notes, and snippets.

View adamkaplan's full-sized avatar

Adam adamkaplan

View GitHub Profile
@adamkaplan
adamkaplan / HockeyPublish.sh
Last active January 4, 2016 04:29
See installation instructions in the comment below
# Copyright 2014 Gilt Groupe, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@adamkaplan
adamkaplan / gist:20a697fe171d0eeca9dd
Created December 23, 2014 04:16
Disable warnings on a single call
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (config->queuePointer && config->queuePointer == dispatch_get_current_queue()) {
#pragma clang diagnostic pop
@adamkaplan
adamkaplan / DeDupeExample
Last active August 29, 2015 14:14
Complete Example Code
- (AFHTTPRequestOperation *)GET:(NSString *)urlString
parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation*,id))success
failure:(void (^)(AFHTTPRequestOperation*,NSError*))failure
{
NSCAssert([NSThread isMainThread], @"must execute on the main thread");
NSURL *url = [[NSURL URLWithString:urlString relativeToURL:self.baseURL] absoluteString];
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"GET"
@adamkaplan
adamkaplan / Timer.m
Last active August 29, 2015 14:16
Xcode Timer Snippet.
{
uint64_t t_start = mach_absolute_time();
<#code#>
uint64_t t_end = mach_absolute_time();
struct mach_timebase_info t_info;
mach_timebase_info(&t_info);
double_t elapsed = (t_end - t_start) * t_info.numer / (t_info.denom * (double_t)1e6);
NSLog(@"Elapsed: %fms", elapsed);
}
@adamkaplan
adamkaplan / NSData+JFRBinaryInspection.h
Last active March 13, 2017 08:40
Print NSData As Binary
//
// NSData+JFRBinaryInspection.h
// SimpleTest
//
// Created by Adam Kaplan on 4/15/15.
//
#import <Foundation/Foundation.h>
@interface NSData (JFRBinaryInspection)
// Missing 'result unused' warning demo
// Correct: expect.beNil();
// Wrong: expect.beNil;
#import <Foundation/NSObject.h>
#define expect [EXPExpect new]
@interface EXPExpect : NSObject
- (void(^)(void)) beNil;
@adamkaplan
adamkaplan / UsageExample.m
Last active September 5, 2015 00:29
Exploratory examination of a way to prevent accidental retain cycles in blocks.
//
// YFObjCUtils.c
//
// Created by Adam Kaplan on 7/31/15.
// Licensed under the MIT license.
//
@implementation UsageExample
- (void)usageMethod {
@adamkaplan
adamkaplan / Uncached DNS, new connection
Last active January 16, 2023 03:34
Use Curl to identify bottlenecks in your service layers.
# SSL request to hostname that is not in DNS
> curl -o /dev/null -w @curlformat https://beta.finance.yahoo.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 255k 0 255k 0 0 233k 0 --:--:-- 0:00:01 --:--:-- 233k
Size: 261255
DNS: 0.522
Connect: 0.536
@adamkaplan
adamkaplan / ignore-warnings.codesnippet
Created April 19, 2017 15:37
Xcode Snippets. Drag and drop into Xcode to use.
<?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>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>#pragma clang diagnostic push
@adamkaplan
adamkaplan / new-version.m
Last active June 23, 2017 20:40
trustkit-discuss
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler
{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
{
[TSKPinningValidator handleChallenge:challenge completionHandler:completionHandler];
}
else
{
// This challenge was not for server trust. Fall back to default behavior.