Skip to content

Instantly share code, notes, and snippets.

View bhubr's full-sized avatar

Benoît Hubert bhubr

View GitHub Profile
@bhubr
bhubr / nginx-deployment.yaml
Last active December 9, 2021 10:45
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
@bhubr
bhubr / README.md
Last active May 29, 2022 09:28
Mise en place d'un projet TS avec Jest

Mise en place d'un projet TS avec Jest

Installation

1. Initialiser le projet

Utiliser Git Bash ou WSL (sinon faire le .gitignore manuellement)

Créer un répertoire ts-with-jest, initialiser le package.json, le dépôt Git, le fichier .gitignore :

@bhubr
bhubr / ajax-get-html.js
Last active November 8, 2021 13:42
Exemples AJAX
// EXEMPLE AJAX AVEC HTML
// On passe comme argument à fetch l'URL d'une ressource
// (HTML ou JSON) à interroger
fetch("/ajax-content.html")
// la fonction passée dans le .then est appelée seulement quand on
// a reçu la réponse du serveur
.then(function(response) {
// L'objet response contient la réponse du serveur
// En appelant la méthode text on récupère le contenu
// (texte brut) de la réponse
@bhubr
bhubr / .prettierrc.json
Last active February 10, 2022 15:02
Basic default prettierrc
{
"semi": true,
"singleQuote": true
}
@bhubr
bhubr / meals.csv
Last active October 22, 2021 11:31
Fake data
jambon frites pepsi
poulet frites coca-cola
saucisse frites fanta
burger frites coca-cola
omelette frites perrier
tofu salade perrier
@bhubr
bhubr / .Xresources
Created October 12, 2021 07:05
Paramétrage Xterm openSUSE
xterm*faceName: Courier New
xterm*faceSize: 12
xterm*renderFont: true
@bhubr
bhubr / kahoot.md
Last active October 11, 2021 10:55
Quiz lundi 11/10 POE SPIE

POE SPIE - Lundi 11/10 - Quiz Culture info / réseau

1. Quel composant a remplacé les tubes à vide, et permis la miniaturisation des ordinateurs ?

A. la diode
B. le transistor
C. la résistance
D. le condensateur

Voir la réponse

@bhubr
bhubr / template.html
Created October 3, 2021 20:42
Album template with inline CSS
<!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>Simple Album</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
@bhubr
bhubr / error-types.ts
Created September 23, 2021 13:14
TypeScript type guards
class NetworkError extends Error {}
class OtherError extends Error {}
function flipCoin() {
return Math.random() > 0.7;
}
function networkRequest() {
if (flipCoin()) {