Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rémy HUBSCHER Natim

🏠
Working from home
View GitHub Profile
@Natim
Natim / ini2json.py
Created Jan 11, 2013
Convert an ini configuration file into a json file
View ini2json.py
# -*- coding: utf-8 -*-
import json
import sys
from ConfigParser import (ConfigParser, MissingSectionHeaderError,
ParsingError, DEFAULTSECT)
class StrictConfigParser(ConfigParser):
def _read(self, fp, fpname):
@Natim
Natim / language_app.py
Created Aug 18, 2012
Flask language_dispatch : Detect the user language and redirect to the right domain_name
View language_app.py
# -*- 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 Apr 13, 2020
Register m2m changed event.
View models.py
# 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 Mar 26, 2014
Smaller your PDF before sending them by email
View shrinkpdf.sh
#!/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 Jul 25, 2018
From bottom to top, floating animation showcase
View Square.elm
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 (..)
@Natim
Natim / vimeo.html
Created Apr 3, 2012
Vimeo Javascript Display Thumb
View vimeo.html
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
function vimeoLoadingThumb(id){
var url = "http://vimeo.com/api/v2/video/" + id + ".json?callback=showThumb";
var id_img = "#vimeo-" + id;
var script = document.createElement( 'script' );
script.type = 'text/javascript';
View Types.elm
type alias Page =
{ name : String
, url : String
, created_at : Date
, title : String
, description : String
, url : String
}
View dynamic_methods.py
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 / get_anchors.py
Last active Mar 8, 2017
Get anchors from Woleet
View get_anchors.py
import aiohttp
import asyncio
import os
WOLEET_SERVER = 'https://api.woleet.io/v1'
WOLEET_HEADERS = {
'Authorization': 'Bearer {}'.format(os.getenv('WOLEET_BEARER_TOKEN')),
'Content-Type': 'application/json'
}
@Natim
Natim / README.md
Created May 25, 2016
A first kinto_bootstrap PoC
View README.md

To use it:

python kinto_bootstrap.py -s http://localhost:8888 -a token:my-token -v
$ python kinto_bootstrap.py --help
usage: kinto_bootstrap.py [-h] [-s SERVER] [-a AUTH] [-b BUCKET] [-v] [-q]
                          [-D]

Bootstrap bucket
You can’t perform that action at this time.