Skip to content

Instantly share code, notes, and snippets.


Ben Bahrenburg benbahrenburg

View GitHub Profile
benbahrenburg / CLLocationManager+Combine.swift
Created June 11, 2021 19:28 — forked from malhal/CLLocationManager+Combine.swift
A Combine location publisher for CLLocationManager.
View CLLocationManager+Combine.swift
// Requirements: a NSLocationWhenInUseUsageDescription entry in Info.plist
// Usage: @State var locator = CLLocationManager.publishLocation()
// and
// .onReceive(locator) { location in
// Improvements needed: Move requestWhenInUseAuthorization into its own publisher and perhaps have a combineLatest pipeline for both authorized and valid location.
// A configuration param to init(), e.g. so each manager can have the same distanceFilter.
import Foundation
import Combine
import CoreLocation
View OIDExternalUserAgentASWebAuthenticationSession.swift.swift
import UIKit
import SafariServices
import AuthenticationServices
import AppAuth
import Reachability
class OIDExternalUserAgentASWebAuthenticationSession: NSObject, OIDExternalUserAgent {
private let presentingViewController: UIViewController
private var externalUserAgentFlowInProgress: Bool = false
private var authenticationViewController: ASWebAuthenticationSession?
benbahrenburg / escape-json.js
Created December 25, 2020 03:39 — forked from matthewmueller/escape-json.js
Escape JSON strings before trying to run JSON.parse
View escape-json.js
Escape JSON
var escapeJSON = exports.escapeJSON = function(json) {
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
var meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
benbahrenburg /
Created July 26, 2020 03:08 — forked from icerge/
Security: ACLs, Query Business Rules

Number of rows removed due to security constraint

User gets this message in a list of records whenever there is a record user doesn't have rights to view. I.e. there is an ACL restricting access to a record or there in NO ACL granting the access. Let's ignore security mode setting here.

It's a default system beharior.

Would you like to get rid of it? System to count with records user has access to?

Solution 1

Replicate row level read access ACLs to query business rules. Naturally, every query will get controlled.

benbahrenburg / Writer.swift
Created October 28, 2019 13:26 — forked from steve228uk/Writer.swift
Write XMP
View Writer.swift
import UIKit
import CoreServices
import ImageIO
class Writer {
let output = NSTemporaryDirectory().appending("output.heic")
lazy var outputUrl: CFURL = {
return URL(fileURLWithPath: output) as CFURL
benbahrenburg / cocoapods-bundle-id
Created May 8, 2018 14:47 — forked from daltonclaybrook/cocoapods-bundle-id
A post install script for CocoaPods that changes the bundle identifier of all pods to the one specified.
View cocoapods-bundle-id
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
if == 'BREnterprise'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution: The Carter Group LLC'
benbahrenburg / LICENSE
Created November 29, 2017 18:58 — forked from commonsguy/LICENSE
deaar: Convert Android AAR Artifacts Into Library Projects
Apache License
Version 2.0, January 2004
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
benbahrenburg / Obfuscator.swift
Created September 19, 2016 00:38 — forked from MathieuWhite/Obfuscator.swift
Obfuscator for Swift
View Obfuscator.swift
// Obfuscator.swift
// SwiftObfuscatorExample
// Created by Mathieu White on 2016-07-03.
// Copyright © 2016 Mathieu White. All rights reserved.
import Foundation
View gist:3cfc8289c30472f40d2f7d02ef72ddcb
import UIKit
struct ConstraintInfo {
var attribute: NSLayoutAttribute = .left
var secondAttribute: NSLayoutAttribute = .notAnAttribute
var constant: CGFloat = 0
var identifier: String?
var relation: NSLayoutRelation = .equal
benbahrenburg / ParameterEncodingExt.swift
Created February 16, 2016 14:28 — forked from tmspzz/ParameterEncodingExt.swift
View ParameterEncodingExt.swift
// Actual gzipping from
// Example: ParameterEncoding.JSON.gzipped
infix operator • { associativity left }
func • <A, B, C>(f: B -> C, g: A -> B) -> A -> C {
return { x in f(g(x)) }
extension ParameterEncoding {