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
  • Yampa
  • Rennes
  • 12:10 (UTC +02:00)
View GitHub Profile
@Natim
Natim / README.rst
Created August 25, 2014 21:09
Use a DNS TXT entry to configure a ramp up number for a slow software activation

Ramp Up

The problem

The idea of the ramp up is to have a scalable way to activate a software feature slowly so that the scale is handled.

If you have let say 10 million users and you want to launch a most wanted feature.

@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 / 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 / uuid_from_text.py
Created March 17, 2014 08:52
UUID from text
import hashlib
import sys
from uuid import UUID
text = sys.stdin.read()
print UUID(hashlib.sha256(text).hexdigest()[:32])
@Natim
Natim / cutfdu.py
Created February 14, 2014 15:32
Faster count uniq cut file (for flake8 or log for instance) (Thx @boblefrag for http://snippet.gabory.fr/snippet/9/)
# From http://snippet.gabory.fr/snippet/9/
# Similar to `cut -d ":" -f 1 | sort | uniq -c | sort -n`
#
# Usage: flake8 venv | python cutfdu.py
# Mock : flake8 venv | cut -d ":" -f 1 | sort | uniq -c | sort -n
#
# From Natim with love (2014-02-14)
import itertools
import sys
@Natim
Natim / gist:8456937
Last active January 3, 2016 11:29
Dans @capitainetrain -- Ouvrir tous les billets passé puis :
var value = 0;
var regex = /[+-]?\d+\,\d+/g;
$('.ember-view .price').each(function(){ value += $(this).html().match(regex).map(function(v) { return parseFloat(v.replace(',', '.')); })[0] });
console.log(value);
@Natim
Natim / requete.sql
Created December 3, 2013 15:20
Première requête PostGIS
SELECT numero, geom FROM parcelle
WHERE ST_Intersects(geom, ST_Transform(
ST_ConvexHull('SRID=4326;MULTIPOINT(2.232 48.818,
2.246 48.82,
2.241 48.809,
2.232 48.818)'::geometry),
27572));
@Natim
Natim / 25square.py
Last active December 25, 2015 22:29
Python2 and Python3 compatible carre de 25 encoder and decoder
# -*- coding: utf-8 -*-
from __future__ import print_function
from six.moves import input, xrange, map
from string import ascii_letters
alphabet = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
def get_maps(keyword):
keyword = keyword.upper().replace('W', 'V')
@Natim
Natim / decodage.py
Created September 27, 2013 14:53
Carré de Polybe
# -*- coding: utf-8 -*-
M = [["A", "B", "C", "D", "E"],
["F", "G", "H", "IJ", "K"],
["L", "M", "N", "O", "P"],
["Q", "R", "S", "T", "U"],
["V", "W", "X", "Y", "Z"]]
def decode(texte):
@Natim
Natim / gist:6722268
Created September 26, 2013 23:56
Django selecteur de langue
{% load static i18n i18nurl %}
{% get_available_languages as LANGUAGES %}
{% for language_code, language_name in LANGUAGES %}
{% language language_code %}
<li><a href="#{{ language_code }}" class="{% if language_code == LANGUAGE_CODE %} active{% endif %}" data-lang="{{ language_code }}" data-next="{% current_i18nurl language_code %}"><i class="sprite-flag-{{ language_code }}"></i>{{ language_name }}</a></li>
{% endlanguage %}
{% endfor %}
<script type="text/javascript">