Skip to content

Instantly share code, notes, and snippets.

View EnetoJara's full-sized avatar
🐼
I may be slow to respond.

Ernesto Jara Olveda EnetoJara

🐼
I may be slow to respond.
View GitHub Profile
const flat = (base, val) => Array.isArray(val) ? base.concat(val.reduce(flat, [])) :base.concat(val);
const map = arr => arr.reduce(flat, []);
console.log(map([1,23,[3,[3,1,[3,4],5],6],5]))
@EnetoJara
EnetoJara / polishNotation.js
Created January 28, 2020 21:05
Evaluate Reverse Polish Notation in Javascript
/**
Input: [“3”, “1”, “+”, “5”, “*”]
Output: 9
Explanation: ((3 + 1) * 5) = 20
*/
function RPN(seq) {
if (seq.length <= 2) {
console.log('Please enter valid RPN')
@EnetoJara
EnetoJara / Home.js
Created February 10, 2020 00:05
This Component will be the Parent Component, the main "window".
import React from "react";
import logo from "./logo.svg";
import { WindowOpener } from "./window-opener";
export class Home extends React.Component {
constructor (props) {
super(props);
this.state = {
message: ""
}
import React from "react";
export class Son extends React.Component {
constructor (props) {
super(props);
this.state = {
message: ""
}
this.onChangeHandler = this.onChangeHandler.bind(this);
}
@EnetoJara
EnetoJara / window-opener.js
Created February 10, 2020 00:39
Window Opener component this Component is used to open windows
import PropTypes from "prop-types";
import React from "react";
// Main Window.
let browser = null;
// child window.
let popup = null;
// interval
let timer = null;
// This function is what the name says.
import React from 'react';
import { BrowserRouter, Redirect, Route, Switch } from "react-router-dom";
import './App.css';
import { Home } from "./Home";
import { Son } from "./Son";
function App() {
return (
<div className="App">
import * as qs from "qs";
import { PathLike } from "fs";
export const apiConfig = {
returnRejectedPromiseOnError: true,
withCredentials: true,
timeout: 30000,
baseURL: "https://jsonplaceholder.typicode.com/",
headers: {
common: {
import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
import { Api } from './../src/api/api';
import { Credentials, Token, User } from './interfaces';
export class UserApi extends Api {
public constructor (config?: AxiosRequestConfig) {
super(config);
// this middleware is been called right before the http request is made.
{
"compilerOptions": {
"incremental": true,
"target": "es2019",
"module": "esnext",
"lib": [
"DOM",
"ES2017",
"ES2019"
],
import { applyMiddleware, createStore } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import createSagaMiddleware from "redux-saga";
import { rootReducer } from "../reducers";
import { AppState } from "@eneto/api-client";
import { initUserState } from "../../modules/users/user-reducer";
import { initUsersState } from "../../modules/users/users-reducer";
import { initListsState } from "../../modules/lists/lists-reducer";