Skip to content

Instantly share code, notes, and snippets.

View erwanriou's full-sized avatar
:electron:
ǝʌɐๅɔsǝˌๅ sᴉns ǝſ ʇuop ǝʇɹǝqᴉๅ ɐๅ ʇsǝ ǝʌǝɹ ǝꓶ

R1 erwanriou

:electron:
ǝʌɐๅɔsǝˌๅ sᴉns ǝſ ʇuop ǝʇɹǝqᴉๅ ɐๅ ʇsǝ ǝʌǝɹ ǝꓶ
View GitHub Profile
@erwanriou
erwanriou / rockpaperscissor.sh
Last active November 21, 2022 16:08
Rock Paper Scissor game in shell bash
#!/bin/bash
ORANGE='\033[0;33m'
NC='\033[0m'
USER_SCORE=0
COMPUTER_SCORE=0
# PRINT SELECTION LIST
function print_selection() {
printf "\n1 Welcome to ROCK - PAPER - SCISSOR \n\n"
// HANDLE THE EVENT HANDLER FUNCTION
const handleProductsTotalPriceUpdate = () => {
const getProductsTotal = () => {
const products = document.getElementsByClassName(
"woocommerce-grouped-product-list-item"
);
const totals = Object.values(products)
.map((p) => {
// GET QUANTITIES
@erwanriou
erwanriou / backup-cron-job.yml
Last active May 31, 2022 14:31
How to create a backup cron job for MongoDB database on kubernetes (GKE)
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cluster-admin
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods/exec", "pods/cp"]
@erwanriou
erwanriou / ecommerceDiscount.js
Last active March 29, 2021 17:19
vanilla javascript update to calculate price discount for ecommerce.
const handlePricePourcentage = () => {
const isEmpty = value =>
value === undefined ||
value === null ||
(typeof value === "object" && Object.keys(value).length === 0) ||
(typeof value === "string" && value.trim().length === 0)
// GET REAL PRICE
const getRealPrice = () => {
const parent = document.getElementsByTagName("del")
@erwanriou
erwanriou / articleAction.js
Created November 20, 2019 09:40
Redux flow for a blog
import axios from "axios"
import {
GET_ERRORS,
ARTICLE_RESET_STATE,
ARTICLE_FETCH,
ARTICLES_FETCH,
ARTICLES_LIKE,
ARTICLE_LIKE
} from "../types"
@erwanriou
erwanriou / config-overrides.js
Created November 20, 2019 08:58
Implementation of PWA working on specific part of the app and code splitting of the packages for http2 optimization on rewired CRA
const {
rewireWorkboxInject,
defaultInjectConfig
} = require("react-app-rewire-workbox")
const path = require("path")
const webpack = require("webpack")
module.exports = function override(config, env) {
// IMPORTANT: CONFIG RELATIVE TO WEBPACK ONLY HTTP2
config.optimization = {
@erwanriou
erwanriou / Head.js
Created November 20, 2019 08:52
Exemple of codesplitting optimization based on router component
import React from "react"
import { connect } from "react-redux"
import { getTranslate } from "react-localize-redux"
import { Helmet } from "react-helmet-async"
const Head = ({ translate, component }) => {
return (
<Helmet>
<title>{translate(`meta.${component}.title`)}</title>
<meta