Skip to content

Instantly share code, notes, and snippets.

View douglastaquary's full-sized avatar

Douglas Taquary douglastaquary

View GitHub Profile
import Foundation
extension Formatter {
//var localTimeZoneName: String { return TimeZone.current.identifier }
static let iso8601: DateFormatter = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
/// Request to fetch and store new XApp token if the current token is missing or expired.
func XAppTokenRequest(_ defaults: UserDefaults) -> Observable<String?> {
var appToken = XAppToken(defaults: defaults)
// If we have a valid token, return it and forgo a request for a fresh one.
if appToken.isValid {
return Observable.just(appToken.token)
}
import UIKit
extension UITextField {
func flashForError() {
self.layer.borderWidth = 1
self.layer.borderColor = UIColor.red.cgColor
delayToMainThread(2) {
self.layer.borderWidth = 0
self.layer.borderColor = UIColor.clear.cgColor
import UIKit
final class VCActivityIndicator {
static let sharedInstance = VCActivityIndicator()
let container: UIView = {
let view = UIView()
view.backgroundColor = .clear
return view
//
// RepositoriesViewModel.swift
//
// Created by Douglas Taquary on 03/06/17.
// Copyright © 2017 Douglas Taquary. All rights reserved.
//
import Foundation
import RxSwift
import RxCocoa
@douglastaquary
douglastaquary / LoadMoreActivityIndicator.swift
Created June 13, 2017 19:30
Loading more data on server endless concept
//
// LoadMoreReposActivityIndicator.swift
//
// Created by Douglas Taquary on 05/06/17.
// Copyright © 2017 Douglas Taquary. All rights reserved.
//
import UIKit
class LoadMoreReposActivityIndicator {
@douglastaquary
douglastaquary / scrollViewDidScroll.swift
Created June 13, 2017 19:31
Método para chamar o LoadMoreAcitivityIndicator
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let currentOffset = scrollView.contentOffset.y
let maximumOffset = scrollView.contentSize.height - scrollView.frame.size.height
let deltaOffset = maximumOffset - currentOffset
if deltaOffset <= -64 {
if ( !loadMoreStatus ) {
self.loadMoreStatus = true
```cp -r /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0\ \(15A5278f\) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/```
@douglastaquary
douglastaquary / PullRequestsTableViewControllerTests.swift
Created June 23, 2017 03:33
Implementação básica para testar ViewControllers com Quick/Nimble
class PullRequestsTableViewControllerTests: QuickSpec {
override func spec() {
describe("pullrequests TableViewController") {
var controller : PullRequestsTableViewController!
beforeEach {
let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
import UIKit
extension UIButton {
func loadingIndicator(toShow: Bool) {
let originalButtonText = self.titleLabel?.text
if toShow {
let indicator = UIActivityIndicatorView()