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 / gulpfile.js
Last active August 29, 2015 14:16 — forked from Simounet/gulpfile.js
var clone = require('gulp-clone');
gulp.task("default", function() {
var normal = gulp.src( destination + '*.png' );
var retina = normal.pipe(clone());
normal.pipe(makeSprites())
.pipe(gulp.dest( imagesBase + '1x/' ));
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));
};
'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 / 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');
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!");
});
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){ doc[p]=(function(old){ return function(v){return addListen(old(v))}; })(doc[p]);}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@nfroidure
nfroidure / gist:5696893
Last active December 18, 2015 00:29 — forked from brunobord/gist:5695039
// -------- Database section
// current version
var __versions__ = ['1.0.1','1.0.2','1.0.3'];
var __version__ = localStorage.getItem('db:version')
||__versions__[__versions__.length-1];
function migrate_1_0_1() {
console.log('going into migrate_1_0_1');
}
function migrate_1_0_2() {
@nfroidure
nfroidure / gist:5118171
Last active December 14, 2015 16:49 — forked from bloodyowl/gist:5118132
{
"name" : "FranceJS"
, "version" : "0.0.1"
, "dependencies" : {
"jslovers" : "*",
"parisjs" : "*",
"toulousejs" : "*",
"lyonjs" : "*",
"lillejs" : "*"
}
// Chainable API for URIBuilder
var uri = new URLBuilder(logErrorHandler)
.parse('bad_url_format')
.addQueryParam('param','value')
.setPort('443')
.toString();
function logErrorHandler(err, url_object){
if('parse_error'===err.type)