Skip to content

Instantly share code, notes, and snippets.

View madcato's full-sized avatar

Dani Vela madcato

View GitHub Profile
extension Array {
/**
Insert an element at a position ordered.
Precondition: the array must be already sorted.
- parameter element: element to insert
- parameter orderedBy: This block must return $0 < $1
*/
mutating func insert(ordered element: Element, orderedBy: (_ A: Element, _ B: Element) -> Bool) {
var low = 0
var high = self.count - 1
@madcato
madcato / Observable.swift
Created March 15, 2018 14:51
Just another Observable implementation
//
// Observable.swift
// TestObservable
//
// Created by Daniel Vela on 13/03/2018.
// Copyright © 2018 veladan. All rights reserved.
//
//
// https://colindrake.me/post/an-observable-pattern-implementation-in-swift/
//
@madcato
madcato / TitleShadowButton.swift
Created March 12, 2018 08:51
Button with shadow
//
// TitleShadowButton.swift
// OSFramework
//
// Created by Daniel Vela on 29/04/2017.
// Copyright © 2017 Daniel Vela. All rights reserved.
//
import QuartzCore
@madcato
madcato / TransparentTableViewCell.swift
Created March 12, 2018 08:50
Set transparent color in the background color of UITableViewCell
/
// TransparentTableViewCell.swift
// OSFramework
//
// Created by Daniel Vela on 29/04/2017.
// Copyright © 2017 Daniel Vela. All rights reserved.
//
class TransparentTableViewCell: UITableViewCell {
override func awakeFromNib() {
@madcato
madcato / OSEditableTableViewController.swift
Created March 12, 2018 08:45
Editable table view controller sample
//
// OSEditableTableViewController.swift
// mavlink
//
// Created by Daniel Vela on 26/06/16.
// Copyright © 2016 Daniel Vela. All rights reserved.
//
protocol OSDataSource {
func count() -> Int
@madcato
madcato / OSCircleImageView.swift
Created March 12, 2018 08:43
Rounded image view
//
// OSCircleImageView.swift
// CircleImageProject
//
// Created by Daniel Vela on 15/04/16.
// Copyright © 2016 Daniel Vela. All rights reserved.
//
@IBDesignable
class OSCircleImageView: UIImageView {
@madcato
madcato / OSCircleLabel.swift
Created March 12, 2018 08:42
Present a round label (like badges)
//
// OSCircleLabel.swift
// CircleImageProject
//
// Created by Daniel Vela on 15/04/16.
// Copyright © 2016 Daniel Vela. All rights reserved.
//
@IBDesignable
class OSCircleLabel: UILabel {
@madcato
madcato / OSiCloudDataBackup.swift
Created March 12, 2018 08:39
Backups in the cloud
//
// OSiCloudDataBackup.swift
// OSFramework
//
// Created by Daniel Vela on 20/09/2016.
// Copyright © 2016 Daniel Vela. All rights reserved.
//
/**
Delegate of class OSiCloudDataBackup. Methods are called to indicate a
@madcato
madcato / Core Data Stack
Last active November 30, 2018 11:08
Classes to access CoreData using one shared database that can be accesses in the main thread and in background threads
//
// CoreDataStack.swift
// iOS-Boilerplate
//
// Created by Daniel Vela Angulo on 23/11/2018.
// Copyright © 2018 veladan. All rights reserved.
//
import CoreData
import Foundation
@madcato
madcato / SimplePersistence.swift
Last active March 12, 2018 08:24
Simple persistence for properties using de UserDefaults class in iOS. Can be extended with new providers.
//
// SimplePersistence.swift
// OSFramework
//
// Created by Daniel Vela on 06/02/2017.
// Copyright © 2017 Daniel Vela. All rights reserved.
//
import Foundation