Skip to content

Instantly share code, notes, and snippets.

View tiagobbraga's full-sized avatar
🏠
Working from home

Tiago Braga tiagobbraga

🏠
Working from home
View GitHub Profile
@tiagobbraga
tiagobbraga / steps.md
Last active May 12, 2021 14:58 — forked from travisvalentine/steps.md
Setup Facebook app with firebase authentication to test authentication locally (aka, setting up App Domain)

Note: I had issues with setting up my Facebook app so authentication would work. I'd receive the error at the bottom, and it took me a while to figure out what was wrong

Here are the steps I took:

  • Go to http://developers.facebook.com/, create, and setup your app
  • When inside the dashboard, click "Settings"
  • Click "Add Platform"
  • Choose website (for authentication via the web app)
  • Add http://localhost:3000/ as "Site URL" (and "Mobile URL" if necessary)
  • Add localhost to "App Domains" above

Bundling Design Systems/Component Libraries

First of all you need to decide who will be your target consumers based on the following:

  1. They have the same environment(webpack config, babel config) setup as you where you built your design system(this is mostly possible if you use monorepos/same configs where all the teams share the same environment).

  2. They don't have the same environment which is the case when you work in bigger teams and you want to distribute your design system as any other npm package which is already built and can be used directly.

If your use case falls under case no. 1 then you can just compile the source babel src -d build and leave the bundling to the consumer projects tools(webpack/rollup)

@tiagobbraga
tiagobbraga / Git commands
Last active February 19, 2025 15:12
git-commands
Git clone com específico branch:
$ git clone --branch <branchname> <remote-repo-url>
Remover todos os commits
$ git checkout --orphan latest_branch
$ git add -A
$ git commit -am "mensagem"
$ git branch -D main
$ git branch -m main
$ git push -f origin main
@tiagobbraga
tiagobbraga / scrollview_autoayout.txt
Last active October 27, 2020 18:25
UIScrollView Scrollable Content Size Ambiguity
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
tiagobbraga / cnpj-validator.js
Created July 19, 2017 18:54
CNPJ Validator for jquery form validator (http://www.formvalidator.net/)
$.formUtils.addValidator({
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
tiagobbraga / PHPhotoLibrary+SaveImage
Last active November 27, 2019 01:48 — forked from khorbushko/PHPhotoLibrary+SaveImage
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 2.3 and 3
// SWIFT 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
@tiagobbraga
tiagobbraga / hide-iterm-dock-icon.md
Created May 27, 2017 22:22 — forked from stvhwrd/hide-iterm-dock-icon.md
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/iTerm.app/Contents/Info.plist

####To undo the above:

@tiagobbraga
tiagobbraga / iterm2-solarized.md
Created May 27, 2017 21:51 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@tiagobbraga
tiagobbraga / sizeHeaderFooterToFit.swift
Created October 17, 2016 21:48
sizeHeaderFooterToFit
private func sizeHeaderFooterToFit() {
if let _ = self.tableView.tableHeaderView {
let headerView = self.tableView.tableHeaderView!
headerView.setNeedsLayout()
headerView.layoutIfNeeded()
let heightHeader = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
var frameHeader = headerView.frame
frameHeader.size.height = heightHeader
headerView.frame = frameHeader
self.tableView.tableHeaderView = headerView
@tiagobbraga
tiagobbraga / LOGIN_THE_SAME_FORM_TWO_MODELS.md
Created September 28, 2016 20:07
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.