Skip to content

Instantly share code, notes, and snippets.

View BertrandBordage's full-sized avatar

Bertrand Bordage BertrandBordage

View GitHub Profile
find -iname "*.jpg" -type f -print0 | parallel --progress -0 -j +0 "mogrify -resize 800x800\> {}"
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
'''
def cache_generics(queryset):
@BertrandBordage
BertrandBordage / crawl_readonly.sh
Created January 26, 2015 19:09
Crawl a website by reading web pages without saving
wget -r --spider http://yoursite.you
@BertrandBordage
BertrandBordage / Dockerfile
Created January 30, 2015 14:44
Wagtail demo Dockerfile
# Build this docker image using: docker build -t wagtail-demo [path_to_the_folder_containing_this_file]
# Run it using: docker run -p 8000:8000 wagtail-demo
FROM ubuntu:14.10
MAINTAINER Bertrand Bordage, [email protected]
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install postgresql postgresql-server-dev-9.4 build-essential \
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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
@BertrandBordage
BertrandBordage / autoreplyer.py
Last active June 20, 2025 03:10
Automatically reply to unread and unanswered messages in Python
"""
Automatically replies to mails both unread and unanswered.
WARNING: This answers to any both unread and unanswered mail, even if it is years old.
Don’t use on a mailbox with old messages left unread and unanswered.
Simply subclass ``AutoReplyer``, define the undefined class attribute,
and call the ``run`` method on an instance. This loops until you stop the script
(using Ctrl+C, typically) or until an error occurs, like a network failure.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/less">
body {
margin: 30px;
font-family: Helvetica, sans-serif;
}
.wysiwyg {