Skip to content

Instantly share code, notes, and snippets.

View Baza207's full-sized avatar

James Barrow Baza207

View GitHub Profile
/*
Copyright (C) 2016 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
A struct for accessing generic password keychain items.
*/
import Foundation
@Baza207
Baza207 / SwiftLintRunScript.sh
Created August 29, 2017 11:56
Default code to add to a Run Scrip Build Phase in Xcode for SwiftLint.
if [ "$USER" != "xcodeserver" ]; then
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
fi
@Baza207
Baza207 / TimerExtensions.swift
Created February 20, 2017 23:32
Timer extension to add basic block timers for pre-iOS 10.
public extension Timer {
@discardableResult
public class func scheduledTimer(withTimeInterval interval: TimeInterval, block: @escaping (Timer) -> Void) -> Timer {
let fireDate = interval + CFAbsoluteTimeGetCurrent()
let timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, fireDate, 0, 0, 0) { (runLoopTimer) in
block(runLoopTimer!)
}!
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, CFRunLoopMode.commonModes)
@Baza207
Baza207 / Fastfile
Last active April 7, 2016 14:19
Default Fastfile setup.
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/docs/Actions.md
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# By default, fastlane will send which actions are used
# No personal data is shared, more information on https://github.com/fastlane/enhancer
@Baza207
Baza207 / .gitignore
Created March 14, 2016 20:38
Default .gitignore file for Xcode projects.
# Mac OS X
.DS_Store
# Xcode
## Build generated
build/
DerivedData
## Various settings
@Baza207
Baza207 / .swiftlint.yml
Last active June 19, 2021 09:56
Default rules for SwiftLint.
disabled_rules: # rule identifiers to exclude from running
- line_length
- force_cast
- trailing_whitespace
- todo
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- fastlane
@Baza207
Baza207 / UICollectionViewControllerExtensions
Last active September 14, 2016 15:10
A Swift extension for UICollectionViewController to allow setting and getting a UIRefresh control in the same manor as UITableViewController.
///
/// Extention functions for UICollectionViewController
///
extension UICollectionViewController {
/// Allows easy access to a collection view controller's refrsh control the same way as in a table view controller.
var refreshControl: UIRefreshControl? {
get {
return collectionView?.viewWithTag(140412014669856) as? UIRefreshControl
}
set {