Skip to content

Instantly share code, notes, and snippets.

View mathewsanders's full-sized avatar

Mathew Sanders mathewsanders

View GitHub Profile
@Gurdeep0602
Gurdeep0602 / AppStoryboard.swift
Last active April 2, 2024 09:54
AppStoryboard enumeration
//
// AppStoryboards.swift
// AppStoryboards
//
// Created by Gurdeep on 15/12/16.
// Copyright © 2016 Gurdeep. All rights reserved.
//
import Foundation
import UIKit
@michaelevensen
michaelevensen / PagingCollectionViewController.swift
Last active April 10, 2024 08:46
An example of perfectly paging horizontal UICollectionViewController with overflowing cells. Works great with Storyboard — no need to set any specific attributes, just add this Class to the Controller and set your desired size for the cells like you would normally.
import UIKit
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
/* Custom scrollView for paging */
let pagingScrollView = UIScrollView()
/* Return item size */
@aparrish
aparrish / tarot_stuff.md
Created October 15, 2016 13:56
some notes and cool stuff for digital tarot/generative text
@mathewsanders
mathewsanders / CGSize+Extension.swift
Created October 14, 2016 19:20
Create CGContext from a CGSize
extension CGSize {
typealias ContextClosure = (_ context: CGContext, _ frame: CGRect) -> ()
func image(withContext context: ContextClosure) -> UIImage? {
UIGraphicsBeginImageContext(self)
let frame = CGRect(origin: .zero, size: self)
context(UIGraphicsGetCurrentContext()!, frame)
let image = UIGraphicsGetImageFromCurrentImageContext()
@avdyushin
avdyushin / storage.swift
Last active August 28, 2023 14:35
CoreData stack for iOS 9 and iOS 10 using Swift 3
//
// Storage.swift
//
// Created by Grigory Avdyushin on 30.06.16.
// Copyright © 2016 Grigory Avdyushin. All rights reserved.
//
import UIKit
import CoreData
@yichizhang
yichizhang / KeyboardViewController.swift
Created May 7, 2016 07:04
iOS9 Keyboard extension - Custom height keyboard
//
// KeyboardViewController.swift
// CustomHeightKeyboard
//
// Created by Yichi on 3/10/2015.
// Copyright (c) 2015-present Yichi. All rights reserved.
//
import UIKit
@huguesbr
huguesbr / NSDataExtensions.swift
Last active July 18, 2019 08:10 — forked from tanner0101/NSDataExtensions.swift
Convert to and from NSData for common Swift types. Includes Eddystone URL conversion.
//
// NSDataExtensions.swift
// MAPO
//
// Created by Hugues Bernet-Rollande on 21/3/16.
// Copyright © 2016 WB Technologies. All rights reserved.
//
import Foundation
@alonecuzzo
alonecuzzo / ithunk.swift
Created February 2, 2016 20:14
Thunk Presentation
import UIKit
//POP is great, but there are some gotchas when dealing with protocols that have a Self requirement.
// Self
protocol OwlType {
func hootWithOwlType(owl: Self)
}
class GreatHornedOwl: OwlType {
@daaain
daaain / prototype.html
Last active August 13, 2016 18:21
Quick prototyping boilerplate: React + Babel + Foundation + Sheetrock. See it running here: http://www.danieldemmel.me/in-browser-prototype-boilerplate/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prototype</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.3/foundation-flex.css">
<script src="https://fb.me/react-with-addons-15.3.0.js" type="text/javascript"></script>
<script src="https://fb.me/react-dom-15.3.0.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/chriszarate/sheetrock/master/dist/sheetrock.min.js"></script>
@capttaco
capttaco / Fetchable.swift
Last active May 3, 2019 17:28
A utility protocol for custom NSManagedObjects that makes querying contexts simpler and more convenient. Requires Swift 2.
import CoreData
protocol Fetchable
{
typealias FetchableType: NSManagedObject
static func entityName() -> String
static func objectsInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> [FetchableType]
static func singleObjectInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> FetchableType?
static func objectCountInContext(context: NSManagedObjectContext, predicate: NSPredicate?) -> Int