Skip to content

Instantly share code, notes, and snippets.

View lscoder's full-sized avatar

Leonardo Campos lscoder

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active July 22, 2024 06:32
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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@igorlima
igorlima / README.md
Last active August 29, 2015 14:16
Get started with Saucie CLI and make easier cross browser testing

Gittip Donate Button

You probably know that to do JavaScript testing is good and one of hurdles to overcome is how to test our code on different browsers. There’re some tools availables for helping us on hurdling this overcome. One of them is a CLI (command line) named saucie developed by igorlima. This CLI is a library hosted on NPM which allows integrate your frontend JavaScript tests with SauceLabs platform. SauceLabs makes awesome cross browser testing, and saucie makes easier that cross browser testing by CLI.

A great interactive JS Test Runner, the testem library, uses saucie on its examples and has the fo

@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

@gregoriokusowski
gregoriokusowski / gist:4634474
Created January 25, 2013 13:32
Since we started to use a branching model to control every stuff we send to production, we use the interactive rebase into a temp branch in order choose commits, keep their reference and check the code before check it to the stable branch.
git checkout master
git checkout -b temp
git rebase -i stable
# Time to select/remove/squash commits
git checkout stable
git pull . temp
git branch -d temp
@joshdholtz
joshdholtz / SomeFragment.java
Last active December 22, 2022 09:41
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@mateusfreira
mateusfreira / gist:3781896
Created September 25, 2012 13:33
Dado um vetor com 'n' números distintos, calcular quantas possibilidades existem para se obter a soma 's'
def countSum(numbers: List[Int], expectedResult: Int): Int = {
countSumRecursively(numbers, 0, expectedResult);
}
def countSumRecursively(numbers: List[Int], currentResult: Int, expectedResult: Int): Int = {
if (currentResult == expectedResult)
1
else if ((currentResult > expectedResult) || (numbers.isEmpty))
0
else