Skip to content

Instantly share code, notes, and snippets.

@mcibique
mcibique / sinon.js
Last active April 19, 2018 19:54
Sinon showcase
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import sinonStubPromise from 'sinon-stub-promise';
chai.use(chaiAsPromised);
chai.use(sinonChai);
sinonStubPromise(sinon);
// 1. trimming and padding
// https://github.com/tc39/proposal-string-left-right-trim
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimLeft
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
console.log(" 123 ".trim() === "123"); // true
console.log(" 123 ".trimStart() === "123 "); // true
console.log(" 123 ".trimEnd() === " 123"); // true
console.log("123".padStart(6, "0")); // 000123
@mcibique
mcibique / Dockerfile
Last active August 27, 2017 16:19
logs from docker when installing npm@5.4.0 (https://github.com/npm/npm/issues/16807)
FROM node:8
# check installed node and npm
RUN node -v && npm -v
# check the path where the npm is installed
RUN find / -name "npm-cli.js"
# list all node_modules from the npm folder
RUN ls -la /usr/local/lib/node_modules/npm/node_modules
@mcibique
mcibique / 00 - generators.js
Last active February 8, 2017 22:53
ES6 generators
// generators
// http://exploringjs.com/es6/ch_generators.html
// https://github.com/getify/You-Dont-Know-JS/blob/master/async%20%26%20performance/ch4.md#chapter-4-generators
@mcibique
mcibique / 00 - parameter handling.js
Last active January 26, 2017 16:31
ES6 Parameter handling
// parameter handling
// http://exploringjs.com/es6/ch_parameter-handling.html
@mcibique
mcibique / 00 - symbols.js
Last active February 8, 2017 10:22
ES6 Symbols
// symbols
// http://exploringjs.com/es6/ch_symbols.html
// https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20%26%20beyond/ch2.md#symbols
// https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20%26%20beyond/ch7.md#well-known-symbols
@mcibique
mcibique / 00 - api aditions.js
Last active February 7, 2017 23:32
ES6 API aditions
// api
// http://exploringjs.com/es6/ch_maps-sets.html
// http://exploringjs.com/es6/ch_arrays.html
// https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20%26%20beyond/ch6.md
// https://developer.mozilla.org/en-US/docs/tag/ECMAScript%202015?page=1
@mcibique
mcibique / 00 - classes.js
Last active September 30, 2023 02:59
ES6 classes
// classes
// http://exploringjs.com/es6/ch_classes.html
// https://github.com/getify/You-Dont-Know-JS/blob/master/es6%20%26%20beyond/ch3.md#classes