Skip to content

Instantly share code, notes, and snippets.

View mattiaerre's full-sized avatar
`yarn prettier:fix`

Mattia Richetto mattiaerre

`yarn prettier:fix`
View GitHub Profile
/* eslint no-console: off */
const http = require('http');
const _ = require('lodash');
const randomHttpStatusCode = _.sample(_.invert(http.STATUS_CODES));
console.log('randomHttpStatusCode:', randomHttpStatusCode);
@mattiaerre
mattiaerre / handle-change-with-debounce.js
Created July 29, 2016 19:08
handle-change-with-debounce.js
handleChange(e) {
e.persist();
// info: "this.debounced" is defined at the class level
if (!this.debounced) {
this.debounced = _.debounce(() => {
console.log('YATTA!');
this.debounced.cancel();
this.debounced = undefined;
}, 500);
this.debounced();
(function() {
var you = true;
const MATTIA = 'Mattia';
var myName = {
is: function(name) {
return name == MATTIA
}
};
var to = {
call: {
@mattiaerre
mattiaerre / generic-component-tests.js
Last active September 6, 2015 18:27
Dependency injection in Node.js
var chai = require('chai'),
expect = chai.expect,
should = chai.should();
describe('unit-tests', function () {
'use strict'
describe('generic-component-tests', function () {
describe('given a component', function () {
describe('when initialized w/ dependency', function () {