Skip to content

Instantly share code, notes, and snippets.

View Josscii's full-sized avatar
💭
??

Josscii Josscii

💭
??
View GitHub Profile
@wattnpapa
wattnpapa / MKMapViewZoomLevel.swift
Created May 10, 2017 13:21
MKMapViewZoomLevel.swift
//
// MKMapViewZoomLevel.swift
//
// Created by Johannes Rudolph on 10.05.17.
// Based on http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/
//
import Foundation
import MapKit
@lexrus
lexrus / CollectionOperator.swift
Created April 24, 2017 08:53
Avoid hard-coded KVC collection operators
import Foundation
enum CollectionOperator: String {
case avg
case count
case max
case min
case sum
//
// ContextLabel.swift
// ContextLabel
//
// Created by Cory D. Wiles
// Copyright (c) 2017 Cory D. Wiles. All rights reserved.
//
import Foundation
import UIKit
import UIKit
enum LayoutableButtonVerticalAlignment: String {
case center
case top
case bottom
case unset
}
enum LayoutableButtonHorizontalAlignment: String {
@kishikawakatsumi
kishikawakatsumi / ReorderingRealmResultsInTableView.swift
Created July 27, 2016 04:51
Reorder Realm Results in UITableView
import UIKit
import RealmSwift
class Data: Object {
dynamic var name = ""
...
dynamic var order = 0 // 並べ替えのためのカラムが必要
}
@hotpaw2
hotpaw2 / RecordAudio.swift
Last active March 20, 2025 03:59
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.
@robnadin
robnadin / NSDate+ISO8601.swift
Created March 8, 2016 16:44
Fast C-based ISO8601 date parser written in Swift
import Foundation
extension NSDate {
class func dateFromISO8601String(string: String?) -> NSDate? {
guard let string = string else {
return nil
}
var tm = Darwin.tm()
@preble
preble / NSTextStorageSubclass.swift
Created February 9, 2016 04:45
Base subclass of NSTextStorage in Swift
import Cocoa
@objc
class SomeTextStorage: NSTextStorage {
private var storage: NSMutableAttributedString
override init() {
storage = NSMutableAttributedString(string: "", attributes: nil)
super.init()
@jkosoy
jkosoy / CGSize+AspectFunctions.swift
Last active June 3, 2023 18:11
Aspect Fill and Aspect Fit calculations in Swift
// port of http://stackoverflow.com/a/17948778/3071224
import UIKit
import Foundation
extension CGSize {
static func aspectFit(aspectRatio : CGSize, var boundingSize: CGSize) -> CGSize {
let mW = boundingSize.width / aspectRatio.width;
let mH = boundingSize.height / aspectRatio.height;
@n00neimp0rtant
n00neimp0rtant / gist:27829d87118d984232a4
Last active May 24, 2019 15:10
UIVisualEffectView blur radius manipulation (new for iOS 9)
// iOS 9 allows you to animate between visual effects, which gives you the
// ability to manipulate the blur radius. this can be useful for animating
// a backdrop for a custom modal, and with a few tricks, can even be set
// indirectly, allowing you to "scrub" between them back and forth with
// a gesture, just like when you pull down Spotlight.
// these are the two effects you want to transition between
UIVisualEffect *startEffect = nil; // "nil" means no blur/tint/vibrancy (plain, fully-transparent view)
UIVisualEffect *endEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];