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
@nfroidure
nfroidure / gist:6019151
Last active December 19, 2015 21:18
Supporting old Internet Explorer versions easily
<html><head>
<!--[if lt IE 8]><script type="text/javascript">
alert('Ooops, you are using an old browser. Please come back with a more recent one.');
document.location.href="http://thewebyoumiss.com/?referer=example.com"
+"&preview=example.com/images/preview.png"
+"&preview=youtube.com/qs545qsd";
</script><![endif]-->
</head><body>
<p>The fantastic app you could miss with old browsers.</p>
</body></html>
@nfroidure
nfroidure / latinRegExp.js
Last active December 22, 2015 03:58
A regExp with unicode chars
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@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
@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');
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 / 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
@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 / 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;
'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 / 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'