The iframe
above displays some graphs I've built last week,
in order to get some insight on some GitHub projects issues & pull requests evolution.
They are directly inspired by nf-core project activity statistics.
Une analyse claire, détaillée et visuelle des données publiques issues du grand débat national.
Le code source en Python de Myriam Begel : https://gitlab.begel.fr/myriam/grand-debat
En parallèle, l'analyse du site du gouvernement :
https://www.gouvernement.fr/on-fait-le-point-sur-la-restitution-du-grand-debat-national
I met a very strange Python module loading behaviour in Pelican today :
https://github.com/getpelican/pelican/blob/3395e71/pelican/settings.py#L21
Here is some minimal code reproducing the issue. It requires 5 files :
bug_repro.py
dir_a/__init__.py
dir_a/test_data/pelicanconf.py
dir_b/__init__.py
dir_b/test_data/pelicanconf.py
bug_repro.py
contains:
import dir_a
import dir_b
dir_a/__init__.py
and dir_b/__init__.py
both contain this code:
import os
from importlib.machinery import SourceFileLoader
print(SourceFileLoader('pelicanconf', os.path.dirname(__file__) + '/test_data/pelicanconf.py').load_module().THEME)
dir_a/test_data/pelicanconf.py
contains only the line THEME = 'localized_theme'
and dir_b/test_data/pelicanconf.py
is empty.
What will produces python3.7 bug_repro.py
? 😉
Turns out PHP standard crc32
method is non-standard (while crc32b
is).
Here is how to implement it in Python:
def php_crc32(a):
'''
References:
- https://www.php.net/manual/en/function.hash-file.php#104836
- https://stackoverflow.com/a/50843127/636849
'''
crc = 0xffffffff
for x in a:
crc ^= x << 24;
for k in range(8):
crc = (crc << 1) ^ 0x04c11db7 if crc & 0x80000000 else crc << 1
crc = ~crc
crc &= 0xffffffff
# Convert from big endian to little endian:
return int.from_bytes(crc.to_bytes(4, 'big'), 'little')
from random import*;import time,sys;import curses as h;w=h.initscr();h.noecho() #
P,Q,m,s,e,p,a,q=20,10,5,300,{0:"· ",1:"██"},[[[1,1]]*2,[[0,1,0],[1]*3,[0]*3],[[1#
,0,0],[1]*3,[0]*3],[[0,0,1],[1]*3,[0]*3],[[1,1,0],[0,1,1],[0]*3],[[0,1,1],[1,1,0#
],[0]*3],[[0]*4,[1]*4,[0]*4,[0]*4]],range,len;M,b=p[randint(0,6)],[[0]*Q for r #
in a(P)];h.cbreak();y,R,C,cr,l,d,n=lambda z,x,y:e[z[x][y]],0,4,0,1,s,p[randint(0#
,6)];w.nodelay(1);w.keypad(1);h.curs_set(0);A,B,sw=list,zip,{'U':'if not k(R,C'+#
',A(B(*M[::-1]))):M=A(B(*M[::-1]))','D':'V();R+=1','L':'if not k(R,C-1,M):C-=1',#
'R':'if not k(R,C+1,M):C+=1'};exec(('def k(R,C,se):\n for(r,c)in[(r,c)for c in '#
'a(q(M))for r in a(q(M))]:\n if se[r][c]>0 and(not(0<=R+r<P and 0<=C+c<Q)or b['#
'R+r][C+c]>0):return 1\ndef V():\n global R,C,M,n,l,d\n if(k(R+1,C,M)and R<1 an'#
'd sys.exit())or k(R+1,C,M):\n for(r,c)in[(r,c)for c in a(q(M))for r in a(q(M)'#
')]:\n if R+r in a(P)and C+c in a(Q)and M[r][c]>0:b[R+r][C+c]=M[r][c]\n M,n,'#
'R,C,d=n,p[randint(0,6)],-1,4,s+m-l*m\n for i in[j for j in a(P)if sum(b[j])>9'#
']:b[1:i+1]=b[:i];b[0],l=[0]*Q,l+1\ntry:\n while 1:\n o,z=a(q(n)),a(q(M));u=[('#
'r,c)for c in z for r in z];time.sleep(.001)\n for(r,c)in[(r,c)for c in a(Q)fo'#
'r r in a(P)]:`(r,c*q(e),y(b,r,c))\n for(r,c)in[(r,c)for(r,c)in u if M[r][c]>0'#
']:`(R+r,(C+c)*2,y(M,r,c))\n for(r,c)in[(r,c)for c in o for r in o]:`(r,22+c*2'#
',y(n,r,c)+"· · ")\n try:cr=(cr+1)%d;ch=w.getkey();exec(sw[ch[4:5]]);raise\n '#
'except:exec("if cr<1:V();R+=1");`(P,0,"level "+str(l))\nexcept:h.echo();w.keyp'#
'ad(0);h.nocbreak();h.endwin();print("level "+str(l))').replace('`','w.addstr'))#
Amazing ! Reminds me of the International Obfuscated C Code Contest
This article shows how to construct a non-recursive zip bomb that achieves a high compression ratio by overlapping files inside the zip container. "Non-recursive" means that it does not rely on a decompressor's recursively unpacking zip files nested within zip files: it expands fully after a single round of decompression. The output size increases quadratically in the input size, reaching a compression ratio of over 28 million (10 MB → 281 TB) at the limits of the zip format. Even greater expansion is possible using 64-bit extensions. The construction uses only the most common compression algorithm, DEFLATE, and is compatible with most zip parsers.
$ python3 -m zipfile -e overlap.zip .
Traceback (most recent call last):
...
__main__.BadZipFile: File name in directory 'B' and header b'A' differ.
Yesterday I was crafting some puzzles for my girlfriends, and I was looking for letter-based ones where I a secret word would be revealed once solved.
With this same goal, I had already once worked on an open-source JS word search generator: https://lucas-c.github.io/wordfind/
(pour les francophones …
Over the past years, on software programming projects where my end users where developers (other than myself or my team), I have tried to follow the advice of this website : keepachangelog(.com)
A changelog is defined by Wikipedia as :
a log or record of all notable changes made to a …
An automatic system for rolling a polyhedral die and taking photos of the rolls; extracting the image of just the die from those images; clustering the images of the die by which face is shown; and analyzing the results.
Have you ever wondered what happens exactly when you run pip install? This post will give you a detailed overview of the steps involved in the past, and how it all changes with the adoption of PEP-517 and PEP-518.
Chalice , a Python Serverless Microframework developed by AWS, enables you to quickly spin up and deploy a working serverless app that scales up and down on its own as required using AWS Lambda.
I just added a favicon to this site, representing a glider of Conway's Game of Life.
This GIF was made with a Python script. The source code is on GitHub, and uses Zhao Liang's gifmaze.py.
Feel free to reuse the code to make you own favicons 😉
<style> article img { transform …</style>the image in this tweet is also a valid ZIP archive, containing a multipart RAR archive, containing the complete works of Shakespeare.
Source code. This one is also a PDF : SOURCE.PDF.ZIP.JPG
From: http://taint.org
Awesome trick ! And the source code is in Python
Almost a year ago, GitHub introduced security alerts. They are an awesome feature.
They function as notifications you receive whenever a vulnerability affecting one of your project dependencies.
But long after receiving a notification, how to list all security alerts affecting your repositories ?
I didn't found an out-of-the box solution …
A SaaS company like Dropbox needs to update our systems constantly, at all levels of the stack. When it comes time to tune some piece of infrastructure, roll out a new feature, or set up an A/B test, it’s important that we can make changes and have them hit production fast.
Stormcrow feature gates :
- Are rolled out to production within 10 minutes of being changed.
- Can be used across all Dropbox systems, from low-level infrastructure to product features on web, desktop or mobile.
- Provide advanced targeting capabilities, including the ability to segment users based on data in our analytics warehouse.
pyecharts is a wrapper around echarts, a library developped by Baidu [...] the gallery, it is quite impressive.
The Python wrapper used some technics such as modules to automatically converts Python code into Javascript:javascripthon
.
Some time ago, I used the overblog platform in order to create a blog for a long trip in Ireland.
Despite being sometimes very slow, it was overall a good platform, very easy to grasp for beginners. The blog is now old and unused, but before destroying it I wanted …
A wordcloud/wordmesh generator that allows users to extract keywords from text, and create a simple and interpretable wordcloud.
Why word-mesh?
Most popular open-source wordcloud generators (word_cloud, d3-cloud, echarts-wordcloud) focus more on the aesthetics of the visualization than on effectively conveying textual features. word-mesh strikes a balance between the two and uses the various statistical, semantic and grammatical features of the text to inform visualization parameters.
Features:
- keyword extraction: In addition to 'word frequency' based extraction techniques, word-mesh supports graph based methods like textrank, sgrank and bestcoverage.
- word clustering: Words can be grouped together on the canvas based on their semantic similarity, co-occurence frequency, and other properties.
- keyword filtering: Extracted keywords can be filtered based on their pos tags or whether they are named entities.
- font colors and font sizes: These can be set based on the following criteria - word frequency, pos-tags, ranking algorithm score.
Isaac Asimov:
J’ai une théorie sur les salles de bain.
Quand vous avez un appartement avec 2 personnes et 2 salles de bains, tout le monde peut profiter des salles de bains, y faire ce qu’il veut, tout le temps qu’il veut, au moment qu’il veut. Et tout le monde peut croire dans “le droit à la salle de bain”. D’ailleurs, il est clair que ça devrait être écrit dans la constitution.
Quand vous avez 20 personnes dans l’appartement, même dans le cas improbable où tout le monde croit dans le droit à la salle de bain, et même si c’est écrit dans la constitution, une telle chose ne peut exister. Il faut instaurer des horaires. Des tours. Il faut frapper à la porte et dire “t’as bientôt fini ?”. Il y aura des meilleurs horaires pour certains, et des abus.
La démocratie ne peut pas survivre à la surpopulation. La dignité humaine ne peut pas survivre à la surpopulation. Le confort et la décence ne peuvent pas survivre la surpopulation. Plus on ajoute de personnes sur Terre, plus la valeur de la vie, non seulement diminue, mais disparaît. Cela n’a aucune importance si une personne meurt, plus il y a de gens, moins l’individu compte.
Je plussoie la philosophie finale:
En plus d’apprendre Python, qu’est-ce que je peux faire d’utile ?
Envisager de ne pas faire des enfants, voir d’en adopter. Ou au minimum arrêter de se comporter comme un extrémiste religieux qui fait la promotion du Dieu Procréation comme à peu prêt tout le monde actuellement. C’est grave.
Acheter moins. Réparer. Faire avec moins. Faire sans. Ne pas faire.
Ne pas avoir de voiture. Ne pas changer tous les jours de t-shirt. Ne pas acheter le dernier gadget.
Acheter d’occasion. Donner. Libérer de l’espace chez soi, et du temps dans sa vie.
Prendre le vélo. Marcher. Acheter local. Et moins.
Réfléchir, éteindre la télé, lire, parler à ses amis face à face.
Cuisiner. Manger (beaucoup) moins de viande.
On ne doit pas viser moins de croissance. On doit viser la décroissance.
Gagner moins d’argent, faire moins de choses. Avoir une économie qui ne soit pas basée sur le plus.
Vendre moins.
Ce n’est pas l’austérité. Ce n’est pas vivre comme un homme des cavernes. Ça ne veut pas dire vivre moins. C’est juste ne pas être un parasite suicidaire.
Yesterday I've stumbled upon a very surprising bug in some Python 2 code,
related to the use of the __del__
method in a vendor library we employ at work.
Here is some minimal code that reproduces the issue I met:
class MyClass:
def __init__(self):
raise RuntimeError('Woops')
def __del__ …