Skip to content

Instantly share code, notes, and snippets.

View portellaa's full-sized avatar
🚂
puuuuu puuuuu

Luís Portela Afonso portellaa

🚂
puuuuu puuuuu
View GitHub Profile
@portellaa
portellaa / managed_certificate.md
Last active September 17, 2024 15:49 — forked from fdelu/managed_certificate.md
Managed certificate creation with terraform - Azure Container Apps

variables.tf

variable "env" {
  description = "Environment"
  default     = "dev"
}

variable "app_name" {
  description = "Application name"

Keybase proof

I hereby claim:

  • I am portellaa on github.
  • I am portellaa (https://keybase.io/portellaa) on keybase.
  • I have a public key ASDWp0iRsyw7s9yzpqYrJZtf7YbTbLikuKDfDw_HnSF88wo

To claim this, I am signing this object:

@portellaa
portellaa / swiftaveiro-signalproducer-doitright.swift
Created June 2, 2017 09:45
SwiftAveiro - ReactiveSwift - Do It Right 😎
func timeToDoItCorrectly() {
let generator = TimeBasedFibonacciGenerator()
// You have this both, feel free to use the one suits you best 🤔
// let signal = generator.signal
let producer = generator.producer
let result = producer
.take(first: N)
@portellaa
portellaa / Service🔎.swift
Last active December 16, 2016 02:30
Service 🔎 with lazy capabilities
//: Playground - noun: a place where people can play
import Foundation
typealias LazyServiceClosure<Service> = () -> (Service)
enum ServiceLocatorError: Error {
case duplicateService(String)
case inexistentService
case serviceTypeMismatch
@portellaa
portellaa / 💩⌛️.swift
Last active November 25, 2016 16:01
💩⌛️ example
extension DateFormatter {
private enum DateFormatters {
static var yearMonthDayFormat: String = "yyyy%@MM%@dd"
static var dayMonthYearFormat: String = "dd%@MM%@yyyy"
static var chatDateFormat: String = "EEEE d'%@' MMMM"
static var yearMonthDayFormatters: [Separator : DateFormatter] = [:]
static var dayMonthYearFormatters: [Separator : DateFormatter] = [:]
static var dateFormatters: [String : DateFormatter] = [:]
@portellaa
portellaa / TableViewHeaderProtocol.swift
Created November 22, 2016 16:11
improved `cellForIndexPath` for UICollectionView and UITableView
protocol TableViewHeaderProtocol: ViewCellReuseIdentifier {
init()
func setupLayout()
}
extension TableViewHeaderProtocol where Self: UITableViewHeaderFooterView {
init() {
self.init(reuseIdentifier: Self.reuseIdentifier)
@portellaa
portellaa / xcode_clear_sims_list.sh
Last active November 21, 2016 22:22
Remove all simulators from xcode devices list
xcrun simctl list devices | egrep -o '([A-F0-9]+-){4}[A-F0-9]+' | xargs -I 📱 xcrun simctl delete 📱
@portellaa
portellaa / Default (OSX).sublime-keymap
Last active March 26, 2024 09:06 — forked from lmdemanuel/Default (OSX).sublime-keymap
Sublime Text 3 - User keybindings "a la Xcode"
[
{ "keys": ["super+0"], "command": "toggle_side_bar" },
{ "keys": ["super+shift+o"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+shift+y"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{
"keys": ["super+enter"],
"command": "set_layout",
"args":
{
"cols": [0.0, 1.0],
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten

This gist outlines how to resize a view when a keyboard appears using Auto Layout (there are a bunch of code samples out there that manually adjust the view's frame, but that's just so 2013). The method I outline below works universally on both iPhone and iPad, portrait and landscape, and is pretty darn simple.

Setting Up

The first thing to do is to define our containing view controller, the view, and the bottom constraint that we'll use to adjust its size.

Here's HeightAdjustingViewController.h. We don't need to expose any public properties, so it's pretty bare.