Skip to content

Instantly share code, notes, and snippets.

(function() {
if (!('visibilityState' in document)) {
return false;
}
// rest of your code
}());
@varmais
varmais / thinced.js
Created October 1, 2015 19:43
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
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
@geerteltink
geerteltink / gulpfile.js
Created March 10, 2015 08:18
NPM scripts VS gulp.js
var gulp = require('gulp');
var cp = require('child_process');
var del = require('del');
var concat = require('gulp-concat');
var shell = require('gulp-shell');
var express = require('express');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var less = require('gulp-less');
@cfarm
cfarm / github-flow.md
Last active August 29, 2015 14:03
Github Flow

Workflow for Git and Github

  1. Create a new branch from master:

  2. git checkout master or git status to confirm you're working on master

  3. git branch my-new-branch

  4. Check out the new branch!!!

git checkout my-new-branch

@mkchandler
mkchandler / Setting up SourceGear DiffMerge for Git.md
Last active January 13, 2022 10:44
Setup guide for making Git recognize and use SourceGear DiffMerge.
  1. Download SourceGear DiffMerge: http://sourcegear.com/diffmerge/index.html

  2. Add the following to your global .gitconfig file:

     [diff]
         tool = DiffMerge
     [difftool "DiffMerge"]
         cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' "$LOCAL" "$REMOTE"
     [merge]
    

tool = DiffMerge

@kleinmatic
kleinmatic / propubnerd-gists.md
Created March 26, 2012 16:03
ProPubNerd Gists

Open Source code doesn’t always come in big complex packages. At ProPublica we sometimes share small, simple snippets of using GitHub "Gists." These Gists range from single-byte file delimiters to an entire JavaScript framework for making stepper graphics. They rarely have documentation and don’t even always have names, but they can be super-useful. Here are some we’ve shared over the past few years:

@trepmal
trepmal / notepad.js
Created November 16, 2011 21:35
WordPress: Front-end editable notepad
jQuery(document).ready(function($) {
$('#notepad').click(function(e) {
tag = e.target.tagName;
if ( tag != 'TEXTAREA' && tag != 'INPUT' ) {
contents = $(this).html();
$(this).html( '<textarea style="display:block;width:98%;height:100px;">' + contents + '</textarea><input type="submit" class="save" style="position:relative;z-index:99" />' );
}
});
$('#notepad input.save').live( 'click', function() {
# custom login link
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L]