Skip to content

Instantly share code, notes, and snippets.

@pronebird
pronebird / apple-fomat-regex.txt
Last active October 1, 2021 12:53
Regex for parsing sprintf style format with Apple privacy extensions
# Ignore escape sequences %%
(?<!%)
# Match %
%
# Match extended attributes supported by OSLog, ie: {public, uuid_t}
# See https://developer.apple.com/documentation/os/logging for built-in value decoders
(?:\{([\w-,\s]+)\}){0,1}
@pronebird
pronebird / redux_v3.x.x.js
Last active July 25, 2017 18:17
Patch that adds Dispatch parameter to redux interface
// flow-typed signature: 7f1a115f75043c44385071ea3f33c586
// flow-typed version: 358375125e/redux_v3.x.x/flow_>=v0.33.x
declare module 'redux' {
/*
S = State
A = Action
D = Dispatch
@pronebird
pronebird / CLLocationCoordinate2D+Encodable.swift
Created July 4, 2017 09:46
Encode CLLocationCoordinate2D with Codable in Swift 4
import CoreLocation
extension CLLocationCoordinate2D: Codable {
public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(longitude)
try container.encode(latitude)
}
@pronebird
pronebird / org.nsa.pf.rules
Created January 2, 2017 15:51
OS X Firewall Packet Filter (pfctl): Killswitch + Protection
# Put this file in /etc/pf.anchors/
# Options
set block-policy drop
set fingerprints "/etc/pf.os"
set ruleset-optimization basic
set skip on lo0
# Interfaces
inet_define = "en0"
//: Playground - noun: a place where people can play
//: Binary gap solution for https://codility.com/programmers/task/binary_gap/
import UIKit
// use unsigned
func binary_gap(_ number: UInt) -> UInt {
var max_gap: UInt = 0
var current_gap: UInt = 0
@pronebird
pronebird / github-commit-url.sh
Created September 6, 2016 13:23
Custom action for Source Tree app to copy commit URL on GitHub
#!/bin/sh
#
# Custom action for Source Tree app to copy commit URL on GitHub
# Menu caption: Copy Changeset URL on GitHub
# Script to run: ~/bin/github-commit-url
# Parameters: $REPO $SHA
#
if (( $# != 2 ))
@pronebird
pronebird / .gitattributes
Created August 22, 2016 12:36
Convert your .strings files to UTF-8 once and forever
*.strings text diff
@pronebird
pronebird / MLPatchTransitionViewAccessibility.m
Created July 21, 2016 01:01
Workaround to prevent VO from accessing elements in presenting view displayed beneath dimmed overlay. Default container view ignores `-accessibilityViewIsModal`
/**
* Workaround to prevent VO from accessing elements in presenting view beneath overlay.
*
* @param transitionView UIPresentationController.containerView
*/
static void MLPatchTransitionViewAccessibility(id transitionView) {
NSCParameterAssert(transitionView);
static Class transitionViewClass;
static Class mlTransitionViewClass;
@pronebird
pronebird / CoreDataPlayground-v2.swift
Created July 11, 2016 19:43
Sample CoreData Playground with relationships
// Playground is where kids play biatch
import CoreData
@objc(City)
class City: NSManagedObject {
@NSManaged var name: String
@NSManaged var streets: NSSet
}
@pronebird
pronebird / CoreDataDuplicateRecordsPlayground.swift
Created July 11, 2016 18:26
Fetch duplicate records with CoreData
// Playground is where kids play
import CoreData
@objc(City)
class City: NSManagedObject {
@NSManaged var name: String
}
var cityEntity = NSEntityDescription()