Skip to content

Instantly share code, notes, and snippets.

View sgr-ksmt's full-sized avatar
👉
👁👃👁

Suguru Kishimoto sgr-ksmt

👉
👁👃👁
View GitHub Profile
@lucholaf
lucholaf / gist:e37f4d26e406250a156a
Last active September 5, 2016 15:06
Xcode pre-action: generate Swift FAT file to reduce compilation time, since it's faster to recompile the whole source code in a single file
> $PROJECT_DIR/merge.swift; find $PROJECT_DIR/ -iname *.swift -not -name merge.swift -exec cat {} >> $PROJECT_DIR/merge.swift \;
@algal
algal / CGRect+Codable.swift
Created July 10, 2017 21:58
CGRect Codable implementation
// known-good: Swift 4, in Xcode Version 9.0 beta 2 (9M137d)
// will be unnecessary once the language can auto-synthesize for this case, or
// when Apple's ships a Codable implementation for CoreGraphics struct types.
extension CGSize : Codable {
enum CodingKeys: String, CodingKey {
case width
case height
}
struct PermutationSequenceGenerator<T> : GeneratorType {
var permutationSpaceGenerator: PermutationSpaceGenerator<Int>
let elements: [T]
init(elements: [T]) {
self.elements = elements
self.permutationSpaceGenerator = PermutationSpaceGenerator(objects: Array(indices(elements)))
}
@gwengrid
gwengrid / TypeErasure.swift
Last active September 12, 2018 05:14
Example of type erasure with Pokemon
class Thunder { }
class Fire { }
protocol Pokemon {
typealias PokemonType
func attack(move:PokemonType)
}
struct Pikachu: Pokemon {
typealias PokemonType = Thunder
@bobspryn
bobspryn / preferredFontDescriptorWithTextStyle sizes and styles
Created December 11, 2013 01:12
Apple iOS7 sizes and traits for all UIFontTextStyle's and UIContentSizeCategory's
UIContentSizeCategoryExtraSmall
FontStyle: UICTFontTextStyleBody
Point size 14.000000
Family Name .AppleSystemUIBody
FontStyle: UICTFontTextStyleHeadline
Point size 14.000000
Family Name .AppleSystemUIHeadline
Bold
FontStyle: UICTFontTextStyleSubhead
Point size 12.000000

Generated within the iPhone Simulator (iOS Version 8.4 (12H141))

XS S M L XL XXL XXXL Accessibility M AccessibilityL AccessibilityXL AccessibilityXXL AccessibilityXXXL
UIFontTextStyleHeadline 14.0 15.0 16.0 17.0 19.0 21.0 23.0 23.0 23.0 23.0 23.0 23.0
UIFontTextStyleSubheadline 12.0 13.0 14.0 15.0 17.0 19.0 21.0 21.0 21.0 21.0 21.0 21.0
UIFontTextStyleBody 14.0 15.0 16.0 17.0 19.0 21.0 23.0 28.0 33.0 40.0 47.0 53.0
UIFontTextStyleFootnote 12.0 12.0 12.0 13.0 15.0 17.0 19.0 19.0 19.0 19.0 19.0 19.0
UIFontTextStyleCaption1 11.0 11.0 11.0 12.0 14.0 16.0 18.0 18.0 18.0 18.0 18.0 18.0
UIFontTextStyleCaption2 11.0 11.0 11.0 11.0 13.0 15.0 17.0 17.0 17.0 17.0 17.0 17.0
var fetchedResultsProcessingOperations: [NSBlockOperation] = []
private func addFetchedResultsProcessingBlock(processingBlock:(Void)->Void) {
fetchedResultsProcessingOperations.append(NSBlockOperation(block: processingBlock))
}
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
switch type {
case .Insert:
@hhyyg
hhyyg / code.swift
Last active November 17, 2020 09:16
How to access current firebase user from iOS App Extension.
import Foundation
import KeychainAccess //https://github.com/kishikawakatsumi/KeychainAccess
import Firebase
//Requires shared Keychain with the same group name
class ApplicationBuilder {
enum Target {
case app
@zats
zats / script.swift
Last active March 5, 2021 01:32
Update all your plugins for the latest Xcode beta with a single
#!/usr/bin/env xcrun swift
// $ chmod +x script.swift
// $ ./script.swift
// or $ ./script.swift -xcode=/Applications/Xcode-beta.app
import Foundation
@noreturn private func failWithError(message: String) {
print("🚫 \(message)")
import Combine
import FirebaseAuth
public struct CombineAuth {
fileprivate let auth: Auth
}
extension CombineAuth {
public enum Error: Swift.Error {