Skip to content

Instantly share code, notes, and snippets.

@jul
jul / stem.py
Last active Apr 9, 2021
Tokenization, stemmisation en Français avec ce pot de pue appelé NLTK.
View stem.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set fileencoding=utf-8 :
import nltk
import nltk.data
import re
from nltk.corpus import stopwords
from nltk.stem.snowball import SnowballStemmer
from vector_dict.VectorDict import VectorDict
@jul
jul / test_fdj.py
Last active Jan 12, 2021
simulation de 100 tirages au hasard et mesure des fréquences des gains a Végas
View test_fdj.py
#!/usr/bin/env python3
from archery import mdict
from functools import reduce
from random import randint, seed
from json import dumps
from sys import argv
pp = lambda d:print(dumps(d, indent=4))
_seed = argv[1]
print(_seed)
seed(int(_seed))
@jul
jul / test.sh
Last active Nov 3, 2020
checking font substitution on firefox
View test.sh
#!/usr/bin/bash
MIN_FF_OPT=" --headless "
FF="firefox $MIN_FF_OPT"
die() { echo "$@"; exit 0;}
fc-match Andika || die "le test va pas marcher"
echo "basically if I could create profile from scratch I would put only this"
cat <<EOF
user_pref("font.default.x-western", "Andika");
@jul
jul / gnuplot_plot
Last active Nov 2, 2020
moving median
View gnuplot_plot
#!/usr/bin/env gnuplot
set timefmt '%Y-%m-%d'
set xdata time
set yrange [1<*:]
set format x '%Y-%m-%d'
set xrange ["2020-03-01"<*:]
set datafile sep ','
@jul
jul / control.sh
Last active Oct 21, 2020
watchdog in bash
View control.sh
#!/usr/bin/bash
MYPID=$$
watchdog () {
( PID=$1
DONE=0
while [[ $DONE == 0 ]]; do
echo "watchdog running"
if $( kill -0 $PID ); then
sleep 1;
else
@jul
jul / secrets.sh
Last active Oct 6, 2020
keeping my secrets in exported variables (CLI on video + k8s, docker, vagrant)
View secrets.sh
#!/usr/bin/env -S bash -i
STASH=~/.secrets
RZ="\e[0m"
GR="\e[92m"
RD="\e[91m"
HL="\e[1m"
mkdir $STASH &> /dev/null
chmod 700 $STASH
if [ ! -z "$1" ]; then
View calc4-2.py
#!/usr/bin/python3.7
from functools import reduce
push_to_stack=object()
stack=[]
OP="+/-*"
all_true=lambda x: True
def crush_stack():
global stack
@jul
jul / calc4.py
Last active Sep 8, 2020
calculator 4 opérations yoda style :)
View calc4.py
#!/usr/bin/python3.7
from functools import reduce
crush_stack=object()
stack=[]
dispatch={
lambda x: True :
print,
str.isdigit :
lambda x: stack.append(int(x)),
lambda x: x in '+*/-' :
@jul
jul / dict2graph.py
Last active May 5, 2020
transformer un dict en graph version 0.0.7
View dict2graph.py
#!/usr/bin/env python3
# usage python3 dict2graph.py | xdot -
DIGRAPH = """digraph structs {
graph [
rankdir= "TD"
bgcolor=white
]
node [
@jul
jul / evol.py
Last active Apr 19, 2020
evolution immobilier par dept (source castor)
View evol.py
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from pyquery import PyQuery as P
from archery import mdict
from archery.trait import Copier
from pyaml import dumps
import re
by3 = lambda s: "".join(
[ " " * int((i+1)%3==0) + x for i,x in enumerate(s[::-1])][::-1]).strip()