Skip to content

Instantly share code, notes, and snippets.

View hamzahamidi's full-sized avatar
👀
I may be slow to respond.

Hamza Hamidi hamzahamidi

👀
I may be slow to respond.
View GitHub Profile
def validate(num, name):
if not num.isnumeric():
raise ValueError(f'Le format de {name} n\'est pas valide')
output = int(num)
if output < 0 or 100 < output:
raise ValueError(
f'La veleur de {name} doit être comprise entre 0 et 100')
return output
a = input('Entrez la valeur de A: ')
@hamzahamidi
hamzahamidi / .editorconfig
Created April 14, 2021 17:44
standard editor config for visual studio
rpad# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
@hamzahamidi
hamzahamidi / pagination.js
Last active June 30, 2022 23:34
creates a pagination object (useful to format the result of a DB query)
export const pagination = (paginationParams = {}) => ({
...paginationParams,
limit: paginationParams.limit || 20,
offset: paginationParams.offset || 0,
totalCount: paginationParams.totalCount || 0,
get currentPage() {
return Math.floor(this.offset / this.limit) + 1;
},
get hasNext() {
return this.currentPage * this.limit < this.totalCount;