Skip to content

Instantly share code, notes, and snippets.

@nazariyv
Last active March 29, 2021 00:21
Show Gist options
  • Save nazariyv/a018cc72c50ee7602e0c529d69582481 to your computer and use it in GitHub Desktop.
Save nazariyv/a018cc72c50ee7602e0c529d69582481 to your computer and use it in GitHub Desktop.
ExcessBits
import matplotlib.pyplot as plt
import requests
import base64
import io
import matplotlib.image as mpimg
from PIL import Image
from io import BytesIO
import numpy as np
def grab_image(number: str):
r = requests.get(f'https://assets.cargo.build/05a80b95-2453-42ce-a92f-37c05348e61e/{number}.png')
return r
def all_indices():
indices = []
for i in range(1024):
num = i + 1
if num < 10:
indices.append(f'000{num}')
elif num < 100:
indices.append(f'00{num}')
elif num < 1_000:
indices.append(f'0{num}')
else:
indices.append(f'{num}') # last 24
return indices
all_nums = all_indices()
columns = 4
rows = 8
run = 31
fig, ax = plt.subplots(nrows=rows, ncols=columns, figsize=(4 * columns, 4 * rows))
for i, axi in enumerate(ax.flat):
index = (columns * rows) * run + i + 1
r = grab_image(all_nums[index])
img = Image.open(BytesIO(r.content))
axi.imshow(img)
axi.set_title(f"#{index}")
axi.xaxis.set_ticks([])
axi.yaxis.set_ticks([])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment