Skip to content

Instantly share code, notes, and snippets.

View Abdelkrim's full-sized avatar

Abdelkrim from Brussels Abdelkrim

View GitHub Profile
@Abdelkrim
Abdelkrim / .git_hooks_commit-msg
Created February 20, 2020 13:20
standard-version :
#!/bin/sh
# INSTALLATION
#
# COPY THE FILE commit-msg INTO .git/hooks/commit-msg
# COPY THE FILE package.json INTO THE ROOT OF YOUR PROJECT
# MODIFY THE FILE package.json TO MATCH PROJECT DESCRIPTION
# RUN npm install to install standard-version locally
# CODE, COMMIT YOUR CODE
# RUN 'npm run patch', 'npm run minor' or 'npm run major' TO GENERATE THE VERSION NUMBER and THE CHANGELOG FILE
@Abdelkrim
Abdelkrim / conf.py
Created February 15, 2020 16:01
sphinx, conf.py, generate nice looking PDF file and reading the PREAMBLE latex-styling.tex
# -- Options for LaTeX output ------------------------------------------------
f = open('latex-styling.tex', 'r+')
PREAMBLE = f.read()
latex_elements = {
# https://www.sphinx-doc.org/en/master/latex.html
# 'classoptions': ',openany,twoside',
'classoptions': ',openany',
# 'babel' : '\\usepackage[french]{babel}',
@Abdelkrim
Abdelkrim / latex-styling.tex
Created February 15, 2020 15:59
sphinx, latex, resize figures that are too wide for the page and ensure they take the full width of the page
% Made by ALT-F1 SPRL, Abdelkrim Boujraf
%\usepackage{bookmark}
%\usepackage{charter}
%\usepackage[defaultsans]{lato}
%\usepackage{inconsolata}
% \usepackage{pbsi}
% \usepackage[T1]{fontenc}
@Abdelkrim
Abdelkrim / debugging_using_aspect_oriented_programming_aop.py
Last active January 29, 2020 00:16
debug methods like you would do it using Aspect Oriented Programming (AOP)
# python 3
def enter_exit_info(func):
def wrapper(*arg, **kw):
print(f'-- entering {func.__name__}')
res = func(*arg, **kw)
print(f'-- exiting {func.__name__}')
return res
return wrapper
@Abdelkrim
Abdelkrim / time_taken_to_execute_code.py
Created January 8, 2020 22:48
Python : Calculate time taken to execute a piece of code
# Python : Calculate time taken to execute a piece of code
import time
start_time = time.time()
a,b = 5,10
c = a+b
end_time = time.time()
time_taken = (end_time- start_time)*(10**6)
print("Time taken in micro_seconds:", time_taken) # Time taken in micro_seconds: 39.577484130859375
@Abdelkrim
Abdelkrim / reverse_a_string.py
Created January 8, 2020 22:46
Python : Reverse a string
language = "python"
reversed_language = language[::-1]
print(reversed_language) # nohtyp
@Abdelkrim
Abdelkrim / is_even.py
Created January 8, 2020 22:45
Python : Check if the given number is even
def is_even(num):
return num % 2 == 0
is_even(10) # True
@Abdelkrim
Abdelkrim / swap.py
Created January 8, 2020 22:44
Python : Swap values between two variables
# Swap values between two variables
a = 5
b = 10
a, b = b, a
print(a) # 10
print(b) # 5
@Abdelkrim
Abdelkrim / format_values.py
Last active March 22, 2025 22:34
format values per thousands using python 3 : K-thousands, M-millions, B-billions.
def sizeof_number(number, currency=None):
"""
format values per thousands : K-thousands, M-millions, B-billions.
parameters:
-----------
number is the number you want to format
currency is the prefix that is displayed if provided (€, $, £...)
"""
build
chore (maintain i.e. updating grunt tasks etc; no production code change)
ci (continuous integration)
docs: add Blaze to list of projects
feat: Adding French translation
fix (bug fix)
perf (performance improvements)
refactor
revert
style: Welcome page tweaks for long texts. Removing ettier unnecessary changes