Skip to content

Instantly share code, notes, and snippets.

View Abizern's full-sized avatar
🎧
Working from home

Abizer Nasir Abizern

🎧
Working from home
View GitHub Profile
@Abizern
Abizern / layer0.json
Created October 15, 2020 09:37 — forked from kajsa/layer0.json
Atreus 2 Chrysalis config
{
"keymap": [
{
"keyCode": 52,
"label": "'"
},
{
"keyCode": 54,
"label": ","
},
@Abizern
Abizern / RecursivePublisher.swift
Last active June 15, 2020 11:36
Recursive publisher
// 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
Abizern / Template.swift
Created December 8, 2019 20:42 — forked from paulweichhart/Template.swift
SwiftUI Playground Template
import Foundation
import PlaygroundSupport
import SwiftUI
struct Content: View {
var body: some View {
Text("👋🏻, 🌍!")
}
}
// Scanner+Swift.swift
//
// A set of idiomatic swift extensions to Scanner
//
// Based on https://gist.github.com/natecook1000/59bb0c9117b555f5d40d
// Converted to Swift 3
//
import Foundation
@Abizern
Abizern / NSURL+StandardURLs.swift
Last active January 4, 2016 14:31
NSURL extension for common directory URLs
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
Abizern / Cartfile.private
Last active February 5, 2016 12:00
Common Cartfile
github "jspahrsummers/xcconfigs"
github "JungleCandy/LoggingPrint"
@Abizern
Abizern / Timer.swift
Last active April 20, 2016 16:36
An example of overloaded functions in Swift. - More explanation at http://abizern.org/2015/10/11/swift-function-overloading-by-return-type/
//: 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
Abizern / RepeatingTimer.swift
Last active December 8, 2016 16:32
A function that creates and starts a timer dispatch source.
//
// RepeatingTimer.swift
//
import Foundation
enum TimerError: ErrorType {
/// The timer could not be created.
case CouldNotCreate
}
@Abizern
Abizern / formatter.swift
Last active August 29, 2015 14:19
You don't need to declare a custom class to have a singleton formatter, just use a global lazy var.
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
Abizern / loggingPrint.swift
Last active September 22, 2021 14:28
Debug logging for 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`.