This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######## temp setup ######## | |
'builtin' 'local' '-a' 'p10k_config_opts' | |
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') | |
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') | |
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') | |
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' | |
######## main ######## | |
() { | |
######## colors ######## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source - https://stackoverflow.com/a/61230293/11070463 | |
# | |
# Often, i'll be working in on a jupyter notebook and an error/bug will | |
# interrupt the execution of something that was wrapped with the tqdm | |
# function. This has the annoying side effect where your next tqdm call | |
# will be multilined. To fix this, you can the below two lines of code | |
# and it'll be fixed! (if tqdm gets interrupted again, you'll have the | |
# run these two lines again). | |
while len(tqdm._instances) > 0: | |
tqdm._instances.pop().close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Data classes and loading functions.""" | |
import os | |
import glob | |
import json | |
import shutil | |
import logging | |
import collections | |
import multiprocessing | |
import bs4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from queue import Queue | |
q = asyncio.Queue() | |
async def get_data(): | |
while True: | |
await asyncio.sleep(0.5) # simulate work | |
print("receiving:", await q.get()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import numpy as np | |
def broadcast(): | |
a = np.random.random(256) | |
b = np.random.random((2048, 256)) | |
return timeit.timeit(lambda: a - b, number=1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statistics | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
def stats(values, plot=False): | |
# statistics.mode throws an error if there are multiple modes | |
try: | |
mode = statistics.mode(values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tokenizer: | |
"""Tokenizes text into tokens and sequence of tokens. | |
token (str) | |
the smallest divisable component in a tokenization model | |
seq (list of str) | |
a sequence of tokens that encodes some meaning as an ordered (or | |
unordered) collection | |
text (str) | |
a string that can be broken down into a seq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
N = 1000000 # number of frogs of each gender | |
assert N >= 2 # there must be at least 2 frogs of each gender | |
frogs = ["M"] * N + ["F"] * N | |
max_num_simulations = 2000000 # number of simulations to run | |
num_simulations = 0 | |
num_clearing_successes = 0 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::hash::Hash; | |
fn map<A, B, F>(l: &Vec<A>, f: F) -> Vec<B> | |
where | |
F: Fn(&A) -> B, | |
{ | |
let mut result = Vec::new(); | |
for e in l.iter() { | |
result.push(f(e)); |
OlderNewer