Skip to content

Instantly share code, notes, and snippets.

View igorbrigadir's full-sized avatar

Igor Brigadir igorbrigadir

View GitHub Profile
@lantiga
lantiga / export_trace.py
Last active September 18, 2022 03:03
🤗 Huggingface Bert on RedisAI
from transformers import BertForQuestionAnswering
import torch
bert_name = "bert-large-uncased-whole-word-masking-finetuned-squad"
model = BertForQuestionAnswering.from_pretrained(bert_name, torchscript=True)
model.eval()
inputs = [torch.ones(1, 2, dtype=torch.int64),
torch.ones(1, 2, dtype=torch.int64),
@tyhoff
tyhoff / progress_bar_requests_upload.py
Last active April 15, 2025 18:09
Python requests HTTP PUT with tqdm progress bar
from tqdm import tqdm
from tqdm.utils import CallbackIOWrapper
file_path = os.path.abspath(__file__)
upload_url = https://some-bucket.s3.amazonaws.com
file_size = os.stat(file_path).st_size
with open(file_path, "rb") as f:
with tqdm(total=file_size, unit="B", unit_scale=True, unit_divisor=1024) as t:
wrapped_file = CallbackIOWrapper(t.update, f, "read")
@D2theR
D2theR / gunicorn.conf.py
Last active June 1, 2023 21:10
A simple Gunicorn config script that can be used to add your Django template file directories the reload engine to prevent having to reloading the server in development every time you make a change.
##Gunicorn config file
"""
USAGE
gunicorn -b 127.0.0.1:8888 -c gunicorn.conf.py myapp.wsgi
"""
import os, pathlib
template_root = pathlib.Path('/full/path/to/myapp/templates/')
template_list = []
for path, subdirs, files in os.walk(template_root):
@akashpalrecha
akashpalrecha / an-inquiry-into-matplotlib-figures.ipynb
Last active December 27, 2024 14:38
An Inquiry into Matplotlib's Figures, Axes, subplots and the very amazing GridSpec!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mblondel
mblondel / check_convex.py
Last active November 4, 2025 16:07
A small script to get numerical evidence that a function is convex
# Authors: Mathieu Blondel, Vlad Niculae
# License: BSD 3 clause
import numpy as np
def _gen_pairs(gen, max_iter, max_inner, random_state, verbose):
rng = np.random.RandomState(random_state)
# if tuple, interpret as randn

What the BookCorpus?

So in the midst of all these Sesame Streets characters and robots transforming automobile era of "contextualize" language models, there is this "Toronto Book Corpus" that points to this kinda recently influential paper:

Yukun Zhu, Ryan Kiros, Rich Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja Fidler. 2015. "Aligning books and movies: Towards story-like visual explanations by watching movies and reading books." In Proceedings of the IEEE international conference on computer vision, pp. 19-27.

Why do I even care, there's no translations there?

Some might know my personal pet peeve on collecting translation datasets but this BookCorpus has no translations, so why do I even care about it?

@justinvanwinkle
justinvanwinkle / broken.py
Last active November 7, 2025 09:11
Every python rate-limiting library (that I can find) is broken, at least a little.
# I was looking for a rate limiting library to call rate limited apis as closely
# as possible to their enforced limits. I looked at the first few python libraries
# that I found, and when I glanced at the source, they were all clearly broken.
# Curious how this could be, I took all the top google and pip search results for: python rate limiting
# and tried to get them to do the wrong thing and fail to rate limit in situations that could come up
# in normal use (though in some cases very specific use)
# https://github.com/tomasbasham/ratelimit
# Where broken:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stepney141
stepney141 / BookmarkAPI_en.md
Last active April 4, 2023 01:45
(DEPRECATED) Twitter Undocumented Endpoints for Bookmark
TweetId TimestampMillis UTC
42963561600909314 1299078285967 2011-03-02 15:04:45.967000
55651026778341376 1302103213387 2011-04-06 15:20:13.387000
64933603536142336 1304316352148 2011-05-02 06:05:52.148000
89043986865602561 1310064715483 2011-07-07 18:51:55.483000
102228532620562434 1313208156148 2011-08-13 04:02:36.148000
121591751482933248 1317824707276 2011-10-05 14:25:07.276000
128947588278910976 1319578475433 2011-10-25 21:34:35.433000
129324650898538496 1319668374167 2011-10-26 22:32:54.167000
136463946956804096 1321370514989 2011-11-15 15:21:54.989000