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: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);
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));
};
var CSV = require('oh-csv');
process.stdout.write(
'<?xml version="1.0" encoding="UTF-8"?>' + '\r\n' +
'<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"' + '\r\n' +
' xmlns:dsq="http://www.disqus.com/" xmlns:dc="http://purl.org/dc/elements/1.1/"' + '\r\n' +
' xmlns:wp="http://wordpress.org/export/1.0/">' + '\r\n' +
' <channel>' + '\r\n'
);
@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/' ));
var YError = require('yerror');
var _localDateCopy = global.Date;
var DateMock = {
_mocking: false,
_pendingQueue: [],
_assignedQueue: [],
_pendingIndex: 0,
start: function(theTimeQueue, options) {
@nfroidure
nfroidure / MongoObjectId.cls
Created March 4, 2016 09:38
Generating a MongoDB ObjectId in SalesForce Apex
public with sharing class MongoObjectId {
private static final Integer COUNTER_MASK = 16777215; // 0xFFFFFF
private static final Integer PID_MASK = 65535; // 0xFFFF
private static final String MACHINE_PART = '050135';
private static final String[] hexMap = '0123456789abcdef'.split('');
private static Integer counter = -1;
public static void seed() {
// Seed once or force reseed when testing
if(-1 == counter || Test.isRunningTest()) {
@nfroidure
nfroidure / nock-recorder.js
Last active August 5, 2019 08:11
Snippet to record HTTP traffic
import fs from 'fs';
import nock from 'nock';
nock.recorder.rec({
logging: content => fs.appendFileSync('./nock-records.log', content),
});
@nfroidure
nfroidure / calculator.js
Last active July 11, 2016 13:07
Simple calculator
var operators = {
'+': (a, b) => a + b,
'-': (a, b) => a - b,
'*': (a, b) => a * b,
'/': (a, b) => a / b,
};
function calculator (str) {
return str.split(/\s*(\+|-)\s*/g)
.map(substr => {

Notre PR, qui est soumise

que ton code soit accepté

que ton merge vienne

que ta review soit faîte

sur le code comme les tests.

@nfroidure
nfroidure / middlewares-anti-pattern.js
Last active November 6, 2016 09:41
Express midlewares hell
module.exports = (app) => {
// where ther hell is this config set?
const config = app.get('config');
// How can i see what this timer do?
const timer = app.get('timer');
app.post((req, res, next) => {
const data = {};
// Which middleware set up this query params?