Ludochaordic
Fantaisies programatico-ludiques

Python module imports visualization

flask httpie requests simplejson botocore scrapy docker-compose ansible What are those diagrams ? They show dependencies between the internal modules of various well-known Python libraries. They goal is to provide a global overview of a Python project architecture, as a map of modules & packages, the top-level code abstractions. Note that all …

Read More

Glitch art and image processing with Python

This one above reminds me of The Great Wave off Kanagawa. Like many …

-->

This week I discovered the fantastic glitch art Reddit community (for a little more context on glitch art, wikipedia has a page). These are the pieces I love the most (click on them to find the source): This one above reminds me of The Great Wave off Kanagawa. Like many …

Read More

Free alerting-as-a-service drop-in replacement for mail command

On my personnal server, I used to send myself alerts by email using the handy standard mail command. However, recently it appeared that my server became categorized as "spammer" by some online service providers, due to the alerts frequency (a little bit more than one per day). Hence, I got …

Read More

Certification développeur RGAA Access42

Connaissez-vous l'accessibilité numérique ? En très bref: L'accessibilité numérique est la mise à la disposition de tous les individus, quels que soient leur matériel ou logiciel, leur infrastructure réseau, leur langue maternelle, leur culture, leur localisation géographique, ou leurs aptitudes physiques ou mentales, des ressources numériques. Pour plus de détails …

Read More

Compte-rendu de la PyConFr 2017

Cette année, voyages-sncf.com m'a permis d'aller à la conférence annuelle Python à Toulouse. En vrac, voici un petit résumé personnel de cette PyConFr. J'y étais présent 3 jours sur 4 (sprint le premier et conférences les deux autres), et j'y ai donné donné 2 présentations, dont le contenu est …

Read More

Extracting setup_requires dependencies out of a setup.py

I ended up not using this code, but it may be useful to others: mock_setup_provider.py: import sys from unittest.mock import Mock class MockSetupProvider(Mock): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.captured_setup_requires = set() def setup(self, *args, **kwargs): self.captured_setup_requires.update(kwargs.get('setup_requires')) setup_extractor …

Read More

Python gevent terrible failure mode under Windows

What do you think of the following innocuous Python code ? from gevent import monkey monkey.patch_all(thread=False, select=False) import requests requests.get('http://i-do-not-exist.com') print('THIS WILL NEVER BE PRINTED !!!') Guess what ? The string message will never get printed :( Simply remove the monkey.patch_all line and you'll …

Read More

Rendering deep text-based mindmaps with WiseMapping and Python

In this blog post, I'm going to demonstrate how to reuse WiseMapping HTML+JS rendering engine to easily visualize... text-based mindmaps like this one have many benefits they are readable as-it-is they don't require any tool to be edited they follow the UNIX tenets For the impatient ones, here is …

Read More

Intro à Python & les frameworks web

Le mois dernier j'ai rapidement présenté le language Python et les frameworks web existants à mon équipe à Voyages-Sncf.com. Les slides sont accessibles ici, ainsi que les sources Markdown pour Reveal.js. Iframes non supportées. Cliquez sur le lien dans le paragraphe au-dessus pour accéder directement aux slides. Il …

Read More

Colored diff output with Python

Say you are generating a colored diff output with the standard difflib Python package: diff = difflib.ndiff(file1_lines, file2_lines) print('\n'.join(diff)) Now, I'll show you how to write a simple color_diff function that you can use to color your diff like this: diff = difflib.ndiff(file1_lines, file2_lines) diff …

Read More

youtube_playlist_watcher

Depuis plusieurs années, je ruminais contre Youtube: chaque fois qu'une vidéo est supprimée d'une playlist (parce que l'utilisateur qui l'avait uploadé l'a supprimé par exemple), son nom n'est même pas conservé, seul un lien mort persiste dans la liste. Et la seule solution est alors de googler le nom de …

Read More

God I hate Java Regex API

Pourquoi, mais pourquoi faut-il 3 lignes en Java pour juste extraire un groupe d'une expression régulière qui "match" ??? Matcher matcher = Pattern.compile("o?k(b|i)s+").matcher("kiss"); matcher.matches(); assert matcher.group(1) == "i"; En Python: assert re.match("o?k(b|i)s+", "kiss").group(1) == "i …

Read More

Django tips & tricks

I recently worked on a short website project using Django & Heroku. It was my very time using this Python framework, and I really liked it ! This is a compendium of tips & tricks that I, as a Django beginner, found quite useful : Django enhanced shell To install it : pip install django-extensions …

Read More

Replicating PHPSESSID and srctoken session authentication with mitmproxy

A month ago, I wanted to automate queries to a website that is using the PHPSESSID cookie to keep track of sessions. I struggled a lot and couldn't find any documentation covering the behaviour I was observing. But yesterday I finally found a solution ! In hope it could help others …

Read More

Python 3 non consistent set & dict iteration gotcha

Consider the following Python expression: print("".join(set("ABCDE"))) What do you think it produces ? Not necessarily "ABCDE". Right, but you would expect the result to be consistent, isn't it ? $ for i in {1..3}; do python2.7 -c 'print("".join(set("ABCDE")))'; done ACBED ACBED ACBED Great ! ... But with …

Read More

Mimicking testling HTML rendering of TAP javascript tests

This post is only relevant to you if you use browserify. For a good introduction to this powerful Javascript bundling tool, check this doc. First of all, I'd like to take my hat off to James Hallyday and Peteris Krumins who have built such amazing tools as browserify, testling and …

Read More