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 | |
# coding: utf-8 | |
# | |
# Module to generate the code of Netcdf4 Driver (Mbg...) | |
# | |
import ntpath | |
import netCDF4 as nc |
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
def autoload_package_submodules(package:object, log_info:callable=print, log_error:callable=print): | |
"""Import all submodules of given package to have them loaded""" | |
import os, glob, importlib | |
path = os.path.split(package.__file__)[0] | |
pkg_name = package.__name__ | |
for fname in glob.glob(os.path.join(path, '*.py')): | |
modname = os.path.splitext(os.path.split(fname)[1])[0] | |
if modname.startswith('_'): continue # ignore private modules | |
try: |
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
all: | |
python latonf.py example-data.csv 0 1 -f '%Ddeg %Mmn %Ssec %w' | |
pandas: | |
python latonf.py example-data.csv 0 1 -f '%Ddeg %Mmn %Ssec %w' -p | |
pandas-with-chunks: | |
python latonf.py example-data.csv 0 1 -f '%Ddeg %Mmn %Ssec %w' -c | |
test: | |
pytest latonf.py -v --doctest-modules |
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/python3 | |
"""detect fail2ban's currently banned IP using its log file, | |
and show them in stdout | |
""" | |
import re | |
import argparse | |
from collections import defaultdict |
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/python3 | |
"""Little helper to upload a file or a set of file in a library of a seafile instance, | |
using requests. | |
""" | |
import os | |
import glob | |
import json | |
import argparse | |
import getpass |
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
"""What is the adress i should use ?""" | |
import itertools, random | |
ANSWER = 'Univ Rennes, Inria, CNRS, IRISA F-35000 Rennes' | |
NEEDED = {'Inria', 'Univ', 'CNRS'} | |
MAX_PROPOSITIONS = 6 |
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
"""Example of pandas/seaborn heatmap generation""" | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
def heatmap_using_seaborn(data): | |
import seaborn as sns; sns.set() | |
ax = sns.heatmap(data) | |
plt.show() |
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
"""Simple simulation of a virus spreading, | |
using numpy matrices for internal board representation, | |
and pillow to generate a colored gif visualization. | |
pip install numpy Pillow | |
python vsp.py | |
Outputs: vsp.gif | |
A cell of the 2D world is either None or an integer >= -2. |
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
"""Simple (and slow) implementation of the game of life, | |
using numpy matrices for internal board representation, | |
and pillow to generate a gif visualization. | |
pip install numpy Pillow | |
python gol.py | |
Outputs: gol.gif | |
""" |
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
"""Write a gif where a line moves horizontally. | |
Note that this code does not work with pillow 3.4.0 | |
(only the first frame is written). | |
Tested with pillow 5.0.0. | |
""" | |
from PIL import Image |
NewerOlder