Skip to content

Instantly share code, notes, and snippets.

@theffc
theffc / KeyboardSizeManager.swift
Created November 7, 2021 20:50
KeyboardSizeManager - Swift class to help adjust UI when the keyboard appears and disappears
import Foundation
import UIKit
final class KeyboardSizeManager {
private weak var bottomConstraint: NSLayoutConstraint?
private var oldValue: CGFloat
@theffc
theffc / SubviewComparison.swift
Last active March 1, 2021 17:06
A comparison between UIKit default `addSubview` method, and a function builder approach
// Antes
view.addSubview(title)
view.addSubview(stackHorizontal)
stackHorizontal.addArrangedSubview(icon)
stackHorizontal.addArrangedSubview(text)
view.addSubview(description)
view.addSubview(button)
// Depois
view.subviews {
@theffc
theffc / UIView+Subviews.swift
Last active February 28, 2021 17:14
This is an extension on UIViews that make it possible to add subviews in a more declarative/hierarchical way.
import UIKit
public extension UIView {
@discardableResult
func subviews(@SubviewsBuilder _ subviews: () -> [UIView]) -> UIView {
subviews().forEach { self.customAddSubview($0) }
return self
}
function fish_prompt
# This prompt shows:
# - green lines if the last return command is OK, red otherwise
# - your user name, in red if root or yellow otherwise
# - your hostname, in cyan if ssh or blue otherwise
# - the current path (with prompt_pwd)
# - date +%X
# - the current virtual environment, if any
# - the current git status, if any, with fish_git_prompt
# - the current battery state, if any, and if your power cable is unplugged, and if you have "acpi"
@theffc
theffc / git-aliases.txt
Last active July 21, 2020 19:32
Git aliases
alias.st = status -s -b -u
alias.lg = log --graph --format=format:'%C(blue)%h%C(auto)%d %s %C(bold black)(%ar) %an'
@theffc
theffc / git-proxy.md
Last active May 2, 2024 19:33
Como configurar o git para funcionar com um servidor proxy.

Ativar

Para fazer o git usar um servidor proxy, utilize o seguinte comando:

git config --global http.proxy http://YOUR_PROXY_USERNAME:YOUR_PROXY_PASSWORD@YOUR.PROXY.SERVER:8080

YOUR_PROXY_USERNAME => como é comum o uso de um email para o USERNAME, é necessário utilizar no lugar do @ do email, o seguinte código pwd%40123.

Desativar

@theffc
theffc / typedefs.md
Created November 26, 2015 00:04
This is an edited piece of Linux Coding Style that shows why and when you should use typedefs.

Typedefs

It's a mistake to use typedef for structures and pointers. When you see a

vps_t a;

in the source, what does it mean?

In contrast, if it says