Skip to content

Instantly share code, notes, and snippets.

View dwaps's full-sized avatar

Cornillon Michael dwaps

View GitHub Profile
@dwaps
dwaps / Etape-1.md
Last active January 5, 2024 09:14
Git : Procédure pour débutant

Etape 1 : initialiser un dépôt (projet) git

Créer un dossier pour le futur projet

Dans le terminal, depuis le dossier utilisateur (home) :

michael@dwaps-formation:~$ cd Desktop/mon-super-projet
michael@dwaps-formation:~$ git init
Initialized empty Git repository in C:/Users/conta/Desktop/tests/.git/
@dwaps
dwaps / MyEventEmitter.js
Last active May 16, 2023 13:21
Node : Création d'un EventEmitter
class EventEmitter {
constructor() {
this.events = {};
}
on(eventName, listener) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(listener);
}
@dwaps
dwaps / index.js
Created November 28, 2019 07:17
JS: RegExp examples
const mail = "cocojaco@mail.fr";
const regex = new RegExp("^(\\w+)@(\\w+\\.\\w{2,4})$");
const mailOK = regex.test(mail);
const groups = regex.exec(mail);
const localPart = groups[1];
const domainPart = groups[2];
@dwaps
dwaps / snippet-html.json
Created December 5, 2019 11:38
SNIPPET: Exemple pour générer une structure HTML.
{
"doctype": {
"description": "Generate DOCTYPE",
"prefix": "!",
"body": [
"<!DOCTYPE html>",
"<html lang=\"fr\">",
"\t<head>",
"\t\t<meta charset=\"utf-8\">",
"\t\t<title>${1:TITLE}</title>\n",
@dwaps
dwaps / index.js
Created December 5, 2019 15:56
ES6: Exemple de génération de todo en HTML
// CLASSE
class Todo {
constructor(text) {
this.text = text;
this.done = false;
}
}
// RECUP DES TODOS
const todos = [
@dwaps
dwaps / index.js
Created December 6, 2019 11:41
ES6: Notion de promesse.
// Model
class User {
constructor(name, role) {
this.name = name;
this.role = role;
}
}
// BDD
const users = [
@dwaps
dwaps / geolocation.js
Created December 7, 2019 08:43
HTML5 API: Geolocation --> getCurrentPosition()
if ('geolocation' in navigator) {
const { geolocation } = navigator;
geolocation.getCurrentPosition(success, error);
function success(position) {
const { coords } = position;
const p = document.querySelector('p');
p.innerHTML = `
<strong>LAT:</strong> ${coords.latitude}<br>
<strong>LNG:</strong> ${coords.longitude}
@dwaps
dwaps / README.md
Created December 8, 2019 11:20
NODE.JS: Exercice insertion de code à partir de fichier.

INSERTION DYNAMIQUE DE CODE DANS UN FICHIER

INSTALLATION

L'index.html et l'index.js doivent se trouver à la racine du projet.

Ensuite:

  • Les feuilles de styles à la racine du dossier css/
  • Les scripts à la racine du dossier js/
  • Les fragments de code html à la racine du dossier html/
@dwaps
dwaps / server.js
Created December 9, 2019 15:31
NODE: Exercice routing simple 1
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>TITLE</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
@dwaps
dwaps / index.html
Created December 9, 2019 15:33
NODE: Exercice routing simple 2
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>TITLE</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>