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
""" | |
Librement inspiré de https://twitter.com/IllumiReptilien/status/1325009440026877953 | |
anus.png peut être récupéré ici : https://github.com/fbparis/floot/blob/main/anus.png | |
""" | |
# uncomment in colab | |
# !pip install mtcnn | |
import cv2 | |
import mtcnn |
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
class RandomUCI(): | |
"""Random Upper Confidence Interval | |
""" | |
def __init__(self, bandit): | |
self.bandit = bandit | |
self.arm_count = bandit.arm_count | |
self.mean = np.ones(self.arm_count) / 2 | |
self.variance = np.ones(self.arm_count) / 4 | |
self.N = np.ones(self.arm_count) |
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/local/bin/python3 | |
# -*- coding: utf-8 -*- | |
""" | |
""" | |
__title__ = __file__.rsplit('.', 1)[0].title() | |
__author__ = 'fboudot@pm.me' | |
__license__ = 'IV' | |
version_info = (0, 0, 1) |
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
# -*- coding: utf-8 -*- | |
""" | |
New kind of text extractor: | |
Phase 1: | |
- remove scripts css svg comments canvas etc | |
- add space after each html tag | |
- strip tags | |
- normalize spaces/newlines | |
- keep the result | |
Phase 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
""" | |
Use the formula found on https://nookipedia.com/wiki/Compatibility (slightly modified) to compute Animal Crossing New Horizons village compositions optimizing villagers happiness. | |
Compatibility score between 2 villagers is a grade from 0 (worst) to 4 (best) and village score is the sum of every combinations of 2 villagers score in the village. | |
You can pass a required list of villagers (using their english ids or french names) to find the ideal villagers to recrute next. | |
See --help for options. -m3 -r2 are usualy good parameters. | |
Note that the program never stops so you will have to hit CTRL-C when you're done! |
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
from itertools import product, combinations | |
from random import sample | |
# 0 1 2 3 | |
# 4 5 6 7 | |
# 8 9 A B | |
# C D E F | |
cards = list(product('ABCD', '0123', repeat=1)) |
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
""" | |
kik (key to index to key) is a new implentation of indexed trie (https://gist.github.com/fbparis/e114958a4a9be84146a1a579cf677e8d) reducing memory footprint by a factor 7 or more! | |
The main differences with indexed tries are: | |
* Trie nodes are no longer stored in Node objects but in a python list. An internal mechanism use the list to simulate a tree behaviour, without any recursive function. | |
* Nodes and values stored in the kik can be compressed with several compression levels: | |
* None: no compression at all | |
* 0: data are stored as pickle.dumps (memory use divided by 3-4) | |
* -1, 1 to 9: pickle.dumps are compressed with zlib | |
* Some internal methods can be cached with a custom implentation of a LRU cache. |
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
""" | |
A Python3 indexed trie class. | |
An indexed trie's key can be any subscriptable object. | |
Keys of the indexed trie are stored using a "radix trie", a space-optimized data-structure which has many advantages (see https://en.wikipedia.org/wiki/Radix_tree). | |
Also, each key in the indexed trie is associated to a unique index which is build dynamically. | |
Indexed trie is used like a python dictionary (and even a collections.defaultdict if you want to) but its values can also be accessed or updated (but not created) like a list! | |
Example: | |
>>> t = indextrie() |
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 os | |
from math import factorial | |
from random import seed, randrange | |
class PerfectCipher(object): | |
""" | |
Each byte (0-255) of a message is replaced using a translation table which is a permutation of [0..255]. | |
After each replacement a new translation table is used using a Linear Congruential Generator to act as a PRNG: | |
Next N = (a * N + c) % m | |
Where m is 256! (total count of [0..255] permutations) and a and c carefully chosen so that the period of the PRNG is equal to m. |
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 sys | |
import socket | |
import zlib | |
from loremvpn import LoremVPN | |
if __name__ == '__main__': | |
VPN = LoremVPN("demo", "demo") | |
HOST, PORT = "localhost", 9999 | |
data = " ".join(sys.argv[1:]).encode() |
NewerOlder