Skip to content

Instantly share code, notes, and snippets.


sleblanc sebleblanc

  • /dev/tty0
View GitHub Profile
sebleblanc / biling.lhs
Last active July 26, 2020 06:36
Bilingual (tri-, quadrilingual…) strings
View biling.lhs
I had to deal with bilingual strings from an XML API (Canadian weather
website) in a short script that I wrote. I wanted a way to handle
those that was lightweight and simple.
First we define a sum type for languages that we support. Thanks to
this type, we can ensure through exhaustive pattern matching that we
have always included all supported languages in a string. It is so
simple to implement that it remains simple while still making use of
the safeties of the type system.
ffmpeg -codec:a libvorbis -qscale:a 3 \
-content_type 'audio/ogg' \
-vn -f ogg icecast://source:PASSWORD@icecast:8001/$name_vorbis
sebleblanc /
Last active August 29, 2015 14:21
Convert a Python script to a module
def print_a(a=1):
print("The value of a is", a)
sebleblanc / Installing
Last active December 30, 2017 10:35
Installing flexget in a virtualenv
View Installing

To avoid clashes with packages installed on your system, FlexGet can be installed in a Python virtualenv. A virtualenv is similar to a chroot, but specific to Python packages. Creating a virtualenv is a simple process. The virtualenv will contain its own Python interpreter and its own versions of downloaded dependencies, separate from the system's packages.

Creating a virtualenv is a standard procedure in a Python web application deployment.

Let's create a folder in which to create the virtualenv:

mkdir ~/virtualenv # or any name you prefer
cd ~/virtualenv

Now, create the virtualenv itself and make it relocatable. For some reason, we have to create a regular virtualenv before making it relocatable:

sebleblanc / gist:da93244228cb5acd7789
Created April 3, 2015 00:55
Extract images from a multipart email message.
View gist:da93244228cb5acd7789
Extract images from a multipart email message.
This script will open an email file named "email.txt" and
extract any file that matches the content type 'image/.*'.
It will save it in a folder called "images".
The format of the email is the same as the format you get when
you choose "Show Original" in Gmail.