Skip to content

Instantly share code, notes, and snippets.

View runys's full-sized avatar

Tiago Pereira runys

View GitHub Profile
@runys
runys / reta.cpp
Last active August 29, 2015 14:07
Estudo da reta
#include <iostream>
#include <cmath>
#include <cstdio>
#define DIREITA -1
#define ESQUERDA 1
#define SOBRE 0
using namespace std;
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@runys
runys / activity-indicator.swift
Last active April 18, 2019 14:45
Activity indicator in iOS 11 with Swift 4
// Create the Activity Indicator
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray)
// Add it to the view where you want it to appear
view.addSubview(activityIndicator)
// Set up its size (the super view bounds usually)
activityIndicator.frame = view.bounds
// Start the loading animation
activityIndicator.startAnimating()
@runys
runys / search-controller.swift
Last active September 27, 2018 14:47
Search Controller in Table View Controller in iOS 11 with Swift 4. From: https://www.raywenderlich.com/113772/uisearchcontroller-tutorial
// The code bellow must be written in your Table View Controller
// Remember to use your own classes and properties when creating your own search.
// 1. Create a new property in your class
// The Search Controller is the responsible to do the "searching magic"
let searchController = UISearchController(searchResultsController: nil)
// 2. At the viewDidLoad() add those initializations
searchController.searchResultsUpdater = self // You will get an error here for now, but it will vanish at step number 5
searchController.dimsBackgroundDuringPresentation = false
@runys
runys / alert.swift
Last active December 20, 2017 09:54
Simples alert for iOS 11 with Swift 4.
// 1. Creating the AlertController
let alert: UIAlertController = UIAlertController(title: "Teste",
message: "Aprendendo a fazer alertas",
preferredStyle: .alert)
// 1.1. Create the actions
let okAction = UIAlertAction(title: "OK", style: .default) { (okAction) in
// Insert here the code to be executed when the user select the action
print("O usuário escolheu: \(okAction.title!)")
}
@runys
runys / local-notification.swift
Last active May 9, 2017 14:32
Simple local notification in swift for iOS 10 with Swift 3
// Referencias
// - https://www.appcoda.com/ios10-user-notifications-guide/
// - http://useyourloaf.com/blog/local-notifications-with-ios-10/
// - https://makeapppie.com/2016/08/08/how-to-make-local-notifications-in-ios-10/
// - https://developer.apple.com/reference/usernotifications
//: Local notifications
// 1. Importe o framework UserNotifications
import UserNotifications
@runys
runys / dismiss-keyboard.swift
Created December 27, 2016 14:48
How to dismiss the keyboard in iOS 10 with Swift 3.
// Dissmiss keyboard iOS
// Referências
// - http://stackoverflow.com/questions/18755410/how-to-dismiss-keyboard-ios-programmatically
// Existem algumas formas de esconder o teclado no iOS
// Aqui vamos ver algumas delas!
// 1. Implementando o UITextFieldDelegate e quando o usuário
// apertar no RETURN do teclado, terminamos a edição.
@runys
runys / image-picker.swift
Created January 9, 2017 18:57
Simple Camera and Picture Library Tutorial using iOS 10 and Swift 3.
/*:
Simples tutorial sobre como utilizar a Camera e a Biblioteca de fotos para capturar imagens e utilizá-las em seu aplicativo
Referências:
- https://makeapppie.com/2016/06/28/how-to-use-uiimagepickercontroller-for-a-camera-and-photo-library-in-swift-3-0/
- https://turbofuture.com/cell-phones/Access-Photo-Camera-and-Library-in-Swift
Antes de qualquer coisa, precisamos pedir autorização do usuário para acessarmos a camera e a biblioteca de fotos.
Para isso vá no info.plist e adicione as seguintes chaves:
@runys
runys / date-and-time.swift
Created February 13, 2017 18:41
Ways to work with date and time in iOS 10 and Swift 3.
// 1. Como transformar Date em String?
let today = Date()
// 1: Criamos um NSDateFormatter
let dateFormatter = DateFormatter()
// 2: Definimos o formato da data
dateFormatter.dateFormat = "EEE, dd MMM yyy hh:mm:ss +zzzz"
@runys
runys / page-view-controller.swift
Created March 8, 2017 13:48
Tutorial about how to create a simple page view application in iOS 10 with Swift 3. Originally create to be seen in a playground.
/*:
## Tutorial de UIPageViewController
Referências:
- [How to Use UIPageViewController in Swift 2.2](https://spin.atomicobject.com/2015/12/23/swift-uipageviewcontroller-tutorial/)
- [How to Move Page Dots in a UIPageViewController with Delegation](https://spin.atomicobject.com/2016/02/11/move-uipageviewcontroller-dots/)
- [](https://developer.apple.com/reference/uikit/uipageviewcontroller)
- [](https://developer.apple.com/reference/uikit/uipageviewcontrollerdatasource)
- [](https://developer.apple.com/reference/uikit/uipageviewcontrollerdelegate)