Skip to content

Instantly share code, notes, and snippets.

View benasher44's full-sized avatar

Ben Asher benasher44

View GitHub Profile
require 'optimist'
require 'plist'
# Setups of source path mapping for the framework at framework_path,
# which has a dsym at dsym_path. It maps the source paths to the
# source_path root. Implementation borrowed from https://medium.com/@maxraskin/background-1b4b6a9c65be
def setup_dsym_source_mapping(framework_path, dsym_path, source_path)
binary_uuids = get_uuids_of_dwarf(framework_path)
dsym_uuids = get_uuids_of_dwarf(dsym_path)
verify_uuids(binary_uuids, dsym_uuids)
@benasher44
benasher44 / kn_gtest_to_junit.sed
Last active February 28, 2023 15:45
K/N GTest Output to JUnit XML using sed
# Escape XML characters
s/&/\&/g
s/"/\"/g
s/'/\'/g
s/</\&lt;/g
s/>/\&gt;/g
s/\[==========\] Running ([0-9]+) tests from [0-9]+ test cases./<testsuites><testsuite tests="\1">/g
s/\[ RUN \] ([[:alnum:]_-]+)\.(.+)/<testcase classname="\1" name="\2">/g
s/\[----------\].+//g
@benasher44
benasher44 / ios.gradle
Last active April 30, 2019 04:23
iOS Gradle Utilities for Generating Fat Frameworks and dSYMs
afterEvaluate {
// Create tasks for creating fat frameworks and fat dsyms for sim and device
def binaryKinds = [
// config, sim task, device task
new Tuple('Debug', linkDebugFrameworkIosSim, linkDebugFrameworkIosDevice),
new Tuple('Release', linkReleaseFrameworkIosSim, linkReleaseFrameworkIosDevice),
]
@benasher44
benasher44 / Swift42Compatibility.swift
Last active March 3, 2019 23:03
Swift 4.2 Compatibility Shims
//
// Created by Ben Asher on 6/13/18.
// Copyright © 2018-present PlanGrid. All rights reserved.
//
import Foundation
import MapKit
import UserNotifications
#if swift(>=4.2)
@benasher44
benasher44 / JSONObjectDecoder.swift
Last active October 22, 2020 13:48
JSONObjectDecoder
//
// Created by Ben Asher on 12/18/17.
// Copyright © 2017-present PlanGrid. All rights reserved.
//
import Foundation
/// A JSON decoder for decoding a Foundation-typed JSON object generated by `JSONSerialization`
/// into concrete swift `Decodable` types
public final class JSONObjectDecoder {
@benasher44
benasher44 / PlanLibUUID.swift
Last active May 2, 2018 19:00
Fast Swift implementation of UUID(uuidString:)
import Foundation
extension UUID {
/// Ranges within a UUID string that contain non-hyphen characters
private static let charRanges = [
(0..<8),
(9..<13),
(14..<18),
(19..<23),
@benasher44
benasher44 / gist:52c3a234c8a98948cdb24c8adbca522d
Created March 27, 2017 21:29
ReactiveCocoa 5.1.0 Swift 3.1 Crash Trace
l-value expression does not have l-value access kind set
(member_ref_expr type='@lvalue UISearchBarDelegate?' location=/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:48 range=[/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 - line:18:48] decl=UIKit.(file).UISearchBar.delegate
(archetype_to_super_expr implicit type='UISearchBar' location=/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 range=[/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 - line:18:43]
(member_ref_expr type='Base' location=/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 range=[/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 - line:18:43] decl=ReactiveSwift.(file).Reactive.base [with Base] direct_to_storage
(declref_expr implicit type='Reactive<Base>' location=/<redacted>/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UISearchBar.swift:18:43 range=[/<redac
@benasher44
benasher44 / todo.py
Created March 18, 2017 04:21
todo.py - produce warnings from TODOs created by the current user
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import os
import re
from contextlib import closing
from itertools import chain
@benasher44
benasher44 / keybase.md
Created January 15, 2017 23:13
benasher44 Keybase Verification

Keybase proof

I hereby claim:

  • I am benasher44 on github.
  • I am benasher44 (https://keybase.io/benasher44) on keybase.
  • I have a public key ASAfZYP_CcVdIjs7IbUG4_rD4NRrujFTIeQ1RbPxVLjdbQo

To claim this, I am signing this object:

@benasher44
benasher44 / gist:e49e5e5d15442d4abb676e5bc79683bf
Created May 6, 2016 15:16
==, != for SequenceType and Dictionary with SequenceType values
func ==<S: SequenceType where S.Generator.Element: Equatable>(lhs: S, rhs: S) -> Bool {
var lgen = lhs.generate()
var rgen = rhs.generate()
while true {
let lelem = lgen.next()
let relem = rgen.next()
if let lelem = lelem, relem = relem {
if lelem != relem {
// elements aren't equal
return false