Skip to content

Instantly share code, notes, and snippets.

View beledouxdenis's full-sized avatar

Denis Ledoux beledouxdenis

View GitHub Profile
# Add the below code in your Python file,
# then add @own_profiler as a decorator on the method you would like to profile.
# Note:
# - If there is already a decorator on the method, set @own_profiler above,
# - Each time the method is called, it generates a new profile file,
# don't set this decorator on a method called hundred of times or you will have hundred of profile files to analyze.
#
# To display the resulting profiling data file:
#
# Snakeviz: Callstack layer graph & stats table
@beledouxdenis
beledouxdenis / self-hosted-ngrok.md
Last active April 17, 2019 14:08
Auto-starting self hosted Ngrok (requires a server with Nginx and a registered domain)

On the remote server

vim /etc/nginx/sites-enabled/tunnel_yourdomain_com
server {
    server_name tunnel.yourdomain.com;
#!/usr/bin/env python3
import webbrowser
from fnmatch import fnmatch
from optparse import OptionParser
import requests
from lxml import html
@beledouxdenis
beledouxdenis / dell-vostro-5481-noisy-fan.md
Last active February 25, 2020 10:16
Dell Vostro 5481 Ubuntu Noisy fans solution

Make sure to disable secure boot in bios, otherwise /usr/local/bin/dell-bios-fan-control 0 will return a segfault.

cd /tmp
git clone https://github.com/TomFreudenberg/dell-bios-fan-control
cd dell-bios-fan-control
make
sudo cp dell-bios-fan-control /usr/local/bin/
sudo apt install i8kutils
sudo mkdir /etc/systemd/system/i8kmon.service.d
echo "[Service]
@beledouxdenis
beledouxdenis / odoo-send-email.py
Last active May 16, 2019 12:47
Send an email to Odoo
#!/usr/bin/env python3
import base64
import requests
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from urllib.parse import urljoin
parser = ArgumentParser(description='Send an email to Odoo databases',
formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('eml_file', help='EML File to send')
@beledouxdenis
beledouxdenis / autosort.py
Last active May 23, 2019 13:16
Sort automatically videos folder into Movies / TV Shows folders with season hierarchy, using symlinks, then update the library on Kodi.
#!/usr/bin/python3
import os
import re
import requests
import subprocess
from Levenshtein import distance
DOWNLOAD_DIR = '/media/Downloads/'
MOVIES_DIR = os.path.expanduser('~/Movies/')
@beledouxdenis
beledouxdenis / odoo-all-modules.py
Last active October 16, 2019 09:04
Display all modules of Odoo to install, as on runbot.
#!/usr/bin/env python3
import os
import sys
BLACKLIST = ['auth_ldap', 'document_ftp', 'base_gengo',
'website_gengo', 'website_instantclick',
'pad', 'pad_project', 'note_pad',
'pos_cache', 'pos_blackbox_be', 'hw_', 'theme_', 'l10n_']
version = sys.argv[1]
@beledouxdenis
beledouxdenis / print-badge.py
Created October 17, 2019 16:17
Print Odoo Experience Badge
#!/usr/bin/env python3
import base64
import subprocess
import threading
import requests
def print_badge(barcode):
pdf_filename = "badge-%s.pdf" % barcode
@beledouxdenis
beledouxdenis / server.py
Created January 3, 2020 15:26
Multi-threaded HTTP(S) server
#!/usr/bin/env python3
import threading
import time
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingMixIn
USE_HTTPS = False
if USE_HTTPS:
import ssl
@beledouxdenis
beledouxdenis / flood.py
Created January 3, 2020 15:27
Multi-threaded requests flood to HTTP server
#!/usr/bin/env python3
import requests
import sys
import threading
from urllib3.exceptions import InsecureRequestWarning
# Suppress only the single warning from urllib3 needed.
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)