Skip to content

Instantly share code, notes, and snippets.

Adam adamkaplan

Block or report user

Report or block adamkaplan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
adamkaplan / UserAgent.swift
Created Apr 30, 2019
User Agent Strings in Swift
View UserAgent.swift
public class UserAgent {
public static let userAgent: String? = {
guard let info = Bundle.main.infoDictionary,
let appNameRaw = info["CFBundleDisplayName"] ?? info[kCFBundleIdentifierKey as String],
let appVersionRaw = info[kCFBundleVersionKey as String],
let appName = appNameRaw as? String,
let appVersion = appVersionRaw as? String
else { return nil }
#if canImport(UIKit)
adamkaplan / assetlinks.json
Last active Mar 8, 2019
Finance Android App Links File
View assetlinks.json
View code.m
#include <mach/mach_time.h>
NSURLSessionDataTask *task;
void(^doFetch)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error);
NSArray *smallImages = @[@"",
View random.php
if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
function random_bytes($bytes)
static $fp = null;
View PolicePrecincts.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
adamkaplan / new-version.m
Last active Jun 23, 2017
View new-version.m
- (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];
// This challenge was not for server trust. Fall back to default behavior.
adamkaplan / ignore-warnings.codesnippet
Created Apr 19, 2017
Xcode Snippets. Drag and drop into Xcode to use.
View ignore-warnings.codesnippet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>#pragma clang diagnostic push
adamkaplan / Uncached DNS, new connection
Last active Aug 24, 2018
Use Curl to identify bottlenecks in your service layers.
View Uncached DNS, new connection
# SSL request to hostname that is not in DNS
> curl -o /dev/null -w @curlformat
% 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 / UsageExample.m
Last active Sep 5, 2015
Exploratory examination of a way to prevent accidental retain cycles in blocks.
View UsageExample.m
// YFObjCUtils.c
// Created by Adam Kaplan on 7/31/15.
// Licensed under the MIT license.
@implementation UsageExample
- (void)usageMethod {
View EXPExpectaWarningDemo.m
// 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;
You can’t perform that action at this time.