Skip to content

Instantly share code, notes, and snippets.

View alexsoyes's full-sized avatar

Alex alexsoyes

View GitHub Profile
@alexsoyes
alexsoyes / graph.ts
Created June 20, 2023 09:58
Exemple TypeScript : Graphes
class Graph {
adjacencyList: Map<number, number[]>;
constructor() {
this.adjacencyList = new Map<number, number[]>();
}
addVertex(vertex: number) {
if (!this.adjacencyList.has(vertex)) {
this.adjacencyList.set(vertex, []);
@alexsoyes
alexsoyes / queue.ts
Created June 20, 2023 09:54
Exemple TypeScript : Files / Queues
class Queue<T> {
queue: T[];
constructor() {
this.queue = [];
}
enqueue(value: T) {
this.queue.push(value);
}
@alexsoyes
alexsoyes / stack.ts
Last active June 20, 2023 09:52
Exemple TypeScript : Piles
class Stack<T> {
stack: T[];
constructor() {
this.stack = [];
}
push(value: T) {
this.stack.push(value);
}
@alexsoyes
alexsoyes / linked-list.ts
Created June 20, 2023 09:50
Exemple TypeScript : Listes chaînées
class ListNode<T> {
value: T;
next: ListNode<T> | null;
constructor(value: T) {
this.value = value;
this.next = null;
}
}
@alexsoyes
alexsoyes / array.ts
Created June 20, 2023 09:49
Exemple TypeScript : Tableau
const array: number[] = [1, 2, 3, 4, 5];
console.log(array); // Output: [1, 2, 3, 4, 5]
@alexsoyes
alexsoyes / .htaccess
Created March 12, 2023 05:19
Alex so yes .htaccess file
# BEGIN WP Rocket v3.12.3.2
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>
@alexsoyes
alexsoyes / behat-fr.feature
Created September 19, 2022 02:44
Syntaxe Gherkin en français avec Behat
# Source https://github.com/Behat/fr-docs.behat.org/blob/master/guides/1.gherkin.rst
Fonctionnalité: Une description de ce qui est attendu
Afin de réaliser une action métier (domaine fonctionnel)
En tant qu'acteur explicite du domaine fonctionnel
Je dois tirer un bénéfice de cette fonctionnalité
Scénario: Une description du scénario
Etant donné que [un contexte]
Et [plus d'informations sur le contexte]
@alexsoyes
alexsoyes / behat-en.feature
Created September 19, 2022 02:37
Behat avec Gherkin en anglais.
# from https://behat.org/en/latest/user_guide/gherkin.html
Feature: Some terse yet descriptive text of what is desired
In order to realize a named business value
As an explicit system actor
I want to gain some beneficial outcome which furthers the goal
Additional text...
Scenario: Some determinable business situation
@alexsoyes
alexsoyes / login.feature
Created September 19, 2022 02:35
Ghuerkin file with Cucumber for login authentication
Feature: Authentication
Scenario: User is login in
When the user is login in with valid credentials "[email protected]" and "test1234"
Then the user should have a valid uuid token
Scenario: User is login in (with bad info)
# todo
Scenario: User is login in (with expired password)
@alexsoyes
alexsoyes / login.step.ts
Created September 19, 2022 02:32
A step definition with Cucumber against login for functionnal testing.
import { Before, Then, When } from '@cucumber/cucumber';
import { TestingModule } from '@nestjs/testing';
import { getTestingModule } from '../../apps/core/src/shared/in-memory-orm.module';
import FixturesService from '../../apps/fixtures/src/fixtures.service';
import { AuthModule } from '../../apps/core/src/authentication/auth.module';
import { AuthService } from '../../apps/core/src/authentication/auth.service';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { PermissionsModule } from '../../apps/core/src/authentication/permissions/permissions.module';