Skip to content

Instantly share code, notes, and snippets.

View bactisme's full-sized avatar

Baptiste M. bactisme

View GitHub Profile
@bactisme
bactisme / gist:6305544
Created August 22, 2013 10:17
Using PIL to extract geo (GPS) EXIF data. Extract position from a list of images containing EXIF information. Very poorly written :/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image
from PIL.ExifTags import TAGS
from pprint import pprint
def get_exif(fn):
try:
ret = {}
@bactisme
bactisme / gist:6414498
Last active December 1, 2021 20:30
Télécharge les dernières factures présentent sur l'admin OVH. Utilise l'API REST OVH. Tout cela en python ! Please do whatever you want to do with that.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# DOWNLOAD LAST BILLS ON OVH VIA REST API
import requests
from pprint import pprint
from lxml import html, etree
import StringIO
import json
#!/bin/python
# pip install requests
import requests
from requests.auth import HTTPBasicAuth
def get_distributors(base_url, auth):
print "--- GET HOTELS"
url = base_url + "/api/distributors.json"
r = requests.get(url, auth=auth)
<?php
namespace Sidereo\CoreBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sidereo\CoreBundle\Entity\App;
@bactisme
bactisme / Calcul de l'impot français par tranche.js
Last active February 4, 2022 22:49
Calcul de l'impot français par tranche (javascript)
// http://www.impots.gouv.fr/portal/dgi/public/popup?espId=1&typePage=cpr02&docOid=documentstandard_6182
// Impots sur revenus 2018
// Voir commentaire du gist pour les années suivantes
function impotBareme(montant){
var impot = 0;
var tranches = new Array();
tranches.push([6011, 0]);
tranches.push([11991, 0.055]);
tranches.push([26631, 0.14]);
@bactisme
bactisme / dump-all.sh
Last active August 29, 2015 14:21
restore-from-folder.sh
#!/bin/bash
# DEPLOYED WITH ANSIBLE
DESTFOLDER="/root/backups"
MAIL="b@example.org"
DIST_SERVER="backup-user@backup.server.com"
DIST_FOLDER="/home/backup-user/"
LOGFILE=$$.log
echo "" > $LOGFILE
@bactisme
bactisme / keep-versions.py
Created June 17, 2015 11:18
Keep two version of my vzdump rsynced files
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import os
import os.path
import re
class VMFileRotator:
def __init__(self, path, regexp, max_keep = 2):
@bactisme
bactisme / cut_tags_stats.py
Created October 27, 2015 10:18
Cut Tags Stats
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import operator, sys
def split_tags(string):
return [x for x in string.replace('{', '').split('}') if x]
class CutTagsStats:
@bactisme
bactisme / nginx_status_codes.py
Last active April 7, 2022 04:11
Very simple munin plugin to graph nginx HTTP error codes
#!/usr/bin/python
# ALL FAME GOES HERE : https://gist.github.com/mipearson/1146151
#
# 1/ Place where you want (like /usr/share/munin/plugins/nginx_status_codes.py )
# 2/ Link in /etc/munin/plugins/ :
# ln -s /usr/share/munin/plugins/nginx_status_codes.py /etc/munin/plugins/nginx_errors
# chmod +x /etc/munin/plugins/nginx_errors
# 3/ Test with
# munin-run nginx_errors
# 4/ If nescessary : add these lines in your munin conf
@bactisme
bactisme / check_images_sizes
Created April 26, 2016 13:59
Take a file containing a liste of URL, print average, sum and max file size
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from lxml import html
import sys
def sum_avg_max(images):
total = sum(s for url, s in images)