Skip to content

Instantly share code, notes, and snippets.

View jpvincent's full-sized avatar

Jean-Pierre Vincent jpvincent

View GitHub Profile
@jpvincent
jpvincent / gist:4034445
Created November 7, 2012 21:04
Stage d’expertise technique Web - 2013

Jean-pierre VINCENT, consultant et expert technique Web cherche son stagiaire

Le candidat

Si vous pensez que :

  • le web, ça rox.
  • HTML5, CSS3 et javascript dominent déjà le monde.
  • vous voudriez faire un grand bond en avant dans ces technos.
  • chef de projet ou manager ça n’est pas l’aboutissement d’une carrière de développeur.
  • le grand écart IE7 - Chrome et mobiles est possible.
function makeMochaToBrowserScopeCallback ( testKey, sandboxid) {
'use strict';
return function mochaToBrowserScopeCallback () {
var sendToBenchmark = {};
console.log( mocha.globals('runner').suite );
function applatir (suite) {
// extraction des résultats des tests
var title;
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Jean-Pierre subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="innovation" title="innovation">
<outline type="rss" text="Pl4n3s world" title="Pl4n3s world" xmlUrl="http://pl4n3.blogspot.com/feeds/posts/default?alt=rss" htmlUrl="http://pl4n3.blogspot.com/"/>
<outline type="rss" text="Mozilla Hacks - the Web developer blog" title="Mozilla Hacks - the Web developer blog" xmlUrl="http://hacks.mozilla.org/feed/" htmlUrl="https://hacks.mozilla.org"/>
{
"eqeqeq": true,
"undef": true,
"unused": true,
"trailing": true,
"maxdepth": 3,
"debug": true,
"eqnull": true,
"esnext": true,
"loopfunc": true,
{
"eqeqeq": true, // This options prohibits the use of == and != in favor of === and !==.
"noarg": true, // This option prohibits the use of arguments.caller and arguments.callee
"undef": true, // This option prohibits the use of explicitly undeclared variables
"unused": true, // This option warns when you define and never use your variables
"trailing": true, // This option makes it an error to leave a trailing whitespace in your code
"maxdepth": 3,
"camelCase": true,
"curly": true, // This option requires you to always put curly braces around blocks in loops and conditionals
"immed": true, // This option prohibits the use of immediate function invocations without wrapping them in parentheses
@jpvincent
jpvincent / optimizedFor.js
Last active November 25, 2021 17:12
never blocking loop mechanism, using setTimeout 0 trick and time control to break the loop and let the browser breath
/**
* NEVER BLOCKING LOOP : implementation of the infamous setTimeout 0 hack, with time checking in order to guarantee fluidity without sacrificing execution speed.
*
* USAGE :
* var array = ["a way too big array that is heavy to process"]
* optimizeFor({
* nbIterations: array.length,
* each:function( index ) {
* doSomethingUsefulWith( array[ index ] );
* },
var namespace = window;
// Font Loader
namespace.loadFont = function(familyName, fileName, callback) {
var pathToFonts = 'Content/fonts/';
function applyFont() {
var css = '@font-face { font-family: "' + familyName + '";\
src: url("'+pathToFonts+ fileName + '.eot");\
src: url("'+pathToFonts+ fileName + '.eot?#iefix") format("embedded-opentype"),\
url("'+pathToFonts+ fileName + '.woff2") format("woff2"),\
@jpvincent
jpvincent / multiple-spof-check.js
Created October 28, 2016 15:23
Compile and sort multiple runs of spofcheck. Display scores in CLI
// Warning : the original spofcheck works with an old version of Node. 0.10.36 did it for me.
// npm install spofcheck before
// For CLI display only : the original spofcheck could also generate a junit.xml file to be used in continuous integration
const spofcheck = require('spofcheck')
const url = require('url')
const Table = require('cli-table')
const URLs = [
'http://www.vanityfair.fr/',
// 'http://www.vanityfair.fr/video',
@jpvincent
jpvincent / inclusion-asynchrone.js
Created October 28, 2016 18:18
inclusion asynchrone de JS prenant en compte IE < 10 et ne ralentissant pas le body.onload
// Pour rappel, voici la manière de faire de GA
/*(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
*/
// C'est compatible partout et asynchrone, mais dans le cas de IE < 10, si le script est déclenché trop tôt, il ralentit window.onload
// Il faut donc juste écouter window.onload et déclencher ce script en asynchrone, quitte à le ralentir
function includeGa(){
@jpvincent
jpvincent / proposition syntaxe Jest — webdriver.js
Created December 29, 2017 14:54
Jest marche bien avec Webdriver, mais la syntaxe peut être lourde. On pourrait étendre l'assert de Jest pour intégrer les appels webdriver
// actuellement
expect(await browser.isSelected('[name=CustomClearanceRadios]'))
.toBe(true)
// proposition
expect.el('[name=CustomClearanceRadios]')
.toBeSelected()
// actuellement
expect(await browser.getValue('#ShipperEmail'))
.toBe('jp@made.this')