Skip to content

Instantly share code, notes, and snippets.

@fbparis
fbparis / example.log
Last active December 29, 2018 07:44
Coding/decoding any binary data to/from random textual content (here Lorem Ipsum like)
>>> 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
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
@fbparis
fbparis / ratelimiting.py
Last active November 26, 2018 12:16
Generic decorator to handle multiple rate limits in API calls
import sys, time
from collections import deque
_DEFAULT_POLICY = {1:1}
def rate_limited(*args):
"""
policy is an object where each key is a time interval in seconds and each value is a maximum number of requests during this interval.
{1:1} means 1 request max per second
{1:5} means 5 requests max per second

Keybase proof

I hereby claim:

  • I am fbparis on github.
  • I am fbparis (https://keybase.io/fbparis) on keybase.
  • I have a public key ASAcgU_l1t3GqfnvA9KDRH26an9d87ZCaQ9Xzo3H12o6fQo

To claim this, I am signing this object:

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Python Spintax parser
This module provides an efficient spintax parser where every possible spuns have the same probability.
Given a masterspin you can get the total number of possible spuns or a randomly chosen spun.
"""
@fbparis
fbparis / gist:f623c78adfc24b7dd47e5510a7152ea6
Created June 2, 2016 05:42
Vous en avez marre de ces grèves et de ces blocages, faites le savoir !
Vous en avez marre de ces grèves et de ces blocages, faites le savoir !
------------------------------------------------------------------------------
Coupon à envoyer à votre employeur
------------------------------------------------------------------------------
Je soussigné __________________ __________________,
Aujourd'hui je travaille, je ne revendique rien, je demande à ne pas bénéficier
Verifying that +fbparis is my blockchain ID. https://onename.com/fbparis
@fbparis
fbparis / LibraryOfBabel.py
Created January 1, 2016 05:14
An augmented version of Library Of Babel using sections to store documents of any size...
#!/usr/bin/python
# -*- coding: utf-8 -*-
from random import choice
from unidecode import unidecode
from math import log10
from tqdm import tqdm
class BaseLibraryOfBabel (object):
"""A complete, ordered, searchable, browsable and customizable Library of Babel"""
@fbparis
fbparis / LibraryOfBabel-POC.py
Last active January 11, 2016 20:02
POC for an ordered complete Library of Babel
#!/usr/bin/python
# -*- coding: utf-8 -*-
from random import choice
from tqdm import tqdm # for the progress bar...
def get_book_from_n(n):
n_max = Base**BookLength
if n >= n_max:
return None
//
// SunshineLayerView.m
// Sunshine
//
#import "SunshineLayerView.h"
@implementation SunshineLayerView
@synthesize color = _color;