Compare commits
5 Commits
e69a8aaf8f
...
c1ce350c7c
Author | SHA1 | Date |
---|---|---|
Julien Palard | c1ce350c7c | |
Julien Palard | 0306135f1e | |
Julien Palard | c1bee743d7 | |
Julien Palard | 761facb137 | |
Julien Palard | c4e7ac276e |
|
@ -1,4 +1,5 @@
|
|||
.ipynb_checkpoints/
|
||||
.envrc
|
||||
/index.html
|
||||
/index.md
|
||||
__pycache__/
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
|
@ -1,11 +1,9 @@
|
|||
# GNU/Linux avec Debian
|
||||
|
||||
### Présenté
|
||||
### Présenté par
|
||||
|
||||
<!-- .slide: data-background="static/background.jpg" -->
|
||||
|
||||
par
|
||||
|
||||
Julien Palard <julien@palard.fr>
|
||||
|
||||
|
||||
|
@ -78,7 +76,7 @@ Dans :
|
|||
$ date
|
||||
```
|
||||
|
||||
- `$ ` est « le prompt », il n'est pas éditable.
|
||||
- `$ ` est « le prompt ».
|
||||
- `date` est un programme.
|
||||
|
||||
notes:
|
||||
|
@ -109,6 +107,7 @@ Mais pourquoi !?
|
|||
- Ça permet de faire collaborer des programmes.
|
||||
- Il est facile d'ajouter des programmes.
|
||||
- Tout au clavier, c'est plus rapide.
|
||||
- Une séquence de commandes peut être partagée et rejouée, c’est « un script ».
|
||||
|
||||
|
||||
## C'est plus rapide
|
||||
|
@ -241,7 +240,7 @@ Attention, compressé il fait ~700M, décompressé ~8GB.
|
|||
Peser le fichier :
|
||||
|
||||
```shell
|
||||
$ du -h products.csv
|
||||
$ du products.csv
|
||||
8103812 products.csv
|
||||
```
|
||||
|
||||
|
@ -543,6 +542,9 @@ Quelques démos s'imposeront avec `iconv` et peut être Python.
|
|||
|
||||
# TODO
|
||||
|
||||
- Le shebang
|
||||
- Les alias, les fonctions bash.
|
||||
- Redirections.
|
||||
- Petit historique
|
||||
- Les window-managers
|
||||
- Sweet sweet thinks like youtube-dl
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
|
@ -0,0 +1,565 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Demo Jupyter\n",
|
||||
"\n",
|
||||
"## Sous titre\n",
|
||||
"\n",
|
||||
"- une\n",
|
||||
"- liste\n",
|
||||
"- comme ça\n",
|
||||
"\n",
|
||||
"Les liens, [Ma page](https://mdk.fr)\n",
|
||||
"\n",
|
||||
"![titre de l'image](https://camo.githubusercontent.com/4cdea557cde90c6a18ded36cf1e51b0866f6ff4a/68747470733a2f2f6d646b2e66722f413133333035382e706e67)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import pandas as pd\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# import des données"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib notebook\n",
|
||||
"# %matplotlib inline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a = np.array(range(10))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a = np.zeros((4, 5))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a[0, 0] = 5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a + 5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a * 2.5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"1 + 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.arange(10, 20, .5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.linspace(0, 100, 50)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.zeros((3, 3))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.zeros((3, 5))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.zeros((2, 3, 4, 5))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b = np.random.rand(4, 4)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.random.rand(4, 4)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b > 0.5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mask = b > .5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b[b < .5].mean()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b[~mask]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"b[(b > .5) & (b < .7)]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris = pd.read_excel('https://mdk.fr/iris.xls', index_col=0)\n",
|
||||
"\n",
|
||||
"# python -m pip install xlrd # Doit marcher\n",
|
||||
"# py -m pip install xlrd # Doit marcher aussi !"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"type(iris)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.describe()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[3]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[:4]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.head()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[:3, \"sepal length (cm)\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[[2, 3, 4, 10], [\"sepal length (cm)\", \"petal length (cm)\"]]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[0, \"sepal length (cm)\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[:, \"sepal length (cm)\"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lengths = [colname for colname in iris.columns if \"length\" in colname]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"iris.loc[:, lengths]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pd.read_csv"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pd.read_excel # Shift tab, Shift tab, Shift tab, Shift tab"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from pandas.plotting import scatter_matrix\n",
|
||||
"plot = scatter_matrix(iris)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = np.linspace(0, 10, 100)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"y = np.sin(x)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"y"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plot = plt.plot(x, y)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"noise = np.random.uniform(-1/10, 1/10, 100)\n",
|
||||
"noise"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plot = plt.plot(x, np.sin(x) + noise)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from matplotlib.colors import Normalize\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def show(np_array):\n",
|
||||
" fig, ax = plt.subplots(figsize=(9, np_array.shape[0]))\n",
|
||||
" if len(np_array.shape) == 1:\n",
|
||||
" np_array = [np_array]\n",
|
||||
" for y, line in enumerate(np_array):\n",
|
||||
" for x, value in enumerate(line):\n",
|
||||
" offset = .1 if value < 10 else .2\n",
|
||||
" ax.text(x - offset, y + .15, str(value), c=\"white\", fontsize=20)\n",
|
||||
" ax.imshow(np_array, cmap=\"hsv\", norm=Normalize(1, 50), aspect='equal')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a1 = np.arange(1, 13)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(a1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(a1.reshape(2, 6))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(a1.reshape(6, 2))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(a1.reshape(3, 4).ravel())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a2 = np.arange(13, 25)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(a2)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(np.stack((a1, a2)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show(np.stack((a1, a2), axis=1))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
from collections import defaultdict
|
||||
from functools import wraps
|
||||
|
||||
def affinity(args):
|
||||
def keyfunc(function):
|
||||
return sum(arg == annotation for arg, annotation in zip(args[1:], function.__annotations__.values())) - len(function.__annotations__)
|
||||
return keyfunc
|
||||
|
||||
|
||||
def best_match(args, functions):
|
||||
return max(functions, key=affinity(args))
|
||||
|
||||
|
||||
def make_dispatcher(alternatives):
|
||||
@wraps(alternatives[0])
|
||||
def dispatch(*args, **kwargs):
|
||||
return best_match(args, alternatives)(*args, **kwargs)
|
||||
return dispatch
|
||||
|
||||
|
||||
class MultiNamespaces(dict):
|
||||
def __getitem__(self, key):
|
||||
return super().__getitem__(key)[-1]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.setdefault(key, []).append(value)
|
||||
|
||||
def to_dict(self):
|
||||
frozen = {}
|
||||
for key, values in self.items():
|
||||
if callable(values[-1]):
|
||||
frozen[key] = make_dispatcher(values)
|
||||
else:
|
||||
frozen[key] = values[-1]
|
||||
return frozen
|
||||
|
||||
|
||||
|
||||
class Overloader(type):
|
||||
@classmethod
|
||||
def __prepare__(cls, name, bases, **kwds):
|
||||
return MultiNamespaces()
|
||||
|
||||
def __new__(cls, name, bases, ns, **kwargs):
|
||||
return super().__new__(cls, name, bases, ns.to_dict(), **kwargs)
|
||||
|
||||
|
||||
class Overloading(metaclass=Overloader):
|
||||
...
|
||||
|
||||
|
||||
class Fib(Overloading):
|
||||
def fib(self, n: 0):
|
||||
return 1
|
||||
|
||||
def fib(self, n: 1):
|
||||
return 1
|
||||
|
||||
def fib(self, n):
|
||||
return self.fib(n - 1) + self.fib(n - 2)
|
||||
|
||||
|
||||
print(Fib().fib(10))
|
|
@ -355,7 +355,7 @@ En initiation on dit "ça ne vous servira pas". En avancé on dit
|
|||
## Métaclasse
|
||||
|
||||
- `__new__` et `__init__` d'une classe servent à personaliser l'instance.
|
||||
- `__new__` et `__init__` d'une metaclasse servent à personalier une classe.
|
||||
- `__new__` et `__init__` d'une metaclasse servent à personaliser une classe.
|
||||
|
||||
Notes:
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ Tant qu'il n'y a pas d'ambiguité, c'est implémenté.
|
|||
```
|
||||
|
||||
|
||||
## Les Comparisons
|
||||
## Les comparaisons
|
||||
|
||||
|
||||
```pycon
|
||||
|
@ -637,7 +637,7 @@ Exercice : Import.
|
|||
|
||||
```pycon
|
||||
>>> if "sucre" in ingredients and "œuf" in ingredients:
|
||||
... print("Commencer par blanchir les œufs.")
|
||||
... print("Commencer par blanchir les œufs.")
|
||||
Commencer par blanchir les œufs.
|
||||
```
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../../background.jpg
|
Loading…
Reference in New Issue