Skip to content

Instantly share code, notes, and snippets.

@NilStack
NilStack / UICollectionViewFlowLayout+DelegateAccess.swift
Created April 21, 2018 02:46 — forked from danielctull/UICollectionViewFlowLayout+DelegateAccess.swift
Wraps the six UICollectionViewFlowLayout delegate methods and their equivalent properties using functional programming techniques, so that values are easier to retrieve. Full details at: http://danieltull.co.uk/blog/2018/04/13/simplifying-uicollectionviewflowlayout-delegate-method-usage-with-functional-programming/
extension UICollectionViewFlowLayout {
typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value)
private var delegate: UICollectionViewDelegateFlowLayout? {
return collectionView?.delegate as? UICollectionViewDelegateFlowLayout
}
func retrieve<Key, Value>(
@NilStack
NilStack / ..build-protobuf-3.0.0.md
Created April 7, 2018 13:38 — forked from petewarden/..build-protobuf-3.0.0.md
Script used to build Google Protobuf 3.0.0 for use with Xcode 7 / iOS 9. Builds all supported architectures and produces a universal binary static library.

Google Protobuf 3.0.1 - Mac OS X and iOS Support

The script in this gist will help you buid the Google Protobuf library for use with Mac OS X and iOS. Other methods (such as homebrew or direct compilation) have issues that prevent their use. The libraries built by this script are universal and support all iOS device architectures including the simulator.

This gist was adapted from the original at https://gist.github.com/BennettSmith/7150245, and updated to deal with Xcode 7 and iOS 9, and download protobuf version 3.0.0.

@NilStack
NilStack / KeyboardNotification.swift
Created August 10, 2017 07:42 — forked from kristopherjohnson/KeyboardNotification.swift
Swift convenience wrapper for the userInfo values associated with a UIKeyboard notification
import UIKit
/// Wrapper for the NSNotification userInfo values associated with a keyboard notification.
///
/// It provides properties that retrieve userInfo dictionary values with these keys:
///
/// - UIKeyboardFrameBeginUserInfoKey
/// - UIKeyboardFrameEndUserInfoKey
/// - UIKeyboardAnimationDurationUserInfoKey
/// - UIKeyboardAnimationCurveUserInfoKey
@NilStack
NilStack / UIDeviceHardware.h
Created August 7, 2016 01:45 — forked from Jaybles/UIDeviceHardware.h
UIDeviceHardware - Determine iOS device being used
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@NilStack
NilStack / RVNReceiptValidation.m
Created March 10, 2016 10:30
Mac App Store Receipt Validation Sample (Mac OS X 10.7)
//
// RVNReceiptValidation.m
//
// Created by Satoshi Numata on 12/06/30.
// Copyright (c) 2012 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//
// This sample shows how to write the Mac App Store receipt validation code.
// Replace kRVNBundleID and kRVNBundleVersion with your own ones.
//
// This sample is provided because the coding sample found in "Validating Mac App Store Receipts"
@NilStack
NilStack / IOMobileFramebuffer.h
Created January 10, 2016 12:30 — forked from anthonya1999/IOMobileFramebuffer.h
A recent disassembly of IOMobileFramebuffer framework
/* You may have to include your IOSurface header to compile, because of the GetLayerDefaultSurface function. If you do not have it, you may just uncomment the typedef to an IOSurface below. */
#include <stdio.h>
#include <sys/mman.h>
#ifdef __cplusplus
extern "C" {
#endif
#define kIOMobileFramebufferError 0xE0000000
@NilStack
NilStack / gist:e5600b9b16dd9d1df48e
Created October 26, 2015 05:07 — forked from timothyarmes/gist:7080170
An implementation of a UINavigationBar subclass for iOS7 which creates a taller navigation bar suitable for adding extra controls underneath the title.The appearance proxy is used for shifting the title and bar button items back up to their original vertical position.Note that it's easy to specify your subclass in XCode: clicking on the UINaviga…
#define kAppNavBarHeight 66.0
@implementation TATallNavigationBar
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setupAppearance];
}
@NilStack
NilStack / FBAnimationPerformanceTracker.h
Last active August 29, 2015 14:26 — forked from clementgenzmer/FBAnimationPerformanceTracker.h
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN