Skip to content

Instantly share code, notes, and snippets.

View robinkunde's full-sized avatar

Robin Kunde robinkunde

View GitHub Profile
#if DEBUG
import Foundation
import UIKit
class SimPasteboardHelper {
static let shared = SimPasteboardHelper()
private var handle: FileHandle?
private var dispatchSource: DispatchSourceFileSystemObject?
@robinkunde
robinkunde / dnsLookup.swift
Created May 28, 2021 22:15
Perform DNS lookups using Swift code
//
// dnsLookup.swift
//
// Created by Robin Kunde on 5/28/21.
//
import dnssd
import Foundation
typealias DNSResultHandler = (String, Int) -> Void
import Foundation
struct LinearStringConsumer {
let str: String
private(set) var currentIndex: String.Index
var currentOffset: String.IndexDistance {
return str.distance(from: str.startIndex, to: currentIndex)
}
import UIKit
public extension UIApplication {
func clearLaunchScreenCache() {
do {
try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
} catch {
print("Failed to delete launch screen cache: \(error)")
}
@robinkunde
robinkunde / DTMobileProvision.swift
Created October 17, 2019 20:02
ASN1 mobile provision parser using DTFoundation
struct MobileProvision {
private let dict: [String: Any]?
init() {
let mpURL = Bundle.main.bundleURL.appendingPathComponent("embedded.mobileprovision")
guard let data = try? Data(contentsOf: mpURL) else {
dict = nil
return
}
@robinkunde
robinkunde / fontNames.swift
Created August 21, 2019 02:24
Print certain font names
for familyName in UIFont.familyNames.sorted() {
var hasPrintedFamilyName = false
for fontName in UIFont.fontNames(forFamilyName: familyName).sorted() {
let font = UIFont(name: fontName, size: 16.0)!
guard font.fontDescriptor.symbolicTraits.contains(.traitMonoSpace) else { continue }
if !hasPrintedFamilyName {
print(familyName)
hasPrintedFamilyName = true
}
@robinkunde
robinkunde / erx_generate_static_dhcp.py
Last active July 12, 2018 21:24
Use this script to generate `configure` commands for static DHCP IP address assignment on EdgeRouter X
#!/usr/bin/env python3
import argparse
import os
import csv
usage = '''Use this script to generate configure commands.
Expected input csv format: identifier,identifier_suffix(optional),ignored,mac-address-with-dashes,ip4-address
First line is ignored.
func exportVisibleImages() {
for (windowIndex, window) in UIApplication.shared.windows.enumerated() {
let prefix = "iOS\(ProcessInfo.processInfo.operatingSystemVersion.majorVersion)_window\(windowIndex)_images"
exportImages(fromRootView: window, toDirectory: "/path/to/target/directory", prefix: prefix)
}
}
func exportImages(fromRootView rootView: UIView, toDirectory directory: String, prefix: String) {
let directoryURL = URL(fileURLWithPath: directory, isDirectory: true)
try! FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil)
@robinkunde
robinkunde / blog.md
Last active September 6, 2017 16:56

When it comes to picking an analytics package for your mobile application, you have plenty of candidates to choose from: Google Firebase, Fabric, Hockeyapp, to just name a few.

These solutions vary in pricing and capabilities. However, the most important consideration for many clients is interoperability with existing analytics or business intelligence packages. For this reason, we often get requests to integrate the Google Analytics SDK into iOS and Android apps. If a mobile app’s structure hews closely to an existing website, the ability to use the same analytics suite for both allows us to easily unify reporting.

Google recently reorganized their Cocoapods offerings, moving components like their analytics package back into its own pod and deprecating the Google pod in the process.

It would have been a good time to redo their integration docs as well, but unfortunately, they are still outdated and incomplete.

I'd lik

@robinkunde
robinkunde / openSimFolderForBundleID.sh
Created July 19, 2017 19:13
openSimFolderForBundleID
#!/bin/bash
BUNDLE_PATH=`xcrun simctl get_app_container booted $1`
if [[ $? -ne 0 ]]; then
exit 1
fi
for f in $BUNDLE_PATH/*; do
open -R "$f"
exit;