Skip to content

Instantly share code, notes, and snippets.

View abykal's full-sized avatar
💻
#DevSecOps

Aby Abraham abykal

💻
#DevSecOps
View GitHub Profile
@stomg7969
stomg7969 / fianlMultiFilter.js
Created May 14, 2019 18:19
FILTER BLOG - multi filter
multiPropsFilter = (products, filters) => {
const filterKeys = Object.keys(filters);
return products.filter(product => {
return filterKeys.every(key => {
if (!filters[key].length) return true;
// Loops again if product[key] is an array (for material attribute).
if (Array.isArray(product[key])) {
return product[key].some(keyEle => filters[key].includes(keyEle));
}
return filters[key].includes(product[key]);
@stomg7969
stomg7969 / collectedSamples.js
Created May 14, 2019 18:17
FILTER BLOG - sample output
const collectedTrueKeys = {
color: ['white', 'pink'],
gender: ['girl'],
material: ['cotton'],
cateogry: []
}
@stomg7969
stomg7969 / filteredCollected.js
Created May 14, 2019 18:17
FILTER BLOG - collet keys that are true
// **************** Collect all keys and Filter ****************
// This function collects ALL keys that have true as a value, then create a new obj to compare to filter.
filteredCollected = () => {
const collectedTrueKeys = {
color: [],
gender: [],
material: [],
category: []
};
const { color, gender, material, category } = this.state.passingTags;
@stomg7969
stomg7969 / multiFilter.js
Created May 14, 2019 18:15
FILTER BLOG - universal filter
// **************** UNIVERSAL Filter ****************
allFilterClickListener = (e, filterProp) => {
console.log("FILTER clicked", e.target.dataset.name);
const name = e.target.dataset.name;
this.setState(prevState => ({
passingTags: {
...prevState.passingTags,
[filterProp]: {
...prevState.passingTags[filterProp],
[name]: !prevState.passingTags[filterProp][name]
@stomg7969
stomg7969 / state.js
Created May 14, 2019 18:07
FILTER BLOG - state
state = {
userInputContainerClicked: false,
searchTerm: "",
// tags that render are inside of 'passingTags' object.
passingTags: {
search: {
inputTerm: ""
},
price: {
lowHigh: false,
@stomg7969
stomg7969 / inputTagCollection.js
Last active October 31, 2022 17:52
FILTER BLOG - InputTagCollection component
import React, { Component } from "react";
class InputTagCollection extends Component {
render() {
console.log(this.props.tags);
const { search, price, color, gender, material, category } = this.props.tags;
return (
<div id="chosen-tags">
{search.inputTerm.length ? (
<div className="collection" onClick={this.props.cancelSearchTag}>
@stomg7969
stomg7969 / productAttributes.js
Last active December 12, 2019 11:48
FILTER BLOG - My product attributes
const category = ['innerwear', 'dress', 'robe', 'pajamas', 'sweater', 'pants'];
const color = ['white', 'black', 'brown', 'navy', 'blue', 'yellow', 'pink', 'purple', 'beige', 'red', 'green'];
const gender = ['unisex', 'girl', 'boy'];
const material = ['modal', 'cotton', 'spandex', 'tencel', 'rayon'];
@stomg7969
stomg7969 / simpleFilterSample.js
Last active December 12, 2019 11:48
FILTER BLOG - sample filter function
const sampleArray1 = [1, 2, 3];
const sampleArray2 = ['apple', 'banana', 'cake'];
const result1 = sampleArray1.filter(number => number > 1);
const result2 = sampleArray2.filter(letter => letter.length > 4);
console.log(result1);
// => expected output: Array [2, 3]
console.log(result2);
// => expected output: Array ['apple', 'banana']
@stomg7969
stomg7969 / blockstack address
Created April 18, 2019 22:02
blockstack address
Verifying my Blockstack ID is secured with the address 12u9ToF8YchQMYt9ZCcYFPJYATJHXrURKE https://explorer.blockstack.org/address/12u9ToF8YchQMYt9ZCcYFPJYATJHXrURKE

SSH into AWS ec2/ Digitalocean droplet/ or else other PAAS, linux machine

  1. Install Docker
$sudo apt install docker.io
$sudo usermod -aG docker $USER

I already installed docker