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 / HotSpot.swift
Last active April 4, 2018 12:10
Changing App Wifi
import Foundation
import NetworkExtension
import SystemConfiguration.CaptiveNetwork
public enum HotSpotError : Error, LocalizedError {
case featureNotSupported
public var localizedDescription: String {
return "This feature is available only for iOS 11 or later."
}
@dedeexe
dedeexe / TimeCounter.swift
Created April 3, 2018 01:35
Time Counter
struct TimeCounter {
private var lastTime : Date?
private(set) var counters : Int = 0
private(set) var passedTime : TimeInterval = 0.0
mutating func add() {
guard let previousTime = lastTime else {
lastTime = Date()
counters += 1
return
@dedeexe
dedeexe / twomb
Created February 28, 2018 19:37
Just a 2Mb of X characters
This file has been truncated, but you can view the full file.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@dedeexe
dedeexe / Directory.swift
Last active February 21, 2018 21:14
Class to navigate and handle directories.
//
// Directory.swift
// BackgroundApp
//
// Created by dede.exe on 21/02/18.
// Copyright © 2018 dede.exe. All rights reserved.
//
struct Directory {
@dedeexe
dedeexe / CPF.swift
Created December 30, 2017 12:53
Validate CPF and Create CPF digits
//
// CPF.swift
//
// Created by dede.exe on 30/12/17.
// Copyright © 2017 dede.exe. All rights reserved.
//
import Foundation
///
@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)
@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 / 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 / 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: dede.exe@gmail.com
import UIKit
import PlaygroundSupport
var str = "Hello, playground"
@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