Skip to content

Instantly share code, notes, and snippets.

View adamkaplan's full-sized avatar

Adam adamkaplan

View GitHub Profile
@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 / UserAgent.swift
Created April 30, 2019 17:58
User Agent Strings in 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 March 8, 2019 02:09
Finance Android App Links File
#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",
<?
if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
define('RANDOM_COMPAT_READ_BUFFER', 8);
}
function random_bytes($bytes)
{
static $fp = null;
/**
@adamkaplan
adamkaplan / PolicePrecincts.geojson
Created December 9, 2017 20:36
NYPD Precincts 12-2017
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 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.
@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 / 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)
@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,