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 random | |
s, z, n = 0, 0, 0 | |
dx, dy = 0, -1 | |
# Let keep it simple :-) | |
frog = random.randint(-100, 100) | |
jump = random.randint(-100, 100) | |
while 1: | |
i = s + n * z | |
n += 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
>>> vpn.Encode(r.content) | |
2018-12-28 15:18:01,876 loremvpn INFO Data inflated by factor 7.33 (2.79 after zlib compression) | |
'faugiames metrumstietum orcurat metrie rid ortumst lumstiuscilisit teantum te lum har lia har mesuat orpitorpibustrumstietus faugit fames fam cullicumst nenisiscillandumst lignimes pentenentinc mes la cust custorassapisiturascillustacenaestrumst cullucitur ur nea tea acu ac landie orpis orpitorpitiesel ur lend erius fam peliac fam cust netumstostrumstatem nenascibust las mesemes lucillum lassi sem lasciliam faucincitac orcitiesuat culassectos acienia penibuscitienasciostateandui uraesuam daliscit tetrum semese aculutandui orcu lac harcibenisi hasse hassimet pellusci lac faucie orpenti laceliacuscin ortit iduiss orpitiac lemposustortustrum idignimis orci neandio idapiesus selesumstacustiestincur neanduisit liturumstiesellit orpelibendumstienistrutac neturientur har urassem licincid orpeneandit fam penibendumstiscidio se landignimi ida met tetriscieneneandimes lesumstor mesempostrius iding |
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() |
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
""" | |
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
""" | |
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
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
""" | |
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
# -*- 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
#!/usr/local/bin/python3 | |
# -*- coding: utf-8 -*- | |
""" | |
""" | |
__title__ = __file__.rsplit('.', 1)[0].title() | |
__author__ = 'fboudot@pm.me' | |
__license__ = 'IV' | |
version_info = (0, 0, 1) |