Skip to content

Instantly share code, notes, and snippets.

View color2life's full-sized avatar

Abdul Wahid color2life

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
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
@lirbank
lirbank / meteor_start.sh
Last active February 21, 2018 13:26
Run Meteor locally with a real hostname instead of localhost
#!/bin/sh
DOMAIN=airlab.io
PORT=3000
# Find configured IPv4 addresses, skip localhost
IP=`ifconfig |grep -oE "(inet )([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"|awk '{print $2}' | grep -v "127.0.0.1"`
echo "Your IP: $IP"
# Replace periods with hyphens
HOSTNAME=`echo $IP | tr '.' '-'`
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@yhsiang
yhsiang / gulpfile.js
Last active July 21, 2018 03:52 — forked from chriskjaer/gulpfile.js
switch node-sass to stylus
var gulp = require('gulp'),
gutil = require('gulp-util'),
stylus = require('gulp-stylus'),
uglify = require('gulp-uglify'),
jade = require('gulp-jade'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
tinylr = require('tiny-lr'),
express = require('express'),
app = express(),
@chriskjaer
chriskjaer / gulpfile.js
Last active November 1, 2017 08:22
Gulp recipe: Jade, Sass, Livereload and static server
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
csso = require('gulp-csso'),
uglify = require('gulp-uglify'),
jade = require('gulp-jade'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'), // Livereload plugin needed: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei
tinylr = require('tiny-lr'),
express = require('express'),
@egaumer
egaumer / controller.js
Created May 14, 2013 11:20
Elasticsearch/AngularJS Pagination Example
$scope.pager = {
pageChange: function(pageNum) {
$scope.search(resultPager.get(pageNum));
},
next: function() {
this.pageChange(resultPager.next());
},
@YannBrrd
YannBrrd / app.js
Last active December 17, 2015 06:49
Pagination using ElasticJS
// app.js
angular.module('cs_demo', [
'controllers',
'elasticjs.service',
'ui.bootstrap'
]);
@color2life
color2life / loop.haml
Created June 13, 2012 09:35
haml loop ror
- 10.upto(20) do |i|
@getify
getify / bench-LABjs-parallel.html
Created May 24, 2011 05:53
comparing LABjs and $script.js when parallel loading with execution order dependencies
<script src="../vendor/lab2.min.js"></script>
<script type="text/javascript">
var start = (+new Date);
// load some scripts dependent on each other (in parallel but preserving execution order)
$LAB
.setOptions({AlwaysPreserveOrder:true})
.script('a.js')
.script('b-needs-a.js')
.script('c-needs-b.js')
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];