Skip to content

Instantly share code, notes, and snippets.

View luabida's full-sized avatar
🌙
路安

Luã B. Vacaro luabida

🌙
路安
  • FGV Rio
  • Brazil
  • 04:16 (UTC -03:00)
View GitHub Profile
@luabida
luabida / primes.py
Created January 3, 2023 14:48
Recursion & Laziness Evaluation | First 100 positive prime numbers
def positives(n):
yield n
yield from positives(n+1)
def primes(s):
n = next(s)
yield n
yield from primes(i for i in s if i%n != 0)
@luabida
luabida / repeat.py
Last active November 29, 2022 14:19
Profiling using `timeit.repeat()`, with Min, Mean and Max
from timeit import repeat
from statistics import mean
def stats(stmt, r=100):
res = repeat(stmt, globals=globals(), repeat=r)
print(f'Avg: {mean(res)}\nMin: {min(res)}\nMax: {max(res)}')
"""
def foo():
return 1+1
@luabida
luabida / packages.md
Last active November 23, 2022 18:22
Packages

Installing Python packages and managing Virtual Environments

How to install a package?

# https://packaging.python.org/en/latest/tutorials/installing-packages/
$ python3 -m pip --version
$ python3 -m ensurepip --default-pip
@luabida
luabida / image-grid.md
Last active May 3, 2022 17:53 — forked from trusktr/image-grid.md
Image grids in Markdown
1 2 3
4 5 6
1 2 3 4
5 6 7 8
9 10 11