Skip to content

Instantly share code, notes, and snippets.

@jul
jul / ldap2dhcp.py
Last active March 11, 2020 19:55
ldap 2 dhcpd
#!/usr/bin/env python3
from bla import *
from ldap3 import *
from contextlib import contextmanager
from sys import argv
import ipaddress as ip
netmask = lambda s: str(ip.IPv4Network("0.0.0.0/%s" % s.dhcpNetmask).netmask)
@jul
jul / gruic_calc.py
Last active September 22, 2019 18:46
une calculatrice qui parle (si espeak est installé)
#/!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Perversion
"""
from collections import MutableMapping, Counter, MutableSequence
from json import *
from functools import reduce
@jul
jul / dict_flatening_pandoc.py
Created September 18, 2019 10:31
Using recursion in a weired way to flatten a pandoc json (state serialisation of an AST I guess
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Perversion
"""
from collections import MutableMapping, Counter
from json import *
from functools import reduce
@jul
jul / try_it.py
Last active July 6, 2019 22:20
perf diff between reduce vs sum
from functools import reduce as r
from time import time as t
add = str.__add__
class S(str):
__neutral = ""
def __radd__(s, o):
o = o or S.__neutral
return add(s, o)
def __ladd__(o, s):
@jul
jul / sum vs reduce.py
Last active July 6, 2019 20:37
sum vs reduce v2
from functools import reduce
class string(str):
def __radd__(self, other):
other = other or ""
return reduce(str.__add__,("L" , other , "R+" , "R" , self))
def __add__(self, other):
other = other or ""
@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
"""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 / 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()))
@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];
}