Skip to content

Instantly share code, notes, and snippets.

View pronebird's full-sized avatar

Andrej Mihajlov pronebird

View GitHub Profile
@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()
@pronebird
pronebird / CoreDataPlayground.swift
Created July 11, 2016 18:04
Sample Core Data Playground
// Playground is where kids play biatch
import CoreData
@objc(City)
class City: NSManagedObject {
@NSManaged var name: String
}
var cityEntity = NSEntityDescription()
@pronebird
pronebird / UITableViewCell+CellLayoutMargins.m
Created June 10, 2016 10:04
Default cell layout margins
@implementation UITableViewCell (CellLayoutMargins)
+ (UIEdgeInsets)defaultCellLayoutMargins {
static NSDictionary *constants;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSMutableDictionary *sizeDictionary = [[NSMutableDictionary alloc] init];
// regular sizes
sizeDictionary[UIContentSizeCategoryExtraSmall] = [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(9, 15, 9, 15)];
@interface UITableViewDynamicTypeConstantsDelegate : NSObject<UITableViewDataSource>
@end
@implementation UITableViewDynamicTypeConstantsDelegate
- (NSInteger)tableView:(__unused UITableView *)tableView numberOfRowsInSection:(__unused NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {