Skip to content

Instantly share code, notes, and snippets.

@RxDx
RxDx / playground.swift
Created October 10, 2019 23:51
SwiftUI @ Playground
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
Text("Hello World")
}
}
let host = UIHostingController(rootView: ContentView())
//
// RestAPI.swift
// RestAPI
//
// Created by Rodrigo Dumont on 25/04/18.
//
open class RestAPI<T: Codable> {
public typealias Then = (T?, Error?) -> ()
@RxDx
RxDx / Theme.swift
Created December 19, 2017 10:04
iOS Theme
import UIKit
enum Theme {
case light
case dark
}
extension Theme {
var defaultTextColor: UIColor {
switch self {
@RxDx
RxDx / MacOSLogoutHook.txt
Last active September 21, 2023 23:50
MacOS: Run script before shutdown
Create a file:
$ pico /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set exuction permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
// MARK: - String mask
class Mask {
class func maskCep(CepString: String?) -> String {
guard let CepString = CepString else {
return ""
}
var text = CepString.replacingOccurrences(of: "-", with: "")
@RxDx
RxDx / BaseRepository.swift
Last active August 4, 2017 23:24
BaseRepository Swift
//
// BaseRepository.swift
//
// Created by Rodrigo Dumont on 7/4/16.
// Copyright © 2016 Rodrigo Dumont. All rights reserved.
//
import Alamofire
import SwiftyJSON
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardWillShow), name:UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(keyboardWillHide), name:UIKeyboardWillHideNotification, object: nil)
func keyboardWillShow(notification:NSNotification){
var userInfo = notification.userInfo!
var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).CGRectValue()
keyboardFrame = self.view.convertRect(keyboardFrame, fromView: nil)
var contentInset:UIEdgeInsets = self.scrollView.contentInset
@RxDx
RxDx / android_codes
Created February 6, 2015 19:16
Android Codes
Codes
*#*#4636#*#* — Exibe informações do telefone, bateria e estatísticas de uso;
*#*#7780#*#* — Restaura o aparelho para os padrões de fábrica, apagando aplicativos e dados;
*2767*3855# — Reinstala o firmware do dispositivo;
*#*#34971539#*#* — Apresenta informações detalhadas da câmera;
*#*#7594#*#* — Altera o comportamento do botão liga/desliga, permitindo que o eletrônico seja desligando com um único pressionamento;
*#*#273283*255*663282*#*#* — Realiza um backup rápido de todos os arquivos de mídia;
*#*#197328640#*#* — Habilita o modo de teste;
*#*#232339#*#* ou *#*#526#*#* — Executa um teste da conectividade sem fio LAN