Skip to content

Instantly share code, notes, and snippets.

@leilee
leilee / plistGitDiff
Created February 3, 2018 03:18 — forked from scottrigby/plistGitDiff
Shows git diff of tracked plist files
#!/bin/bash
## @file
## Shows git diff of tracked plist files.
##
## Normally, Mac plist files are binary, so git diffs do not display. However,
## there are cases where seeing diffs is important. For example, when tracking
## changes via Mackup's git storage option.
##
## @see http://confusatory.org/post/133141617492/git-diff-for-binary-apple-property-list-files
@leilee
leilee / ClosureSelector.swift
Last active November 24, 2017 04:31 — forked from avighnash/ClosureSelector.swift
#UIKit #UIControl #gesture
class ClosureSleeve {
let closure: () -> ()
init(attachTo: AnyObject, closure: @escaping () -> ()) {
self.closure = closure
objc_setAssociatedObject(attachTo, "[\(arc4random())]", self, .OBJC_ASSOCIATION_RETAIN)
}
@objc func invoke() {
closure()
//
// PSPDFFastEnumeration.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
@protocol PSPDFFastEnumeration <NSFastEnumeration>
@leilee
leilee / gist:798839857cc79536805e423471d694a3
Created July 12, 2017 08:27 — forked from steipete/gist:6133152
Create a hash from a CGRect
NSUInteger PSPDFHashFromCGRect(CGRect rect) {
return (*(NSUInteger *)&rect.origin.x << 10 ^ *(NSUInteger *)&rect.origin.y) + (*(NSUInteger *)&rect.size.width << 10 ^ *(NSUInteger *)&rect.size.height);
}
@leilee
leilee / CCacheMacNinja.md
Created July 6, 2017 08:45 — forked from jjgod/CCacheMacNinja.md
Using ccache for Mac builds

Introduction

ccache is a compiler cache. It speeds up recompilation of C/C++ code by caching previous compilations and detecting when the same compilation is being done again. This often results in a significant speedup in common compilations, especially when switching between branches. This page is about using ccache on Mac with clang and ninja build system. If you want to use Xcode, please refer to the old CCacheMac page.

In order to use ccache with clang, you need to use the current git HEAD, since the most recent version (3.1.9) doesn't contain the patch needed for using chromium style plugin.

Installation

To install ccache with [homebrew](http://mxcl.

@leilee
leilee / coordinate_systems.swift
Created May 27, 2017 06:01 — forked from phi161/coordinate_systems.swift
Converting Between View Coordinate Systems
import UIKit
import PlaygroundSupport
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Main view
self.view.backgroundColor = .black
@leilee
leilee / ios-cell-registration-swift.md
Created April 4, 2017 04:13 — forked from gonzalezreal/ios-cell-registration-swift.md
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@leilee
leilee / gist:882842cc6646e5db2f6647a4cedb4b1a
Created September 30, 2016 07:44 — forked from steipete/ios-xcode-device-support.sh
Using iOS 10.1 devices with Xcode 8.0 (or: Xcode 7.3.1 and iOS 10 devices, same trick)
// The trick is to link the DeviceSupport folder from the beta to the stable version.
ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.1\ \(14B54\)/ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and recommect your devices. You will need to do that for every beta of iOS 10.1+/Xcode 8.
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
@leilee
leilee / FRP iOS Learning resources.md
Created August 30, 2016 06:05 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos

@leilee
leilee / iterm2-solarized.md
Created August 28, 2016 16:06 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font (OS X / macOS)

Solarized