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
  • 07:20 (UTC +02:00)
  • Twitter @Natim
View GitHub Profile
@Natim
Natim / models.py
Created April 13, 2020 07:17
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 / Square.elm
Last active July 25, 2018 16:08
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 (..)
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 March 8, 2017 12:51
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 14:42
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
@Natim
Natim / scrap_amo_throttle.py
Created March 9, 2016 14:29
Scrap AMO with Python3 and asyncio
View scrap_amo_throttle.py
# -*- coding: utf-8 -*-
# This is PY3 only code using asyncIO
import asyncio
import aiohttp
import base64
import json
from random import randint
from kinto_client import Client, Endpoints
from pyquery import PyQuery as pyquery
@Natim
Natim / scrap_amo.py
Created March 9, 2016 12:30
For each addons, scrap AMO to get the who and why information.
View scrap_amo.py
# -*- coding: utf-8 -*-
# This is PY3 only code using asyncIO
import asyncio
import aiohttp
from pyquery import PyQuery as pyquery
async def fetch_info(session, record):
if 'blockID' not in record:
print("{} doesn't have a blockID".format(record['id']))
@Natim
Natim / hello.rst
Created December 21, 2015 14:59
How to connect to Firefox Hello with Firefox Account
View hello.rst
@Natim
Natim / get_random_token.py
Created December 15, 2015 14:06
Loadtesting with Firefox Account
View get_random_token.py
#!/usr/bin/env python
from __future__ import print_function
import base64
import hmac
import os
import sys
from six.moves.urllib.parse import urlparse
from fxa import core
from fxa import errors