Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / colors.sh
Last active January 15, 2016 09:47 — forked from cyrilis/colors.sh
A ImageMagick Script Can Generate Color Palettes JSON Format.Usage: ./colors.sh IMAGE-PATH COLOR-NUMBERS eg: ./colors.sh /Users/Cyril/Downloads/photo2.jpg 10
dir="." #Set the default temp dir
tmpA1="$dir/spectrumhist_1_$$.png"
tmpB1="$dir/spectrumhist_1_$$.cache"
trap "rm -f $tmpA1 $tmpB1; exit 0" 0 #remove temp files
trap "rm -f $tmpA1 $tmpB1; exit 1" 1 2 3 15 #remove temp files
if [ $# -eq 2 ]
then
colors=$2
else
colors=8
@lotabout
lotabout / what-forces-layout.md
Created August 10, 2016 03:25 — 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()