Skip to content

Instantly share code, notes, and snippets.

View Demomaker's full-sized avatar
😀
Excited about the future

Demomaker Demomaker

😀
Excited about the future
View GitHub Profile
@Demomaker
Demomaker / clean_code.md
Created February 14, 2020 02:43 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@Demomaker
Demomaker / pow_int.py
Created August 1, 2021 06:13
Apply a power to a certain int value in python
def pow_int(valueToPower, power):
if not isinstance(valueToPower, int):
return valueToPower
resultingValue = 1
if power > 0 :
for i in range(0, power):
resultingValue = valueToPower * resultingValue
else :
if power < 0 :
for i in range(0, power):
@Demomaker
Demomaker / convert_int_to_scientific_notation.py
Created August 1, 2021 06:16
Convert an int value to scientific notation in python
def convert_int_to_scientific_notation(number):
scientificSymbol = "x10^"
decimalSeperationCharacter = '.'
stringEquivalent = str(number)
totalExponent = (len(stringEquivalent)-1)
if ("" + decimalSeperationCharacter) in stringEquivalent :
exponents = stringEquivalent.split(decimalSeperationCharacter)
positiveExponent = exponents[0]
negativeExponent = exponents[1]
totalExponent = (len(positiveExponent)-1) - (len(negativeExponent)-1)
@Demomaker
Demomaker / main.py
Last active August 1, 2021 06:41
General definition of a main file in python
# This part of the file is used for imports (ex. import math)
# Use this to create one-liner comments
'''Use these to create multiline comments or one-liner comments. This is the preferred way'''
# This part of the file is used for creating functions (ex. def main())
'''This main function can be renamed to anything really
'def' establishes a function, main is the name of the function and () is an empty set of parameters
In Python, the usage of ':' is preferred over the usage of '{' and '}'.
@Demomaker
Demomaker / calculate_2nd_power.py
Created September 23, 2021 04:09
Calculate the 2nd power of a number without using n * n
def get4SquareNumber(n):
if n == 1:
return 0.25;
return get4SquareNumber(n - 1) + 0.75 + 0.5 * (n-2);
def calculate2ndPower(n):
return get4SquareNumber(n) * 4;
@Demomaker
Demomaker / basics.ml
Created December 20, 2021 02:46
Basics of Ocaml
type anyType = IntElement of int | FloatElement of float | StringElement of string | BooleanElement of bool;;
let printStatement statement =
let open Printf in
printf "%s" statement;;
let concatStrings string1 string2 =
string1 ^ string2;;
let toString (x : anyType) =
@Demomaker
Demomaker / basics.pl
Created December 29, 2021 18:37
Basics of prolog
%! This is a comment
splitString(String, SplitString) :-
atom_chars(String, SplitString).
writeChars(Chars) :-
foreach(member(X, Chars), writeChar(X)).
writeChar(Char) :-
write(Char).
@Demomaker
Demomaker / linkedinvillesG0S.txt
Last active June 30, 2023 17:39
Code postaux Québec Canada LinkedIn et leur ville respective (pour G0S)
G0S 0A0 : Joly, Québec
G0S 0A1 : Laurierville, Québec
G0S 0A2 : Lotbinière, Québec
G0S 0A3 : Val-Alain, Québec
G0S 0A4 : Joly, Québec
G0S 0A5 : Saint-Gilles, Québec
G0S 0A6 : Saint-Édouard-de-Lotbinière, Québec
G0S 0A7 : Ste-Hénédine, Québec
G0S 0A8 : Dosquet, Québec
G0S 0A9 : Parisville, Québec