Skip to content

Instantly share code, notes, and snippets.

View fabien-d's full-sized avatar

Fabien Doiron fabien-d

View GitHub Profile
@fabien-d
fabien-d / github.pr.toggle.file.extension.js
Last active May 14, 2018 17:58
Filter GitHub pull request changed files by extension
/**
* Prompt and filter a PR's changed files by the given extension(s).
*/
var els=document.getElementsByClassName('user-select-contain');
var input = prompt('File extension(s), comma separated');
els = [].forEach.call(els, function(el) {
var parent = el;
while (parent && !parent.classList.contains('js-details-container')) {
@fabien-d
fabien-d / Object.assign.js
Created September 22, 2015 16:27
Nested Object.assign calls formatting
let object = {
key: {
subkey: 'value',
status: 'STATUS'
}
};
// compact
Object.assign( {}, object, { key: Object.assign( {}, object.key, { status: 'PENDING' } ) } );
@fabien-d
fabien-d / bookmarklet.js
Created February 18, 2015 16:53
WorkshopX GitHub pull request bookmarklet
javascript:(function(){document.getElementById('pull_request_body').value='#### What does this PR do?\n#### Todos:\n#### What are the dependent PRs?\n#### How should this be manually tested?\n#### Any background context you want to provide?\n#### What are the relevant stories?\n#### Screenshots (if appropriate)\n#### Questions:'}())
@fabien-d
fabien-d / fabric-node-canvas.js
Created October 17, 2014 15:31
Fabric and Node Canvas Rendering Tests
var fs = require( 'fs' );
var fabric = require( 'fabric' ).fabric;
var out = fs.createWriteStream( __dirname + '/node-canvas-fabric.png' );
var canvas = fabric.createCanvasForNode( 500, 500 );
canvas.add( new fabric.Text( 'Lorem ipsum', {
fontFamily: 'sans-serif',
fontSize: 50,
left: 250,
top: 250,
@fabien-d
fabien-d / sample.js
Created July 10, 2014 18:37
Unit tests - Conditional
// self invoking function will run on page load
// looking for a way to rerun (reload) the script before each test
( function myFunction () {
'use strict';
if ( condition ) {
// something
} else {
// something else
}
@fabien-d
fabien-d / JS-module-example.html
Last active December 27, 2015 04:29
simplified example of an unobtrusive JS module approach -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Module approach</title>
<meta name="description" content="">
</head>
<body>
<div data-module="myModule">
<a href="#">Link</a>
@fabien-d
fabien-d / grunt-static-versioning-usage.md
Last active December 26, 2015 14:19
Quick setup of the grunt-static-versioning plugin
@fabien-d
fabien-d / _debugVAlignment.scss
Created October 15, 2013 13:18
SASS mixin for vertical alignment debugging
/**
* Inspired from http://basehold.it
*
* Should only be used for debugging vertical alignment and on <body> tag.
*
* @example
* body.debug {
* @include debugVAlignment();
* }
*/
@fabien-d
fabien-d / _position.scss
Last active June 8, 2018 14:22
SASS mixin for shorthand position value. Only outputs the value specified. Usage `@include position( TOP, RIGHT, BOTTOM, LEFT );`
@mixin position( $top: null, $right: null, $bottom: null, $left: null ) {
@if $top { top: $top; }
@if $right { right: $right; }
@if $bottom { bottom: $bottom; }
@if $left { left: $left; }
}