Skip to content

Instantly share code, notes, and snippets.

View VieVie31's full-sized avatar
👨‍💻
@universite-de-paris

Olivier RISSER-MAROIX VieVie31

👨‍💻
@universite-de-paris
View GitHub Profile
/**
* Apply a callback on audio data provided as a blob data url ("blob:http://...")
* `processAudioBlobURLinBase64(audio.src, (b64) => console.log(b64));`
*/
function processAudioBlobURLinBase64(audioBlobURL, callback) {
fetch(audio.src).then((a) => a.blob().then(
(blob) => {
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function () {
@VieVie31
VieVie31 / crop_black_border.py
Last active April 29, 2020 19:21
Crop black borders in image with python (robust to watermark putted in)…
import numpy as np
import matplotlib.pyplot as plt
from skimage.io import imread
from skimage.filters import sobel
from skimage.transform import resize
from skimage.morphology import binary_erosion
from scipy.ndimage.filters import maximum_filter1d
import numpy as np
import scipy.sparse as sp
import matplotlib.pyplot as plt
from scipy.spatial.distance import cdist
from sklearn.cluster import AgglomerativeClustering
from skimage.io import imread
from skimage.color import rgb2hsv
"""
Script to dowload video from the ARTE recording of the Paris's Philarmonie.
Example:
python3 download.py "https://www.arte.tv/fr/videos/087078-007-A/kazuki-yamada-dirige-berlioz-et-jarrell/"
python3 download.py "https://www.arte.tv/fr/videos/087078-007-A/kazuki-yamada-dirige-berlioz-et-jarrell/" my_output_name.mp4
"""
import os
import sys
import json
@VieVie31
VieVie31 / dynamic_properties.py
Last active March 2, 2019 20:32
convert automatically all attribute of a dataclass (inherited from mine) into properties with standard setter/getter to the corresponding hidden attribute and keep in memory the timestamp of the last set/get action on it...
import gc
import os
import re
import time
import types
import pickle
import psutil
import pathlib
import threading
@VieVie31
VieVie31 / memory_friendly_class.py
Created March 1, 2019 14:09
just a test with a class with only one attribute... the goal is to serialize the attributes of the class to free memory when too much memory is used... (python 3.7 only)
import gc
import os
import time
import pickle
import psutil
import pathlib
import threading
from dataclasses import dataclass, field
from typing import Any
import turtle
from random import randint
SIZE = 500
#setup the screen
SCREEN = turtle.Screen()
SCREEN.title("snake")
SCREEN.setup(SIZE + 50, SIZE + 50)
SCREEN.bgcolor("black")
@VieVie31
VieVie31 / download.sh
Last active July 14, 2021 11:08
download PIERRE-EMMANUEL BARRÉ podcasts on france inter
curl "https://media.radiofrance-podcast.net/podcast09/13939-12.04.2017-ITEMA_21289880-4.mp3" > "La drôle dhumeur de Pierre-Emmanuel Barré.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/14212-29.03.2017-ITEMA_21274987-0.mp3" > "La campagne électorale va trop vite.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/14212-22.03.2017-ITEMA_21267521-0.mp3" > "France Inter, radio bolchévique.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/14212-15.03.2017-ITEMA_21260072-0.mp3" > "Dignité, tu mauras pas ?.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/15275-08.03.2017-ITEMA_21253600-14.mp3" > "Qui survivra à lapocalypse ?.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/15275-01.03.2017-ITEMA_21246201-14.mp3" > "Le programme de Macron.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/13939-22.02.2017-ITEMA_21237840-6.mp3" > "Le débat politique à la télé, pourquoi faire ?.mp3"
curl "https://media.radiofrance-podcast.net/podcast09/13939-08.02.2017-ITEMA_2122