Skip to content

Instantly share code, notes, and snippets.

View antonyalkmim's full-sized avatar

Antony Alkmim antonyalkmim

View GitHub Profile
@antonyalkmim
antonyalkmim / gist:462abefc914a0db40ca1f384755819c3
Created November 12, 2019 12:11 — forked from steipete/ios-xcode-device-support.sh
Using iOS 13.2 devices with Xcode 11.1 (instead of Xcode 11.2) (also, Xcode 10.3)
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
// Support iOS 13.2 devices (Xcode 11.2) with Xcode 11.1:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/13.2 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Xcode 10.3 to Xcode 11
sudo ln -s /Applications/Xcode-11.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/13.0 /Applications/Xcode-10.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
@antonyalkmim
antonyalkmim / SwipeableCell.swift
Created July 12, 2018 19:18
Swipeable UITableViewCell where you can use custom view behind cell.contentView
//
// SwipeableCell.swift
// Antony Alkmim
//
// Created by Antony Alkmim on 09/07/18.
// Inspired by: https://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views
//
import UIKit
import PINRemoteImage
@antonyalkmim
antonyalkmim / UIViewController+UITextfield.swift
Last active October 17, 2018 08:48
iOS UIViewController extension to fix keyboard overriding textfield
//
// UIViewController+ext.swift
// Antony Alkmim
//
// Created by Antony Alkmim on 03/07/18.
// Copyright © 2018 Antony Alkmim. All rights reserved.
//
import UIKit
infix operator ?!: NilCoalescingPrecedence
@_transparent
public func ?!<T: OptionalType>(value: T, error: @autoclosure () -> Error) throws -> T.ValueType {
if let value = value.optionalValue { return value }
throw error()
}
@antonyalkmim
antonyalkmim / CPFnCNPJUtils.js
Created May 29, 2018 14:22
Script javascript para verificar se CPF e CNPJ são válidos.
const calcularDigito = (str, peso) => {
var soma = 0;
var indice = str.length - 1;
var digito;
while (indice >= 0) {
digito = parseInt(str.substring(indice, indice + 1));
soma += digito * peso[peso.length - str.length + indice];
indice--
@antonyalkmim
antonyalkmim / AppActivity.kt
Created April 9, 2018 17:53
Simple Android Fingerprint authentication dialog
package com.myapp.app.ui.auth
import android.os.Build
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.support.v7.app.AppCompatActivity
import android.view.Gravity
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
@antonyalkmim
antonyalkmim / UserDefaultsService.swift
Created March 22, 2018 13:46
UserDefaults Mockable
import Foundation
protocol UserDefaultsDelegate: class {
func theObject(forKey key: String) -> Any?
func setTheObject(_ object: Any, forKey key: String)
func removeTheObject(forKey key: String)
func synchronizeAll()
}
class UserDefaultsService: NSObject {
@antonyalkmim
antonyalkmim / HttpService+Rx.swift
Last active November 24, 2022 21:42
A URLSession approach to organize Network layer
import Foundation
import RxSwift
extension HttpService: ReactiveCompatible { }
extension Reactive where Base: HttpServiceType {
func request(_ endpoint: Base.Target) -> Single<Data> {
return Single<Data>.create(subscribe: { [weak base] single in
let task = base?.request(endpoint, responseData: { result in
@antonyalkmim
antonyalkmim / Billit.swift
Created January 30, 2018 10:57
Classe para identificar informacoes do boleto a partir do codigo de barras ou linha digitavel
//
// Billit.swift
// antonyalkmim
//
// Implementacao da classe boleto para identificar valor, data de vencimento e linha digitavel a partir de um codigo de barras
// ou identificar valor e data de vencimento a partir de uma linha digitavel.
// Todas as regras implementadas seguem a documentacao da FEBRABRAN (https://cmsportal.febraban.org.br/Arquivos/documentos/PDF/Layout%20-%20C%C3%B3digo%20de%20Barras%20-%20Vers%C3%A3o%205%20-%2001_08_2016.pdf)
//
// Created by Antony Alkmim on 26/01/18.
//
@antonyalkmim
antonyalkmim / .swiftlint.yml
Created September 19, 2017 17:08
Swift Lint Rules
opt_in_rules: # some rules are only opt-in
# - missing_docs
- attributes
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- explicit_top_level_acl
- extension_access_modifier
- fatal_error_message