This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class SyncQueue<T> { | |
func push(_ item: T) { | |
syncQueue.sync { | |
self.data.append(item) | |
} | |
} | |
func pop() -> T? { | |
var result: T? = nil | |
syncQueue.sync { | |
if data.isNotEmpty { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// PanOnScroll | |
// | |
// Created by Shinichiro Oba on 2018/03/08. | |
// Copyright © 2018 bricklife.com. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func p_setupTextLayer(text: String) -> CAShapeLayer { | |
var letters = CGPathCreateMutable() | |
let font = CTFontCreateWithName("Helvetica-Bold", 72, nil) | |
let attrs = [kCTFontAttributeName: font] | |
var attrString = NSAttributedString(string: text, attributes: attrs) | |
let line = CTLineCreateWithAttributedString(attrString) | |
let runArray = CTLineGetGlyphRuns(line) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller | |
{ | |
self.shouldReloadCollectionView = NO; | |
self.blockOperation = [[NSBlockOperation alloc] init]; | |
} | |
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo | |
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type | |
{ | |
__weak UICollectionView *collectionView = self.collectionView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. A property has the same name as a segue identifier in XIB | |
@property (nonatomic) ChildViewController1 *childController1; | |
@property (nonatomic) ChildViewController2 *childController2; | |
// #pragma mark - UIViewController | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue | |
sender:(id)sender | |
{ | |
[super prepareForSegue:segue sender:sender]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diafter - dispatch after | |
@weakify(self); | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, $DELAY$ * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ | |
@strongify(self); | |
NSLog(@"dispatch after"); | |
$END$ | |
}); | |
dthread - dispatch in a new thread | |
@weakify(self); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----- Esc ----- | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a | |
Switch between background command line and MC: Ctrl + o | |
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can add support for Google Protocol Buffers to an Xcode 5 project using Cocoapods by adding the following line to your Podfile. | |
pod 'GoogleProtobuf', '~> 2.5.0' | |
This will place the C++ version of the protobuf code into a Pod for your project. It will also add the protoc compiler in the folder Pods/GoogleProtobuf/bin/protoc within your project. | |
You can create a custom build rule in your project that automatically converts the .proto files into .ph.{h,cc} files. Here is how I did that: | |
Setup a build rule to "Process Source files with names matching: *.proto Using Custom Script". The script should include the following: | |
cd ${INPUT_FILE_DIR} |