Skip to content

Instantly share code, notes, and snippets.

Working from home

Tiago Braga tiagobbraga

Working from home
View GitHub Profile
View git-commands.txt
Git clone com específico branch:
$ git clone --branch <branchname> <remote-repo-url>
Remover um arquivo específico
$ git rm --cached <filename>
Remover todos os arquivos gitignore
$ git rm -r --cached.
$ git add .
$ git commit -m "MESSAGE"
tiagobbraga / scrollview_autoayout.txt
Last active Oct 27, 2020
UIScrollView Scrollable Content Size Ambiguity
View scrollview_autoayout.txt
Xcode 11+
The simplest way using autolayout:
1. Add UIScrollView and pin it 0,0,0,0 to superview (or your desired size)
2. Add UIView in ScrollView, pin it 0,0,0,0 to all 4 sides and center it horizontally and vertically.
3 .In size inspector, change bottom and align center Y priority to 250. (for horizontal scroll change trailing and align center X)
4. Add all views that you need into this view. Don't forget to set the bottom constraint on the lowest view.
5. Select the UIScrollView, select the size inspector and deselect Content Layout Guides.
tiagobbraga / cnpj-validator.js
Created Jul 19, 2017
CNPJ Validator for jquery form validator (
View cnpj-validator.js
name : 'cnpj',
validatorFunction : function(value, $el, config, language, $form) {
value = value.replace(/[^\d]+/g,'');
if(value == '') return false;
if (value.length != 14)
return false;
tiagobbraga / PHPhotoLibrary+SaveImage
Last active Nov 27, 2019 — forked from khorbushko/PHPhotoLibrary+SaveImage
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 2.3 and 3
View PHPhotoLibrary+SaveImage
// SWIFT 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
tiagobbraga /
Created May 27, 2017 — forked from stvhwrd/
Hide the iTerm dock icon on Mac OS X

On my dual-drive MacBook Pro I have remapped the eject key to F13 using Karabiner and NoEjectDelay. The eject key has been assigned as the hotkey for a guake-style visor terminal using iTerm2. Having its own hotkey precludes the need for an icon, so I prefer to hide the iTerm dock icon.

####To hide the dock icon of iTerm2 on Mac OS X:

/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/

####To undo the above:

tiagobbraga /
Created May 27, 2017 — forked from kevin-smets/
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)





View sizeHeaderFooterToFit.swift
private func sizeHeaderFooterToFit() {
if let _ = self.tableView.tableHeaderView {
let headerView = self.tableView.tableHeaderView!
let heightHeader = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
var frameHeader = headerView.frame
frameHeader.size.height = heightHeader
headerView.frame = frameHeader
self.tableView.tableHeaderView = headerView
tiagobbraga /
Created Sep 28, 2016
Unified sign in form for multiple types of Devise users.

An application I'm working on has two different types of Devise users, but I want both types of users to be able to use the same sign in form. Devise doesn't make this easy.

You could argue that I really should have a single user type with a role attribute, but the app is far enough along that I don't want to change that early design decision. It could be changed later if more pain points are discovered.

You could also argue that I shouldn't use Devise, but it's still the de facto authentication standard for Rails applications.

In this example, you can sign in as either a User or an AdminUser. This application only has two types of user, but this example could be extended to support any number of them more gracefully.

View new-profile-eb
# add this lines in ~/.aws/config
aws_access_key_id = xxx
aws_secret_access_key = xxx
# and init
eb init --profile PROFILE_NAME
View kill-process
# show all processes
lsof -wni tcp:3000
# kill process