Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
@fhferreira
fhferreira / what-forces-layout.md
Created January 26, 2018 21:51 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@fhferreira
fhferreira / gist:4435de6b7bc7e3e2edaecbadaa44a00d
Created January 26, 2018 16:49 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@fhferreira
fhferreira / multi-git.md
Created December 5, 2017 22:38 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer.

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.

@fhferreira
fhferreira / Install-php-mysql-apache-on-osx-with-brew.md
Created August 25, 2017 18:54 — forked from GabLeRoux/Install-php-mysql-apache-on-osx-with-brew.md
Detailed steps to install PHP, MySQL, Apache and some usefull extensions such as xDebug on a mac running Mac Os X. Also included: PostgreSQL.

Install PHP, MySQL, PostgreSQL, Apache and xDebug on a Mac

You should have some tools installed like Homebrew, a text editor such as Sublime Text and it's subl command line app inside a bin folder and some basic terminal knowledge.

This gist is a more detailed version of niepi's gist with things that worked for me. It may help someone :)

Install PHP

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl
@fhferreira
fhferreira / gist:a741f8200cb28d7e3ae27540915d0f8d
Created August 25, 2017 06:40 — forked from bramus/gist:5b4f4733e543912a518f
OS X 10.10 Yosemite, Apache, MySQL, PHP 5.6, (MAMP) Homebrew Dev Setup
# From http://www.iyware.com/osx-yosemite-mamp-homebrew-development-setup/
# Install Homebrew
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
# Tap Repos
brew tap homebrew/dupes
brew tap homebrew/versions
@fhferreira
fhferreira / macosx-install-php-oracle-oci8-pdo_oci.md
Created August 24, 2017 21:08 — forked from rafaelqm/macosx-install-php-oracle-oci8-pdo_oci.md
Install OCI8 and / or PDO_OCI on OSX via Brew

Installation

This procedure is tested on Mac OS X 10.10.5 with Developpers tools installed (xCode).

PHP 5.6 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@fhferreira
fhferreira / ModelUtils.php
Created August 22, 2017 04:05 — forked from edilsoncichon/ModelUtils.php
Utilities for model Eloquent Laravel
<?php
namespace App;
/**
* Class ModelUtils
* Methods and attributes commonly used by application of models.
*
* @package App
*/
from functools import wraps
def hitchhiker(func):
@wraps(func)
def wrapper(*args, **kwargs): return 42
return wrapper
@hitchhiker
def fat(n):
if n < 2: return 1
return n * fat(n-1)
@fhferreira
fhferreira / pi.py
Created July 10, 2017 02:35 — forked from fmasanori/pi.py
Cálculo de Pi
def pi_digits(n):
k, a, b, a1, b1 = 2, 4, 1, 12, 4
while n > 0:
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
d, d1 = a/b, a1/b1
while d == d1:
yield int(d)
n -= 1
a, a1 = 10*(a%b), 10*(a1%b1)
@fhferreira
fhferreira / Thanking_fb.py
Created July 10, 2017 02:30 — forked from fmasanori/Thanking_fb.py
Thanking my 500+ friends who wished me on my birthday on Facebook, by by Akshit Khurana
import requests
import json
AFTER = 1353233754
TOKEN = ' <insert token here> '
#by Akshit Khurana
def get_posts():
"""Returns dictionary of id, first names of people who posted on my wall
between start and end time"""
query = ("SELECT post_id, actor_id, message FROM stream WHERE "