Skip to content

Instantly share code, notes, and snippets.

Damien mdamien

Block or report user

Report or block mdamien

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mdamien
mdamien / fst2json.py
Last active Nov 3, 2019
GeoSteiner output parser and import to blender
View fst2json.py
"""
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 Oct 23, 2019
3-way merge with diff-match-patch
View 3way_merge.py
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
View git_file_persistence.py
import mwpersistence
import deltas
import mwreverts
import sys
from pathlib import Path
import git
@mdamien
mdamien / sort_replies.js
Created Mar 25, 2019
Sort twitter replies by likes
View sort_replies.js
[].slice.call(document.querySelectorAll('.replies-to .stream-items:first-child .ProfileTweet-action--favorite .ProfileTweet-actionButton .ProfileTweet-actionCountForPresentation'))
.map(x => parseInt(x.textContent))
.filter(x=>x)
.sort((a, b) => b - a);
// to paste into the dev console when viewing a tweet replies
// output is the sorted list of number of likes for each reply
@mdamien
mdamien / wikipedia_page_authorship.py
Created Mar 19, 2019
wikipedia: page authorship information by wikiwho
View wikipedia_page_authorship.py
# limitation: Special:Export method 1000 revisions limit (without pagination)
from WikiWho.examples.process_xml_dump import process_xml_dump
from WikiWho.utils import iter_rev_tokens
xml_file_path = '/home/ecu/repos/WikiWho/export_radio_meuh.xml' # export from Special:Export
wikiwho_obj = process_xml_dump(xml_file_path)
print(wikiwho_obj.title)
print(wikiwho_obj.ordered_revisions)
prev = None
@mdamien
mdamien / liquid_democracy.py
Created Mar 1, 2019
liquid_democracy demo
View liquid_democracy.py
from collections import Counter
users = [1, 2, 3, 4, 5, 6, 7, 8]
delegs = {
4: 1,
5: 2,
6: 3,
7: 5,
8: 5,
View query.py
import sys, os, collections, string, math
Result = collections.namedtuple('Result',
['file', 'matches', 'n_lines',
'n_exact_match', 'n_exact_length',
'title_match'])
def remove_accents(s):
table = collections.defaultdict(lambda: None)
View _stats
pays - 90 values, 4 distincts
----
95.6% (86) FRANCE
2.2% (2) France
1.1% (1) ROYAUME-UNI
1.1% (1)
categorieOrganisation.label - 90 values, 7 distincts
@mdamien
mdamien / sokoban.py
Last active Aug 17, 2017
sokoban for echo phone
View sokoban.py
import sys
"""
X = WALL
P = Player
C = Box
E = Emplacement for Box
# = E + P
$ = E + C
"""
@mdamien
mdamien / 0readme.md
Last active Oct 7, 2019
404 link detector with scrapy
View 0readme.md

List all the broken links on your website

Requirements:

python3 and scrapy (pip install scrapy)

Usage

  • scrapy runspider -o items.csv -a site="https://yoursite.org" 1spider.py
  • python3 2format_results.py
You can’t perform that action at this time.