Skip to content

Instantly share code, notes, and snippets.

View santospatrick's full-sized avatar
👽
Javascripting

Patrick Santos Bitonti Teixeira santospatrick

👽
Javascripting
View GitHub Profile
@santospatrick
santospatrick / History|-1948d6fc|entries.json
Last active April 6, 2022 19:21
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///Users/santospatrick/Developer/gallery/.env.local","entries":[{"id":"qb39.local","timestamp":1649037573993},{"id":"mdDN.local","timestamp":1649183192753}]}
/**
* React
*/
import React from 'react';
import PropTypes from 'prop-types';
/**
* Generic
*/
import areIntlLocalesSupported from 'intl-locales-supported';
/**
* Redux action to store cultures
* @param {Array<Object>} arr
* @returns {Object}
*/
export const reduxAction = arr => ({
type: 'ADD_CULTURES',
cultures: arr
});
/**
* Pure javascript responsability:
* http to get cultures then add it to
* 'cultures' variable and then reuse
* the transformers we wrote
*/
// Vue.js
<ul>
<li v-for="item in getNames(cultures)">{{ item }}</li>
const names = cultures.map(item => item.cultureName)
// ['Soybean', 'Maize', 'Wheat']
const energies = cultures
.reduce((acc, nextObject) => {
const nextValue = nextObject.energy.quantity;
const currentValue = acc[nextObject.energy.unit]
? acc[nextObject.energy.unit].quantity
: 0;
acc[nextObject.energy.unit] = {
const cultures = [
{
cultureName: 'Soybean',
quantity: 1500.50,
calories: 446,
energy: {
quantity: 0,
unit: 'g'
}
},
/**
* Get cultures name into a new array
* Immutable, pure
* @param {Array} cultures
* @returns {Array<String>}
*/
const getNames = cultures => cultures.map(item => item.cultureName);
/**
* Get cultures quantity summed into
import removeAccents from 'remove-accents';
/**
* Filter list based on certain attribute by some text
* @param {array} list
* @param {string} searchText
* @param {string} attribute
* @returns {array} new filtered list
*/
export function filterList(list, searchText, attribute) {
@santospatrick
santospatrick / README.md
Created August 28, 2017 14:43 — forked from thgaskell/README.md
Sequelize + Express Starter Guide
@santospatrick
santospatrick / terminal-oh-my-zsh.md
Last active June 14, 2024 18:14
Terminal with oh-my-zsh (Linux/Windows/MacOSX)

Terminal with oh-my-zsh (Linux/Windows/MacOSX)

Every step in this tutorial is required for making terminal look as the image below.

ZSH & OH-MY-ZSH

sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"