Skip to content

Instantly share code, notes, and snippets.

@felipecesr
felipecesr / combinations.js
Created July 15, 2016 20:14 — forked from axelpale/combinations.js
JavaScript functions to calculate combinations of elements in Array.
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
var autoprefixer = require('autoprefixer');
module.exports = function(gulp, config, plugins) {
return function() {
gulp.src(config.sourceAssets + 'scss/*.scss')
.pipe(plugins.plumber())
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass({ includePaths : config.sassPaths }))
// .pipe(plugins.combineMq({ beautify: false }))
.pipe(plugins.postcss([ autoprefixer(config.autoprefixer) ]))
class Economic extends Printer {
constructor(name) {
super(name);
}
}
let printers = [
new AllInOne('HP 1'),
new AllInOne('HP 2'),
new Economic('HP 3'),
];
function printerFunctionalities(printers) {
console.log('Impressoras digitalizando: ');
for (let printer of printers) {
if (printer.scan) {
console.log(`${printer.name} is ${printer.scan()}`);
}
}
}
@felipecesr
felipecesr / http-client.js
Last active July 16, 2018 16:38
Single Responsability Principle
import Swal from 'sweetalert2';
export class HttpClient {
get(url) {
return fetch(url, {
headers: {
Accept: 'application/json'
}
}).then(response => {
if (response.ok) {
import Swal from 'sweetalert2';
export default class ErrorHandler {
static handle(response) {
if (response.status == 401) {
Swal({
title: 'Não autorizado',
type: 'error'
});
} else if (response.status == 404) {
import ErrorHandler from './error-handler';
export default class HttpClient {
get(url) {
return fetch(url, {
headers: {
Accept: 'application/json'
}
}).then(response => {
if (response.ok) {
class Rectangle {
constructor(width, height) {
this._width = width;
this._height = height;
}
get width() {
return this._width;
}
class Circle {
constructor(radius) {
this._radius = radius;
}
get radius() {
return this._radius;
}
set radius(value) {