Skip to content

Instantly share code, notes, and snippets.

View dedeexe's full-sized avatar

dede.exe dedeexe

  • PuraMagia Labs
  • Brazil
View GitHub Profile
@dedeexe
dedeexe / FloatingView.swift
Last active September 20, 2016 04:52
Creating a kind of toast
import UIKit
extension UIView {
private struct FloatingKeys {
static var FKCompletion : String = "FKCompletion"
}
private class CompletionWrapper {
private var completion : (()->Void)? = nil
@dedeexe
dedeexe / UITextField+MaskPattern.swift
Last active November 16, 2018 21:14
Adding Mask to a TextField
//
// UITextField+MaskPattern.swift
// MaskedTextField
//
// Created by dede.exe on 10/07/16.
//
// It's totally base on article : "http://vojtastavik.com/2015/03/29/real-time-formatting-in-uitextfield-swift-basics/"
// And I don't mind if the original author allow me to publish it :)... But I'll keep the reference
// I modified the original implementation to keep it as an Extension...
//
@dedeexe
dedeexe / UIColor+Literals.swift
Last active October 20, 2016 19:50
UIColor extension for literal numbers
//
// UIColor+Literals.swift
// Created by dede.exe
//
import UIKit
public extension UIColor {
public convenience init(red:Int, green:Int, blue:Int, percentAlpha:Int = 100)
{
@dedeexe
dedeexe / trap.swift
Created November 3, 2016 08:02 — forked from sharplet/trap.swift
Simple signal handling in Swift
import Darwin
enum Signal: Int32 {
case HUP = 1
case INT = 2
case QUIT = 3
case ABRT = 6
case KILL = 9
case ALRM = 14
case TERM = 15
@dedeexe
dedeexe / URLRequest+curlCommand.swift
Last active April 17, 2020 13:08
Convert URL Request to curl command
extension URLRequest {
public func curl(pretty:Bool = false) -> String {
var data : String = ""
let complement = pretty ? "\\\n" : ""
let method = "-X \(self.httpMethod ?? "GET") \(complement)"
let url = "\"" + self.url?.absoluteString ?? "" + "\""
var header = ""
@dedeexe
dedeexe / DeviceLocation.swift
Created October 28, 2017 15:13
Class to get the current device location using Core Location
//
// DeviceLocation.swift
//
// Created by dede.exe on 28/10/17.
// Copyright © 2017 dede.exe. All rights reserved.
//
import Foundation
import CoreLocation
@dedeexe
dedeexe / DatePickerRange.swift
Created October 28, 2017 19:14
Limit picker to not accept a date lesser than today
// DatePicker.swift
// DatePicker Limit
// Author: Dede
// E-mail: [email protected]
import UIKit
import PlaygroundSupport
var str = "Hello, playground"
@dedeexe
dedeexe / Trigger.swift
Created October 29, 2017 21:49
Schedule to execute an action after a delay. If a new execution is scheduled before the old one be executed, it will override the old and a new delay is set.
//
// Trigger.swift
//
// Created by dede.exe on 15/10/17.
// Copyright © 2017 dede.exe. All rights reserved.
//
import Foundation
public class Trigger {
@dedeexe
dedeexe / ios-cell-registration-swift.md
Created October 31, 2017 14:29 — forked from gonzalezreal/ios-cell-registration-swift.md
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
@dedeexe
dedeexe / Serializable.swift
Last active January 26, 2018 13:21
Protocol to encode JSON to Swift object
//
// Serializable.swift
//
// Created by dede.exe on 14/10/17.
// Copyright © 2017 dede.exe. All rights reserved.
//
import Foundation
public protocol Serializable : Codable {
init?(json:String)