Skip to content

Instantly share code, notes, and snippets.

View fxg42's full-sized avatar

François-Xavier Guillemette fxg42

View GitHub Profile
@fxg42
fxg42 / index.js
Created February 16, 2017 21:15
Currency format
const reverseString = (s) =>
s.split('').reverse().join('')
export const currency = (amount = 0, currencyCode, lang) => {
try {
const decimalSep = lang === 'fr' ? ',' : '.'
const thousandSep = lang === 'fr' ? ' ' : ','
const [ integer, decimal ] = amount.toFixed(2).split('.')
const delim = reverseString(reverseString(integer).replace(/(\d{3})(?=\d)/g, `\$1${thousandSep}`))
@fxg42
fxg42 / w.js
Last active February 13, 2017 03:03
Useless tag function...
//
// Splits a string containing words separated by spaces into a list of those
// words. The function should be used as a tag i.e.
//
// w`foo bar ${'b' + 'az'}` => [ 'foo', 'bar', 'baz' ]
//
export const w = (templateObj, ...substitutions) => String.raw({ raw: templateObj }, ...substitutions).trim().split(/\W+/)
@fxg42
fxg42 / index.js
Last active February 20, 2017 15:00
Signed token generation with Node
/*
* Copyright 2017 CODE3 Coopérative de solidarité
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
@fxg42
fxg42 / laboratoire9.md
Created November 17, 2016 23:33
Laboratoire no 9

Laboratoire no 9

Exercice 1

Écrivez un programme qui additionne tous les nombres contenus dans un fichier. Chaque ligne du fichier contient un nombre réel.

Exercice 2

Écrivez un programme qui lit une fiche informationnelle et stock l'information dans une instance de la classe Fiche. Le fichier ressemble à:

Laboratoire no 7

Exercice 1

Sans utiliser le module Math, complétez les fonctions suivantes:

public static int min (int a, int b) {
  // Retourne la valeur minimale entre a et b.
}
@fxg42
fxg42 / README.md
Last active September 23, 2016 12:30
INF1256 A2016. Laboratoire no 3

Laboratoire no 3

Exercice 1

Écrivez un programme qui lit deux nombres au clavier puis qui affiche le résultat d'opérations mathématiques. Par exemple:

Entrez x: 123
Entrez y: 567.78
x + y = 690.780000

x - y = -444.780000

Évaluation pour INF4375 à l'été 2016

Commentaires de mes étudiants concernant le cours INF4375 à l'été 2016.

Commentaire 1

Excellent cours!

Commentaire 2

Il devrait avoir plus de cours comme celui là, où ont apprend les vrais technologies utilisés en entreprise. Le professeur sait rendre la matière intéressant, et apporte des exemples concrets.

@fxg42
fxg42 / question2.py
Last active May 1, 2016 13:12
Final INF1256
def somme(liste_nombres):
position = 0
longueur = len(liste_nombres)
somme = 0
while position < longueur:
somme += liste_nombres[position]
position += 1
return somme
print somme([ 1, 2, 3, 2, 1 ])
@fxg42
fxg42 / cours.py
Last active April 18, 2016 01:45
INF1256: Exemples de programmation OO vus en classe
import datetime
import string
import math
import random
class Cours(object):
def __init__(self, sigle):
self.sigle = sigle
self.groupes_cours = [ ]
@fxg42
fxg42 / premiere_version.py
Created March 15, 2016 00:56
Feuille de temps INF1256
def ajouter_heures (semaine, jour, nb_hres):
semaine[jour] = min(24.0, semaine[jour] + nb_hres)
def retirer_heures (semaine, jour, nb_hres):
semaine[jour] = max(0.0, semaine[jour] - nb_hres)
def total_heures (semaine):
total_hres = 0.0
for jour in semaine:
total_hres = total_hres + semaine[jour]