Skip to content

Instantly share code, notes, and snippets.

View aminnairi's full-sized avatar
😁

Amin NAIRI aminnairi

😁
  • École Supérieure de Génie Informatique
  • Paris
  • 02:26 (UTC +01:00)
  • LinkedIn in/amin-nairi
View GitHub Profile
<!DOCTYPE html>
<html lang="fr-FR">
<head>
<meta charset="UTF-8">
<meta name="description" content="Découvrez notre tout nouveau site internet.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Le titre de votre site internet</title>
</head>
<body>
<form method="POST" action="/php/register.php">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /webapi/index.php?route=$1 [L,QSA]
@aminnairi
aminnairi / partial.mjs
Created February 4, 2022 09:21
Partial Application
const partial = (callback, ...initialArguments) => {
return (...additionalArguments) => {
const allArguments = [...initialArguments, ...additionalArguments];
if (allArguments.length >= callback.length) {
return callback(...allArguments);
}
return partial(callback, ...allArguments);
};
@aminnairi
aminnairi / index.mjs
Created February 4, 2022 08:52
Correction
// For these excercises :
// - Only use recursion (or direct recursion)
// - Array.prototype methods are prohibited
// - for, while & do while loops are prohibited
// - Array.prototype.length is accepted
/**
* @description Update every item of an array
* @param {<Type>(item: Type) => Type} update A function that will update one item
* @param {Array<Type>} items An array of items to update
@aminnairi
aminnairi / posts.js
Created January 25, 2022 10:39
Seconde partie de l'exercice sur XMLHttpRequest
const request = new XMLHttpRequest();
const errorElement = document.getElementById("error");
const postsElement = document.getElementById("posts");
request.addEventListener("timeout", function() {
errorElement.innerText = "Le délai d'attente maximum est dépassé pour la requête.";
});
request.addEventListener("error", function() {
errorElement.innerText = this.statusText;
@aminnairi
aminnairi / index.php
Created January 18, 2022 18:46
Exercice Fonction
<!DOCTYPE html>
<?php
$cart = [
[ "product" => "paper", "quantity" => 7, "price" => 1.26 ],
[ "product" => "pen", "quantity" => 2, "price" => 0.12 ],
[ "product" => "eraser", "quantity" => 5, "price" => 0.89 ]
];
$stocks = [
@aminnairi
aminnairi / index.php
Created January 18, 2022 16:57
Function Exercise
<?php
$cart = [
[
"product" => "paper",
"quantity" => 7,
"price" => 1.26
],
[
"product" => "pen",
@aminnairi
aminnairi / exercise.php
Created January 10, 2022 21:49
Exercice PHP
<!DOCTYPE html>
<?php
$students = [
[
"id" => 1,
"name" => "Amanda ANDERSSON",
"CC1" => 10,
"CC2" => 17,
"CC3" => 12
@aminnairi
aminnairi / functions-exercise.php
Last active January 10, 2022 10:59
Functions exercises in PHP
<?php
$cart = [
["product" => "paper", "quantity" => 7, "price" => 1.26],
["product" => "pen", "quantity" => 2, "price" => 0.12],
["product" => "eraser", "quantity" => 5, "price" => 0.89]
];
$stocks = [
["product" => "paper", "quantity" => 88],
@aminnairi
aminnairi / asynchronous-recursive-generator.js
Last active December 17, 2021 15:15
Asynchronous Recursive Generator
async function* webservice(entity, index = 1) {
const response = await fetch(`https://jsonplaceholder.typicode.com/${entity}/${index}`);
if (response.ok) {
yield response.json();
yield* webservice(entity, index + 1);
}
}
for await (const user of webservice("users")) {