Skip to content

Instantly share code, notes, and snippets.

View jni's full-sized avatar

Juan Nunez-Iglesias jni

View GitHub Profile
@alexmill
alexmill / img2base64.py
Created December 8, 2015 14:45
Create a base64 thumbnail from image URL (Python)
import numpy as np
import base64
import urllib
from PIL import Image
#Convert image to base64 thumbnail
def img2base64(img_link):
with open("/tmp/img_file.jpg", "wb") as f:
f.write(urllib.request.urlopen(img_link).read())
tmp_img = np.asarray(Image.open("/tmp/img_file.jpg"))
@astrofrog
astrofrog / dotastro_remote.ipynb
Last active November 5, 2015 09:19
Remote data access from Python - #dotastro - Day Zero
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tacaswell
tacaswell / label_axes_iterate.py
Last active August 13, 2021 04:22
A quick little function to walk through the axes in a Figure instance and label each one with annotate.
import string
from itertools import cycle
from six.moves import zip
def label_axes(fig, labels=None, loc=None, **kwargs):
"""
Walks through axes and labels each.
kwargs are collected and passed to `annotate`
@jboner
jboner / latency.txt
Last active May 6, 2024 07:06
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD