Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
ricardopereira / FadeScrollView.swift
Created May 20, 2020 09:07 — forked from luismachado/FadeScrollView.swift
Custom UIScrollView with fade effect
//
// FadeScrollView.swift
//
// Created by Luís Machado on 23/06/2017.
// Copyright © 2017 Luis Machado. All rights reserved.
//
import UIKit
class FadeScrollView: UIScrollView, UIScrollViewDelegate {
@ricardopereira
ricardopereira / FileManagerExtensions.swift
Created December 3, 2019 16:43 — forked from AvdLee/FileManagerExtensions.swift
Easily print out useful locations for usage during debugging on the Simulator.
extension FileManager {
/*
Prints out the locations of the simulator and the shared group folder.
This is useful for debugging file issues.
Example usage: FileManager.default.printFileLocations()
*/
func printFileLocations() {
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let simulatorFolder = paths.last!
import Foundation
final class SafeSyncQueue {
struct QueueIdentity {
let label: String
}
let queue: DispatchQueue
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
SUPPORTED_PLATFORMS = iphoneos macosx appletvos watchos iphonesimulator appletvsimulator watchsimulator
SWIFT_VERSION = 4.2
IPHONEOS_DEPLOYMENT_TARGET = 9.0
MACOSX_DEPLOYMENT_TARGET = 10.11
@ricardopereira
ricardopereira / .gitignore
Created October 30, 2018 00:38 — forked from pepasflo/.gitignore
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
@ricardopereira
ricardopereira / spm
Created August 27, 2018 09:32 — forked from JohnSundell/spm
A script that makes it easier to use the Swift Package Manager by making common commands less verbose 👍
#!/usr/bin/env bash
# Put this file in /usr/local/bin and then run chmod +x on it to make it executable
command=$1
shift
case $command in
"init" )
swift package init "$@"
@ricardopereira
ricardopereira / UIAlertController+TextField.swift
Created August 14, 2018 22:27 — forked from ole/UIAlertController+TextField.swift
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@ricardopereira
ricardopereira / TestCase.swift
Created August 14, 2018 22:09 — forked from DivineDominion/TestCase.swift
Bridging XCTAssertThrows to Swift to catch exceptions. (Doesn't work with assert(), though)
class ExceptionTestCase: XCTestCase {
func raisesException() {
var exception = NSException(name: NSInternalInconsistencyException, reason: "Testing exceptions", userInfo: nil)
XCTAssertThrows({ exception.raise() })
XCTAssertThrowsSpecific({ exception.raise() }, NSInternalInconsistencyException, "Should raise NSInternalInconsistencyException")
}
}
@ricardopereira
ricardopereira / DebuggingObjCBlocks.lldbinit
Last active June 13, 2018 02:02 — forked from mayoff/!README.md
Debugging Objective-C blocks in lldb
command script import ~/pblock.py