Skip to content

Instantly share code, notes, and snippets.

View oussematn's full-sized avatar
🏠
Working from home

Miled Oussema oussematn

🏠
Working from home
  • Tunis Tunisia
View GitHub Profile
let isOn = true;
const handleClick = () => {
isOn = !isOn;
};
<button
onClick={handleClick}
style={{ backgroundColor: isOn ? 'green' : 'red' }}
>
const items = [
{
img: 'a.png',
title: 'Title 1',
description: 'Description 1'
},
{
img: 'b.png',
title: 'Title 2',
description: 'Description 2'
// Parent component
<Item img='a.png' title='title 1' description='Description 1'></Item>
<Item img='b.png' title='title 2' description='Description 2'></Item>
<Item img='c.png' title='title 3' description='Description 3'></Item>
<Item img='d.png' title='title 4' description='Description 4'></Item>
// Child component
<div>
<img src={img} />
<h3>{title}</h3>
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js')
workbox.routingl.registerRoute(
({request}) => request.destination === "image",
// This will try to load the images from the network first, then fallback to the cached
new workbox.strategies.NetworkFirst()
// If we want to use the cashed content first, we could use:
// new workbox.strategies.CasheFirst()
)
{
"name": "Hello World",
"short_name": "Hello World",
"start_url" : "?home=true",
"icons":[
{
"src":"icons/manifest-icon-192.png",
"sizes":"192x192",
"type":"image/png",
"purpose":"maskable any"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hi WPA</title>
<link rel="manifest" href="manifest.json">
</head>
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
fs.readFile(“./usr/myfile.txt”, function myfunc (err, data) {
console.log(“Task done”);
});
function whatever(handleData){
getData(url , data=>handleData(data))
}
let products=[{name:'RTX 3090',price:1499},{name:'Apple Stand',price:1000}]
let totalPrice = 0
products.forEach(product=> totalPrice += product.price)
return totalPrice