Skip to content

Instantly share code, notes, and snippets.

View Natim's full-sized avatar
🏠
Working from home

Rémy HUBSCHER Natim

🏠
Working from home
  • Silvr
  • Rennes
  • 23:58 (UTC +02:00)
  • X @Natim
View GitHub Profile
@Natim
Natim / README.md
Last active January 15, 2024 21:35
From TAEG to Commission

From TAEG to Commission

Understanding TAEG

TAEG is the Taux Annuel Effectif Global, it is the cost of money for a year with the current fees on the loan.

From an amortization table, you can compute it like that:

+------------+--------------+
@Natim
Natim / ini2json.py
Created January 11, 2013 10:21
Convert an ini configuration file into a json file
# -*- coding: utf-8 -*-
import json
import sys
from ConfigParser import (ConfigParser, MissingSectionHeaderError,
ParsingError, DEFAULTSECT)
class StrictConfigParser(ConfigParser):
def _read(self, fp, fpname):
@Natim
Natim / asyncio_ls.py
Created April 7, 2014 19:56
AsyncIO LS
import asyncio.subprocess
@asyncio.coroutine
def demo():
proc = yield from asyncio.create_subprocess_exec('ls', '-1', stdout=asyncio.subprocess.PIPE)
while True:
line = yield from proc.stdout.readline()
if not line:
break
print(line)
@Natim
Natim / permission.py
Last active January 10, 2022 03:53
How to handle our permission schema with Redis
# -*- coding: utf-8 -*-
from __future__ import print_function
import json
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=1)
# List of permissions that gives us this permission
PERMISSIONS_INHERITANCE = {
'bucket:write': {
@Natim
Natim / morse.py
Last active January 10, 2022 03:53
Morse
lettre_morse = {
"a": ".-",
"b": "-...",
"c": "-.-.",
"d": "-..",
"e": ".",
"f": "..-.",
"g": "--.",
"h": "....",
"i": "..",
from functools import partial
RULES = {
'six_h': {'high': 390, 'low': 330},
'twelve_h': {'high': 750, 'low': 690},
'twentyfour_h': {'high': 1490, 'low': 1410},
'seven_d': {'high': 169, 'low': 168}
}
@Natim
Natim / language_app.py
Created August 18, 2012 08:40
Flask language_dispatch : Detect the user language and redirect to the right domain_name
# -*- coding: utf-8 -*-
import locale
import re
from flask import Flask, redirect, request
app = Flask(__name__)
LANGUAGE_CODES = ('fr', 'en', 'zh')
DOMAIN_NAME = 'example.com'
@Natim
Natim / models.py
Created April 13, 2020 07:17
Register m2m changed event.
# Voir https://docs.djangoproject.com/fr/3.0/ref/signals/#m2m-changed pour plus d'infos
@receiver(m2m_changed, sender = VisiteMedicale.animaux.through)
def visite_medicale_save_action(sender, instance, **kwargs):
if reverse:
# Cas de popi.visite_medicale_set.remove(sterilisation_20200413)
animaux = [instance]
visite_medicale = model.objects.get(pk__in=pk_set)
else:
# Cas de sterilisation_20200413.animaux.add(Popi)
@Natim
Natim / shrinkpdf.sh
Created March 26, 2014 17:37
Smaller your PDF before sending them by email
#!/bin/sh
# http://www.alfredklomp.com/programming/shrinkpdf
# Licensed under the 3-clause BSD license:
#
# Copyright (c) 2014, Alfred Klomp
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@Natim
Natim / Square.elm
Last active July 25, 2018 16:08
From bottom to top, floating animation showcase
module Square exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Animation exposing (px, percent)
import Time exposing (second)
import Ease exposing (..)