Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Chaumeny tchaumeny

  • Paris, France
View GitHub Profile
View RotatingCube.js
// RotatingCube React component, used in https://lipsum.dev/2020-09-1-rotations/
import * as BABYLON from 'babylonjs'
import * as GUI from 'babylonjs-gui'
import React, { useEffect, useRef, useState } from 'react'
const canvasWidth = 500;
const canvasHeight = 300;
function initScene(canvas, rotationCb) {
const engine = new BABYLON.Engine(canvas);
@tchaumeny
tchaumeny / polynomial.py
Last active May 24, 2020
Polynomial type in Python
View polynomial.py
# See https://lipsum.dev/2020-05-1-pourquoi-les-polynomes/
from numbers import Number
class Polynomial:
def __init__(self, *coefficients):
self.degree = -1
self.coefficients = tuple(coefficients)
for i, coef in enumerate(self.coefficients):
if coef != 0:
@tchaumeny
tchaumeny / money_amount_words.py
Last active Feb 17, 2017
Converting amount of money (including cents) to words using num2words
View money_amount_words.py
from num2words import num2words
def money_amount_words(amount, units='euros', cents='centimes', lang='fr'):
"""
Returns an iterator over the words describing the given amount
Args:
amount: decimal.Decimal, the amount of money
units: str, the currency units
You can’t perform that action at this time.