View get_magic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from requests import get | |
import re | |
''' | |
sometimes, you want a minimalistic magic number detection for simple file types. | |
Like for instance, you scrap the web and you don't trust the web server when returning the mime type | |
(actually happened to me on bilbliothèque nationale de france more than once) | |
So, yo want to make sure that for instance, the returned content is atcually a jpeg, and you may not be | |
on a unix OS with libmagic and you may not want to add dependencies and ... | |
just comparing 3 bytes in a row in a raw byte stream is not THAT hard |
View oneline.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export LANG=C | |
redadd() { python3 -c '(s,d,r)=(__import__("sys"),__import__("archery").mdict,__import__("functools").reduce);print(sorted(r(d.__add__,(d({l[:-1]:1}) for l in s.stdin.readlines())).items(),key=lambda k:k[1],reverse=True)[:10])' ; } | |
red() { python3 -c '(s,d,r)=(__import__("sys"),__import__("archery").mdict,__import__("functools").reduce);print(sorted(r(d.__radd__,(d({l[:-1]:1}) for l in s.stdin.readlines())).items(),key=lambda k:k[1],reverse=True)[:10])' ; } | |
function count() { python3 -c'(s,d)=(__import__("sys"),__import__("archery").mdict);print(sorted(sum((d({l[:-1]:1}) for l in s.stdin.readlines()),{}).items(),key=lambda k:k[1],reverse=True)[:10])'; } | |
cfl() { python3 -c'(s,t,d,f)=(__import__("sys"),__import__("tld"),__import__("archery").mdict,lambda l:t.get_fld(l[:-1],fix_protocol=True,fail_silently=True));print(sorted(sum((d({f(l):1}) for l in s.stdin.readlines()),{}).items(),key=lambda k:k[1],reverse=True)[:10])'; } | |
test_time() { | |
func="$1" | |
TIMEFORMAT="%U" |
View freebsd_inst.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
LOCATION=$(pwd) | |
ARCH=amd64 | |
VERSION=13.1 | |
FLAVOUR=BETA2 | |
FROM_VM=https://download.freebsd.org/ftp/releases/VM-IMAGES/${VERSION}-${FLAVOUR}/${ARCH}/Latest/ | |
FROM_CDROM=https://download.freebsd.org/ftp/releases/ISO-IMAGES/${VERSION}/ | |
FILENAME=FreeBSD-${VERSION}-${FLAVOUR}-${ARCH}.qcow2 | |
CDROM="$( basename $FILENAME .qcow2 )-bootonly.iso" |
View todel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
from operator import itemgetter | |
### uitliser ipython -i argv[0] pour être en interactif et faire joujou | |
can = sg.Canvas(size=(1412,998)) | |
status=sg.Text('status') | |
win = sg.Window("titre",[[can,],[status,],], finalize=True) | |
c = can.TKCanvas | |
from time import sleep, time | |
from random import randint | |
from os import system |
View goft.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
from operator import itemgetter | |
### uitliser ipython -i argv[0] pour être en interactif et faire joujou | |
can = sg.Canvas(size=(400,600)) | |
status=sg.Text('status') | |
win = sg.Window("titre",[[can,],[status,],], finalize=True) | |
c = can.TKCanvas | |
from time import sleep | |
SZ=50 |
View gof_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
### uitliser ipython -i argv[0] pour être en interactif et faire joujou | |
can = sg.Canvas(size=(400,600)) | |
win = sg.Window("titre",[[can,],],finalize=True) | |
c = can.TKCanvas | |
from time import sleep | |
SZ=50 | |
ORD=1 | |
def save(canvas, name="save"): |
View tr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
### uitliser ipython -i argv[0] pour être en interactif et faire joujou | |
can = sg.Canvas(size=(400,600)) | |
win = sg.Window("titre",[[can,],],finalize=True) | |
c = can.TKCanvas | |
SZ=50 | |
def tr(x,y, up=1,**kw): | |
""" créer un triangle équilatéral centré en x,y avec une homothétie / | |
symmétrie sur l'axe des y (up / down) exprimée en coordonnées |
View test_fdj.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
View test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"); |
View gnuplot_plot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ',' |
NewerOlder