Skip to content

Instantly share code, notes, and snippets.

var moment = require('moment');
// Add here the result for the customer info from the API get customer endpoint (as an array)
const [data] = [];
const [policy] = data.policies;
if (!data.policies.length || data.policies.length > 1) throw new Error('Check policies number')
const formatDate = (date) => moment(date).format('MMM DD, YYYY, LTS Z');
@jimyandres
jimyandres / pre-commit-eslint
Created August 18, 2020 15:43 — forked from shettayyy/pre-commit-eslint
Pre-commit hook for Linting JS with ESLint before commit.
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
ESLINT="$(git rev-parse --show-toplevel)/node_modules/.bin/eslint"
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@jimyandres
jimyandres / docAPI.md
Last active May 8, 2020 20:33
API amicus
@jimyandres
jimyandres / Calling-0497439.json
Last active April 22, 2020 16:07
Tracking: Calling Vs Tracking (Order ID
// https://172.27.4.76/ws/callin/search?order_id=0497439
[
{
"__type": "callin",
"company_id": "TMS",
"call_date_time": "20190102111800-0500",
"city_id": 7115340,
"city_name": "CHICAGO",
"entered_by": "PATRICKF",
"id": "zz1d07lo32h143s-VMTS66",
@jimyandres
jimyandres / McLRequests.js
Last active April 23, 2020 14:37
Script to skipt SSL validation on a request (with Axios)
const axios = require('axios');
const https = require('https');
const httpsAgent = new https.Agent({
rejectUnauthorized: false,
});
const makeReq = req =>
axios({
method: req.type,
@jimyandres
jimyandres / switchless-redux.js
Created January 4, 2019 15:02
Eliminate the switch statement
const switchcase = cases => defaultCase => key =>
cases.hasOwnProperty(key) ? cases[key] : defaultCase;
const executeIfFunction = f =>
f instanceof Function ? f() : f;
const switchcaseF = cases => defaultCase => key =>
executeIfFunction(switchcase(cases)(defaultCase)(key));
const counter = (state = 0, action) =>

Getting Started with Redux - EggHead.io

1. The Single Immutable State Tree

  • First principle (Single source of truth): everything that changes in the app (the data and the UI state), is contained in a single plane object, called as the state or the state tree.

2. Describing State Changes with Actions

  • Second Principle (State is read-only): the state tree is read-only. To modify the state tree is necessary to dispatch an action, an object describing what happened.