Skip to content

Instantly share code, notes, and snippets.

View BertrandBordage's full-sized avatar

Bertrand Bordage BertrandBordage

View GitHub Profile
# WARNING: This is just a workaround. Consider it as a very
# temporary solution if you really need this feature.
from django.utils.safestring import mark_safe
from django_select2.util import convert_to_js_arr
TEMPORARY_ID = 0
@BertrandBordage
BertrandBordage / Cython simple class benchmark.ipynb
Created January 25, 2014 16:27
Cython simple class benchmark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BertrandBordage
BertrandBordage / arte_downloader.py
Last active February 14, 2016 19:48
Arte downloader
#!/usr/bin/env python3
import json
from math import ceil
import re
from subprocess import check_output
import sys
from urllib.parse import unquote
from urllib.request import urlopen
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/less">
body {
margin: 30px;
font-family: Helvetica, sans-serif;
}
.wysiwyg {
@BertrandBordage
BertrandBordage / to_html5_videos.py
Last active September 22, 2016 15:09
Converts most videos to the same quality HTML5-compatible MP4+OGV
# coding: utf-8
"""
Converts videos inside the current directory to two complementary
HTML5 video formats while keeping the same quality.
The converted videos are placed in a subfolder.
You need avconv to be installed with some codecs
(packages libav-tools & libavcodecs-extra under Ubuntu)
"""
@BertrandBordage
BertrandBordage / locmem.py
Created October 25, 2015 15:34
Django LocMem cache backend without pickle
"Thread-safe in-memory cache backend."
import time
from contextlib import contextmanager
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.utils.synch import RWLock
# Global in-memory store of cache data. Keyed by name, to provide
#!/usr/bin/env python
from argparse import ArgumentParser
from io import BytesIO
import re
from xml.etree import ElementTree
NAMESPACED_RE = re.compile(r'^\{(.+)\}.+$')
SVG_NAMESPACE = 'http://www.w3.org/2000/svg'
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BertrandBordage
BertrandBordage / SQLAlchemy_vs_peewee.ipynb
Last active July 29, 2021 09:41
SQLAlchemy vs peewee
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BertrandBordage
BertrandBordage / cat.asm
Created April 16, 2014 19:04
Command-line read file in X86_64 intel assembly for Linux
; À compiler avec nasm -felf64 cat.asm && ld cat.o -o cat
%define SYS_EXIT 60
%define SYS_READ 0
%define SYS_WRITE 1
%define SYS_OPEN 2
%define SYS_CLOSE 3
%define STDOUT 1
%define BUFFER_SIZE 2048