Skip to content

Instantly share code, notes, and snippets.

View alexgibson's full-sized avatar
🍄
1UP

Alex Gibson alexgibson

🍄
1UP
View GitHub Profile
@scottjehl
scottjehl / inert-unert.js
Created August 5, 2020 21:28
inert-unert.js: a quick utility for applying or removing the inert property
// inert-unert.js: a quick utility for applying or removing the inert property
// - @scottjehl, @filamentgroup
// (note: inert support polyfill is still needed in some browsers)
// usage:
// when a modal element such as a dialog is active,
// this function will make unrelated elements inert, aiming to affect as few as possible
// example: inert( document.querySelector(".modal-open") );
function inert( allButThisElement ){
function inertSiblings( node ){
if( node.parentNode ){
@davehunt
davehunt / conftest.py
Created January 17, 2017 16:33
Enable trace logging for GeckoDriver
@pytest.fixture
def firefox_options(firefox_options):
firefox_options.log.level = 'trace'
return firefox_options
@jpetto
jpetto / optimizely-review-checklist.md
Last active March 26, 2020 22:21
Checklist for reviewing & starting Optimizely experiments

Optimizely Review Checklist

Experiment

  • URL targeting
  • Variation redirects
  • Variation code
  • Audience
  • Traffic allocation
  • Goal(s)
@bendc
bendc / functional-utils.js
Last active September 15, 2023 12:12
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
var Dialog = React.createClass({
render: function() {
// 1) render nothing, this way the DOM diff will never try to do
// anything to it again, and we get a node to mess with
return React.DOM.div();
},
componentDidMount: function() {
// 2) do DOM lib stuff
this.node = this.getDOMNode();
@Integralist
Integralist / RTL.md
Created November 1, 2013 18:42
BBC News' RTL (right to left) solution

Right-to-Left (RTL)

Implementation

There are two methods to use in order to flip CSS styles: interpolated properties and the flip() function.

  • Interpolation should be used for any property which has a direction (e.g. padding-left, margin-right, border-right, left, etc.)
  • flip() should be used for all other properties

Which properties need to be flipped?

@WebReflection
WebReflection / find-or-fallback.js
Created July 17, 2013 06:19
a very simple and cross platform way to grab some experimental function
function findOrFallback(where, what, fallback) {
for(var
vendors = ['', 'webkit', 'moz', 'ms', 'o'],
first = what.charAt(0),
others = first.toUpperCase(),
suffix = what.slice(1),
i = 0, length = vendors.length,
current;
i < length; i++
) {
@cobyism
cobyism / gh-pages-deploy.md
Last active July 18, 2024 05:22
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@paulirish
paulirish / gist:3910471
Created October 18, 2012 08:33
page visibility API : tribulations with prefixes
// this is the least sucky way i could think of to
// detect and deal with a cross-browser impl of the page visibility api
// forks welcome.
function getHiddenProp(){
var prefixes = ['webkit','moz','ms','o'];
if ('hidden' in document) return 'hidden';
@lorenzopolidori
lorenzopolidori / has3d.js
Last active December 4, 2020 10:52 — forked from webinista/has3d.js
Testing for CSS 3D Transforms Support
function has3d(){
if (!window.getComputedStyle) {
return false;
}
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',