Skip to content

Instantly share code, notes, and snippets.

@jul
jul / sum vs reduce.py
Last active July 6, 2019 19:55
sum_vs_rediuce.py
from functools import reduce
class string(str):
def __ladd__(self, other):
other = other or ""
return reduce(str.__add__,("L" , self , "L+" , "R" , other))
def __radd__(self, other):
other = other or ""
return reduce(str.__add__,("L" , self , "R+" , "R" , other))
@jul
jul / matrix.py
Created October 29, 2018 13:41
Why Point2D is useless when dict supports LinearAlgebrae
#!/usr/bin/env python3
from archery import mdict, vdict
from math import pi, cos, sin, acos
class Matrix(mdict):
def __call__(self, other):
res= mdict()
for (src, dst), functor in self.items():
res += mdict({ dst: functor(other[src])})
return res
@jul
jul / reproduce_bug.py
Last active June 21, 2018 12:38
seek is sick ?
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from sys import version
import platform
import locale
print("platfrom is %s" % platform.platform())
print("default locale is "+repr( locale.getdefaultlocale()))
print("locale is "+repr( locale.getlocale()))
"""Licence : Julien Tayon (2018)
If you find me a job in GIS or BigData I will change this license to a full
2 clauses BSD
Licence proprietaire sur un fichier a code source ouvert
ca me laissera le plaisir de poursuivre ceux qui le reutilisent sans mon accord
Proprietary licence with opened source. This a bait for all the newbies
that copy paste from the internet without taking attention of the licenses.
@jul
jul / france.html.template
Last active May 7, 2018 11:28
scrapping pole emploi comme un pro
<html>
<header>
<script>
window.addEventListener("load", function(event) {
var color = %(color)s;
for( dep in color ) {
var el = document.getElementsByClassName("departement" + dep);
console.log(el);
el[0].style["fill"] = color[dep];
}
@jul
jul / correct_course_id.py
Created June 6, 2017 09:37
correcting openEdX course_id truncated model
#!/usr/bin/python
# -*- coding: utf8 -*-
import MySQLdb
from json import dumps
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="user", # your username
passwd="pass", # your password
db="edxapp") # name of the data base
TABLE_MAGANE='''SELECT
@jul
jul / rgaa_to_wcag2.py
Created May 18, 2017 07:26
conversion nomenclature Rgaa vers wcag2.0 (SID)
## importing from notebook (hence ugly import)
from pyquery import PyQuery as S
doc = S("https://disic.github.io/rgaa_referentiel_3-2016/criteres.html")
interesting = doc("[id^=crit]")
import re
number = re.compile("crit-(?P<NUM>.*)$").search
dotted_num = re.compile("(?P<NUM>[\d\.]{1,5})").findall
@jul
jul / liseuse.draft.py
Last active May 1, 2022 09:01
FUCK LA BNF.py
from pyquery import PyQuery as S
import urllib
from json import loads, dumps
from os import path, makedirs
from requests import get
WAIT=.5
"""
Admire the doc made by these fucking twats
http://www.bnf.fr/fr/professionnels/donnees_bnf_recuperables/a.donnees_rdf.html#SHDC__Attribute_BlocArticle7BnF
@jul
jul / check_claim.py
Created February 24, 2017 11:55
Measure how much sites saying they have angular, might have
"""disclaimer may trigger false negative/positive
no measuring tools are perfect
"""
from pyquery import PyQuery as P
doc= P("https://www.madewithangular.com/")
doc.make_links_absolute()
import re
def one_zero(itera):
try:
@jul
jul / comparateur.py
Last active February 6, 2017 16:29
Êtes vous plutôt banlieue ou pas?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pylab as P
import os
import readline
import atexit
from pyquery import PyQuery as S
import re
from json import load, dump, dumps