Skip to content

Instantly share code, notes, and snippets.

View seysdev's full-sized avatar
🎯
Working

sebastian yabiku seysdev

🎯
Working
View GitHub Profile
@seysdev
seysdev / hyper.js
Created July 17, 2019 02:51
config hyper with gitbash
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// default font size in pixels for all tabs
fontSize: 12,
@seysdev
seysdev / adapter.js
Created June 25, 2019 00:17
Dessign Patterns - Structural
const ServiceStorageAdapter = () => {
const adapter = {};
adapter.getAll = function () {
return fetch('/shopping')
.then(function (response) {
return response.json();
})
}
@seysdev
seysdev / singleton.js
Created June 20, 2019 04:40
Dessign Patterns - Creational
class Database {
constructor(data) {
if (Database.exists) {
return Database.instance;
}
Database.instance = this;
Database.exists = true;
this._data = data;
@seysdev
seysdev / prototype.js
Created June 20, 2019 03:30
Dessign Patterns - Creational
var myCar = {
name: "Ford Escort",
drive: function () {
console.log( "Weeee. I'm driving!" );
},
panic: function () {
console.log( "Wait. How do you stop this thing?" );
}
};
@seysdev
seysdev / factory.js
Last active June 20, 2019 02:43
Dessign Patterns - Creational
// PATTERN FACTORY USING CLASS
class Bicycle {
constructor() {
this.vehicle = 'Bicycle';
this.wheels = 2;
this.speedMax = 20;
}
}
class Car {
@seysdev
seysdev / constructor.js
Created June 20, 2019 01:02
Dessign Patterns - Creational
function Pokemon(type, power) {
this.type = type;
this.power = power;
this.say() {
return `I am ${this.type} and my power is ${this.power}`;
}
}
// es6
class Pokemon {
@seysdev
seysdev / operators.js
Created May 23, 2019 15:46
operators - reactive programming
/*
example 1
*/
import { from } from 'rxjs';
import { filter, map } from 'rxjs/operators';
const arraySource = from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
arraySource.pipe(
@seysdev
seysdev / observable.js
Created May 23, 2019 14:22
reactive programming
var observable = Rx.Observable.create(function (observer) {
observer.next(1);
observer.next(2);
observer.next(3);
setTimeout(() => {
observer.next(4);
observer.complete();
}, 1000);
});
@seysdev
seysdev / reactive-ex1.js
Last active May 22, 2019 17:20
not reactive
/*
* Without reactive paradigm
*/
class Car {
constructor(sales) {
this.items = [];
this.sales = sales;
}
add(item) {
@seysdev
seysdev / event-rxjs.js
Created May 21, 2019 23:36
basic rxjs
/*
secuencia de eventos
*/
document.addEventListener('click', (e) => console.log('Clicked!', e.clientX));
/*
usando rxjs
*/
import { fromEvent } from 'rxjs';