Skip to content

Instantly share code, notes, and snippets.

View simoninmath's full-sized avatar

simoninmath simoninmath

View GitHub Profile
@simoninmath
simoninmath / .gitignore
Created April 26, 2025 15:00
Std .gitignore file
# Compilation files
bin/
obj/
*.exe
*.dll
*.pdb
*.cache
*.ilk
*.ncb
*.suo
@simoninmath
simoninmath / TwoSums.cs
Created February 17, 2025 09:33
Two sums exercice
// PSEUDO CODE
// Function TwoSumFinalIteration(nums : List<int>, target : int) : List<int>
// Var
// collection : Dictionary<int, int>
// value : int
// Start
// If nums.Length < 2 OR nums.Length > 10000 OR target < -1000000000 OR target > 1000000000 Then
// Display "Constraints not respected!"
@simoninmath
simoninmath / IntPalindrome.cs
Last active February 17, 2025 09:30
Int Palindrome exercice
// PSEUDO CODE
// Function ConvertIntToString(x : int) : List<string>
// Var convertedInt: List<string>
// Start
// convertedInt <- new List<string>()
// Foreach char in x.ToString()
// Append char.ToString() to convertedInt
@simoninmath
simoninmath / RandomMethod.cs
Created February 9, 2025 21:14
Random Method
namespace csharp_method
{
public class RandomMethod
{
public void DisplayRandomNumbers()
{
Random random = new Random();
for (int i = 0; i < 5; i++)
{
@simoninmath
simoninmath / footer.component.scss
Created January 20, 2024 16:53
Footer style with media queries
@simoninmath
simoninmath / http-client.service.ts
Last active January 1, 2024 11:17
Create an Angular HttpClient Service
// 1 - Service "newsletter": call the DB Table named "newsletter" and get email addresses form this Table with HttpClient method
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, map, pipe, tap } from 'rxjs';
import { Newsletter } from '../model/newsletter';
@Injectable({
providedIn: 'root'
})
@simoninmath
simoninmath / detail.component.ts
Created December 19, 2023 17:37
Dynamic Titles
// For list and details logic
ngOnInit() {
const figurineId: string | null = this.route.snapshot.paramMap.get("id");
if(figurineId) {
this.figurineService.getFigurineById(+figurineId).subscribe(figurine => { // Get dynamic titles in detail section
this.figurine = figurine;
this.initTitle(figurine);
});
}
import { inject } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from './auth.service';
// Refactored with Guard Function and inject()
export const AuthGuard = () => {
const authService = inject(AuthService);
const router = inject(Router);
if(authService.isLoggedIn) {
@simoninmath
simoninmath / login.component.ts
Created December 19, 2023 11:06
Logic Login Component
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styles: [
]
})
@simoninmath
simoninmath / login.component.html
Created December 19, 2023 11:05
Login Form Template
<div class='row'>
<div class="col s12 m4 offset-m4">
<div class="card hoverable">
<div class="card-content center">
<span class="card-title">Page de connexion</span>
<p><em>{{message}}</em></p>
</div>
<form #loginForm="ngForm">
<div>
<label for="name">Name</label>