Skip to content

Instantly share code, notes, and snippets.

View aladin002dz's full-sized avatar
✌️
Working remotely!

Mahfoudh Arous aladin002dz

✌️
Working remotely!
View GitHub Profile
@aladin002dz
aladin002dz / MycomponentFetch.jsx
Last active December 3, 2024 10:39
standard flow of fetch in react
import { useState, useEffect } from 'react';
export default function MyComponentFetch(){
const [data, setData] = useState(null); // State to store fetched data
const [loading, setLoading] = useState(true); // Loading state
const [error, setError] = useState(null); // Error state
useEffect(() => {
const fetchData = async () => {
setLoading(true);
@aladin002dz
aladin002dz / vscode-shortcuts.md
Last active May 8, 2024 15:49
VS Code Shortcuts

Ctrl + D / Cmd + D : multiple selection of the same occurence.
Shift + Ctrl + L / Shift + Cmd + L: Select all occurence of the same item.
Alt + Ctrl / Option + Cmd : multi cursor editing.
Ctrl + P / Cmd + P : Search and Open a file in the current folder by typing name of the file or its pattern.
Ctrl + T / Cmd + T: jump to a definition by typing "#" then the identifier.
Shift + Ctrl + P / Shift + Cmd + P: open command pannel and type any command.
Ctrl + Shift + ù : open integrated terminal.
Credit: Mosh Hamedani: https://www.youtube.com/watch?v=1mD7-WWKvto&ab_channel=ProgrammingwithMosh

Ctrl + G: jump to a file.

RTK Query Primer

Redux Toolkit

File structure :

  • ./main.jsx
  • ./app/store.js
  • ./app/apiSlice.js
  • ./App.jsx
  • ./components/PokemonList.jsx
@aladin002dz
aladin002dz / rtk-primer-1.md
Created February 24, 2023 10:27 — forked from jeromeabel/rtk-primer-1.md
Redux Toolkit Primer

Redux Toolkit Primer #1 - Counter 📖

Redux Toolkit

A simple example of a Counter to remind me the basic usage of Redux Toolkit. The Counter React component displays its value ("state") and allows to change it with three different buttons ("actions").

File structure :

  • ./main.jsx
  • ./App.jsx
  • ./app/store.js

Redux Toolkit Primer #2 - Cart 🛒

Redux Toolkit

A simple example of a Cart to remind me the basic usage of Redux Toolkit. We need to use two features : "products" and "cart". The Products React Component displays a list of products and add it to the cart. The Cart Component displays the number of items and the total score.

File structure :

  • ./main.jsx
  • ./App.jsx
  • ./app/store.js
Country,Year,Value
Albania,1980,2.7
Albania,1981,5.7
Albania,1982,2.9
Albania,1983,1.1
Albania,1984,2
Albania,1985,-1.5
Albania,1986,5.6
Albania,1987,-0.8
Albania,1988,-1.4
@aladin002dz
aladin002dz / nodejs_db_with_restapi.js
Created January 10, 2020 19:20 — forked from dalelane/nodejs_db_with_restapi.js
Node.js, Express, and SQLite to wrap a REST API around an SQL database
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('data/demodb02');
db.serialize(function() {
db.run("CREATE TABLE IF NOT EXISTS counts (key TEXT, value INTEGER)");
db.run("INSERT INTO counts (key, value) VALUES (?, ?)", "counter", 0);
});
@aladin002dz
aladin002dz / docker_wordpress.md
Created December 1, 2019 21:03 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
var mousex;
var mousey;
window.addEventListener('click', function (event) {
mousex = event.x
mousey = event.y
})
//the circle object decalaration
function Circle(x,y,dx,dy,radius){
//the circle properties
this.x = x;
this.y = y;
...
//the drawing method
this.draw = function() {