Skip to content

Instantly share code, notes, and snippets.

document.querySelectorAll('.list-article-consommation').forEach(article => {
count = 1
article.querySelectorAll('.content p').forEach(el => {
if (!el.innerText.trim()) return
el.innerHTML = '<i>('+ count +')</i> ' + el.innerHTML
count += 1
})
})
@mdamien
mdamien / parse.js
Last active October 29, 2020 12:58
Parse les annotations des videos de l'Assemblée Nationale
var links = document.querySelectorAll('.mediaIndex a')
var player = document.querySelector('#html5_player')
var results = []
var i = 0;
function next() {
if (links[i]) {
links[i].click()
setTimeout(() => {
@mdamien
mdamien / export_tlfp_to_mediawiki.py
Created October 27, 2020 13:20
la fabrique de la loi vers mediawiki
import glob
import os
import sys
from pathlib import Path
from lys import L, raw, render
from mwclient import Site
from tlfp.tools.common import open_json
fetch("https://www.nosdeputes.fr/deputes/json").then(data => data.json()).then(data => {
DEPUTES = {}
data.deputes.forEach(dep => {
dep = dep.depute
DEPUTES[dep.nom_de_famille.toUpperCase()] = dep.groupe_sigle
})
function process() {
document.querySelectorAll("#amdtAuteur").forEach(x => {
if (!x.hasAttribute("processed")) {
var nom = x.innerText.replace("de", "").replace(" et plusieurs de ses collègues", "").replace("M.", "").replace("Mme", "")
@mdamien
mdamien / index.html
Created July 27, 2020 08:06
Reddit activity as a calendar view
<!DOCTYPE html>
<body>
<p style="font-family: sans-serif;padding-left: 27px;margin: 0;">
darkest green = 5+ contributions | lightest green = at least one contribution
</p>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js"></script>
<script>
var width = 960,
@mdamien
mdamien / 0readme
Created July 26, 2020 07:21
Twitter Calendar View of user tweets
tweets.csv comes from `twint -u dam_io --csv -o tweets.csv`
from pprint import pprint
def convert(date):
day, hour = date.split(' à ')
hour = int(hour.replace('h', ''))
return day + '_' + str(hour).rjust(2, '0')
def merge(start, end, other_start, other_end):
if other_start < start and other_end < start:
return None
Gilbert Collard 226K
Nadine Morano 218K
Raphaël Glucksmann 197.8K
Jordan Bardella 75.9K
Yannick Jadot 61.5K
Nicolas Bay 60.9K
Thierry Mariani 58K
François-Xavier Bellamy 52.6K
Manon Aubry 50.4K
Pascal Canfin 46.1K
TODO = """
- [x] Article 1
- [x] Article 2
- [x] Article 3
- [x] Article 4
- [x] Article 5
- [x] Article 6
- [x] Article 7
- [x] Article 8
- [x] Article 9