Skip to content

Instantly share code, notes, and snippets.

Abizer Nasir Abizern

View GitHub Profile
Abizern / RecursivePublisher.swift
Last active Jun 15, 2020
Recursive publisher
View RecursivePublisher.swift
// I needed to fetch all the pages from a paged endpoint.
// In this specific case, the JSON results contained a `pagingStatus` section that provided extra information which I could use:
// Hiding that behind a protocol:
import Foundation
protocol PagedReturning {
var pagingStatus: PagingStatus { get }
Abizern / Template.swift
Created Dec 8, 2019 — forked from paulweichhart/Template.swift
SwiftUI Playground Template
View Template.swift
import Foundation
import PlaygroundSupport
import SwiftUI
struct Content: View {
var body: some View {
Text("👋🏻, 🌍!")
View Scanner+Swift.swift
// Scanner+Swift.swift
// A set of idiomatic swift extensions to Scanner
// Based on
// Converted to Swift 3
import Foundation
Abizern / NSURL+StandardURLs.swift
Last active Jan 4, 2016
NSURL extension for common directory URLs
View NSURL+StandardURLs.swift
import Foundation
/// abstract: Convenience methods for getting standard URLs
extension NSURL {
/// The URL to the Documents directory
static var documentsURL: NSURL {
return try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
Abizern / Cartfile.private
Last active Feb 5, 2016
Common Cartfile
View Cartfile.private
github "jspahrsummers/xcconfigs"
github "JungleCandy/LoggingPrint"
Abizern / Timer.swift
Last active Apr 20, 2016
An example of overloaded functions in Swift. - More explanation at
View Timer.swift
//: Playground - noun: a place where people can play
import Foundation
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
// Extend NSTimeInterval to provide the conversion functions.
extension NSTimeInterval {
Abizern / RepeatingTimer.swift
Last active Dec 8, 2016
A function that creates and starts a timer dispatch source.
View RepeatingTimer.swift
// RepeatingTimer.swift
import Foundation
enum TimerError: ErrorType {
/// The timer could not be created.
case CouldNotCreate
Abizern / formatter.swift
Last active Aug 29, 2015
You don't need to declare a custom class to have a singleton formatter, just use a global lazy var.
View formatter.swift
var formatter: NSNumberFormatter = {
let f = NSNumberFormatter()
f.locale = NSLocale.currentLocale()
f.maximumFractionDigits = 2
f.minimumFractionDigits = 2
f.alwaysShowsDecimalSeparator = true
f.numberStyle = .CurrencyStyle
return f
Abizern / loggingPrint.swift
Last active Jan 3, 2019
Debug logging for Swift
View loggingPrint.swift
// LoggingPrint.swift
import Foundation
Prints the filename, function name, line number and textual representation of `object` and a newline character into
the standard output if the build setting for "Active Complilation Conditions" (SWIFT_ACTIVE_COMPILATION_CONDITIONS) defines `DEBUG`.
Abizern / MockingTest.m
Last active Jan 4, 2016
Test for OCMock installation into an Xcode project.
View MockingTest.m
// MockingTest.m
#import <OCMock/OCMock.h>
@interface MockingTest : XCTestCase
You can’t perform that action at this time.