Skip to content

Instantly share code, notes, and snippets.

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/moment@2.27.0/moment.min.js"></script>
<script>
var width = 960,
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
@mdamien
mdamien / scrap.py
Created April 15, 2015 23:15
Google login images
import requests
from bs4 import BeautifulSoup
with open('urls','w') as f:
while True:
r = requests.get("https://login.corp.google.com/")
soup = BeautifulSoup(r.text)
src = soup.find("img","login-image")['src']
print(src)
f.write(src+"\n")
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
@mdamien
mdamien / fst2json.py
Last active November 3, 2019 20:03
GeoSteiner output parser and import to blender
"""
FST (Full Steiner tree) generator Version 3 parser
Documentation: http://geosteiner.com/geosteiner-5.1-manual.pdf (page 186)
How to use: "./rand_points 10 | ./efst | ./bb -f | python3 fst2json.py"
To note, an alternate method is to grep for the " % @C XXX YYY" output from `bb`,
to get the Steiner points. (page 158 of the manual)
"""
@mdamien
mdamien / 3way_merge.py
Created October 23, 2019 22:53
3-way merge with diff-match-patch
import os, glob
import diff_match_patch as dmp_module
dmp = dmp_module.diff_match_patch()
stashed = False
for file in glob.glob('textes_des_reglements/**/*.md'):
# (FR) commit à partir duquel les corrections ont été manuelles
@mdamien
mdamien / parse.py
Last active July 27, 2019 06:46
parse_reddit.py
import requests, csv
# optional: makes requests-cache make it easy to cache your results
# import requests_cache
# requests_cache.install_cache('reddit_cache')
# where we store all the rows
DATA = []
def get(url, args={}):
@mdamien
mdamien / git_file_persistence.py
Created April 7, 2019 08:59
mwpersistence4git.py
import mwpersistence
import deltas
import mwreverts
import sys
from pathlib import Path
import git