Skip to content

Instantly share code, notes, and snippets.

View nfroidure's full-sized avatar
🌻
Getting greener

Nicolas Froidure nfroidure

🌻
Getting greener
View GitHub Profile
const noop = arg => arg;
const combine = () => Array.from(arguments).reduce((a, b) => a.concat(b));
const compact = arr => arr.filter(el => el);
const difference = () => {
var others = Array.from(arguments).slice(1).reduce((a, b) => a.concat(b));
return arguments[0].filter(el => !others.some(exclude => el === exclude));
};
@nfroidure
nfroidure / gist:8e07426a2bc9ff65dee5
Created December 11, 2014 13:23
Mixins mess in
var Mixin = require('Mixin');
var Mixin1 = require('Mixin1');
var Mixin2 = require('Mixin2');
var Mixin3 = require('Mixin3');
function MyCtor() {
}
Mixin.set(myCtor, Mixin1, Mixin2, Mixin3);
@nfroidure
nfroidure / xbbcode2xhtml.js
Last active August 29, 2015 14:09
Convert XBBCodes to XHTML
module.exports = function xbbcode2html(str, options) {
var all = options.all || false;
var cleanup = options.cleanup || false;
var secure = options.secure || false;
var tags = [
'span', 'kbd', 'var', 'del', 'ins', 'div', 'strong', 'em', 'dfn', 'cite',
'q', 'blockquote', 'p', 'br', 'a', 'ol', 'ul', 'li', 'abbr', 'acronym',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'pre', 'address', 'img', 'tr',
'th', 'td', 'table', 'caption', 'thead', 'tfoot', 'tbody', 'dl', 'dd', 'dt',
'map', 'area', 'code', 'samp', 'sub', 'sup'
'use strict';
var STYLE_ATTRIBUTE = 'TEXT-STYLE-NAME';
var styleMatches = function (item, styleName) {
if (!item || item.attributes === undefined || item.attributes[STYLE_ATTRIBUTE] === undefined) {
return false;
}
return item.attributes[STYLE_ATTRIBUTE].match(styleName);
@nfroidure
nfroidure / gRetain.js
Last active August 29, 2015 13:56
gulp-retain
function gRetain(options) {
var stream = new Stream.Writable({objectMode:true})
, fileMap = {}
, timeout
, size = 0
;
options.limit = options.limit || 0;
options.delay = options.delay || 300;
@nfroidure
nfroidure / gist:8550658
Last active January 4, 2016 01:49 — forked from 0gust1/gist:8432208
#!/usr/bin/env node
//module.exports = function(){
var http = require("http");
var optimist = require("optimist");
var cheerio = require("cheerio");
var path = require("path");
var uglifyjs = require('uglifyjs');
var uglifycss = require('uglifycss');
var url = require('url');
@nfroidure
nfroidure / bench.sh
Last active January 4, 2016 00:49
Help me benchmarking Gulp VS Grunt! A summary of the results will be published on my blog (http://www.insertafter.com/blog.html).
#!/bin/bash
# Install the project
git clone git@github.com:ChtiJS/chtijs.francejs.org chtijs
cd chtijs
# Testing the Grunt build
git checkout master
npm install --quiet
time for a in {1..10}; do grunt dist; done
gulp.src(...)
.pipe(gutil.forwardErrors(pluginA()))
.pipe(gutil.forwardErrors(pluginB()))
.pipe(gutil.forwardErrors(pluginC()))
.on('error', function () {
throw new Error("Do not send to production!");
});
@nfroidure
nfroidure / gist:7385942
Last active December 27, 2015 20:39
Exemple de tâche Grunt de génération d'icône
module.exports = function(grunt) {
// Chargement des modules Grunt nécessaires
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-svgicons2svgfont');
grunt.loadNpmTasks('grunt-svg2ttf');
grunt.loadNpmTasks('grunt-ttf2eot');
grunt.loadNpmTasks('grunt-ttf2woff');
@nfroidure
nfroidure / gist:7247493
Created October 31, 2013 10:27
Installation préalable à ChtiJS#5 :
Installer/compiler NodeJS : http://nodejs.org
Puis dans la console :
# Karma runner
npm install -g karma
# Framework de test
npm install -g karma-mocha
npm install -g karma-chai
npm install -g karma-effroi