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
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
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 = @[@"https://s.yimg.com/av/curveball/ads/pr/RESIZE/82x82/1342c899c7055c754f17a7e2d948330a.jpeg",
@"https://s.yimg.com/av/curveball/ads/pr/RESIZE/82x82/3c549674c2851a410348412ea45c2eab.jpeg",
@"https://s.yimg.com/av/curveball/ads/pr/RESIZE/82x82/85f1c40fe33d2234ec7d5c8bf01e3a25.jpeg",
@"https://s.yimg.com/av/curveball/ads/pr/RESIZE/82x82/eaa3b450578344d79f1a5ebec9dfdb70.jpeg",
View random.php
<?
if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
define('RANDOM_COMPAT_READ_BUFFER', 8);
}
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
adamkaplan / new-version.m
Last active Jun 23, 2017
trustkit-discuss
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];
}
else
{
// This challenge was not for server trust. Fall back to default behavior.
@adamkaplan
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" "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 / 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 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 / 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.