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
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. | |
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. | |
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! | |
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. | |
- Conclusion, classifications, or results should ALWAYS appear last. | |
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. | |
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p |
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
def add_line_numbers(input_file, output_file): | |
with open(input_file) as f: | |
text = f.read() | |
output_text = "\n".join([f"{i} {line}" for i, line in list(enumerate(text.split("\n")))]) | |
with open(output_file, "w") as f: | |
f.write(output_text) |
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 BTreeNode: | |
def __init__(self, t, leaf=False): | |
""" | |
Initialize a B-tree node. | |
Args: | |
t (int): Minimum degree of B-tree node. | |
leaf (bool, optional): True if node is a leaf. Defaults to False. | |
""" | |
self.t = t # Minimum degree (defines the range for number of keys) |
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 git # !pip install GitPython | |
import os | |
def download_repo_folder(repo_path, url, dirs_to_checkout, branch="main"): | |
# Initialize the repo (make sure the path is where you want to clone) | |
os.makedirs(repo_path, exist_ok=True) | |
repo = git.Repo.init(repo_path) |
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 numpy as np | |
import jax | |
import matplotlib.pyplot as plt | |
import jax.numpy as jnp | |
def inverse_square_root_schedule( | |
max_lr: float, | |
warmup_steps: int, | |
): | |
def schedule(count): |
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 pickle | |
import numpy as np | |
from tqdm import tqdm | |
import os | |
# Create a large numpy array and save it to a pickle file | |
# a = np.random.random((1000, 1000)) | |
a = np.random.random((40000,10000)) | |
with open('large_array.pkl', 'wb') as f: | |
pickle.dump(a, f) |
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
sudo ncdu / | |
sudo docker container ls -a --format '{{.ID}}:{{.Names}}' | xargs -I {} sh -c 'echo "Container {} ($(echo {} | cut -d: -f2)): $(sudo docker inspect --format "{{.GraphDriver.Data.MergedDir}}" $(echo {} | cut -d: -f1) | sed "s/\/merged$//") (Size: $(sudo du -sh $(sudo docker inspect --format "{{.GraphDriver.Data.MergedDir}}" $(echo {} | cut -d: -f1) | sed "s/\/merged$//") | cut -f1))"' | |
sudo docker image ls --format '{{.ID}}:{{.Repository}}:{{.Tag}}' | xargs -I {} sh -c 'echo "Image {} ($(echo {} | cut -d: -f2):$(echo {} | cut -d: -f3)): $(sudo docker inspect --format "{{.GraphDriver.Data.UpperDir}}" $(echo {} | cut -d: -f1) | sed "s/\/diff$//") (Size: $(sudo du -sh $(sudo docker inspect --format "{{.GraphDriver.Data.UpperDir}}" $(echo {} | cut -d: -f1) | sed "s/\/diff$//") | cut -f1))"' |
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 more_itertools | |
import itertools | |
""" | |
>>> create_named_matrix(2,3,5) | |
array([[['0,0,0', '0,0,1', '0,0,2', '0,0,3', '0,0,4'], | |
['0,1,0', '0,1,1', '0,1,2', '0,1,3', '0,1,4'], | |
['0,2,0', '0,2,1', '0,2,2', '0,2,3', '0,2,4']], | |
[['1,0,0', '1,0,1', '1,0,2', '1,0,3', '1,0,4'], | |
['1,1,0', '1,1,1', '1,1,2', '1,1,3', '1,1,4'], |
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
namespace functions { | |
// Execute a block of Python code. This can be used to perform calculations, process data, or any other task that can be accomplished through Python code. | |
type python = (_: { | |
code: string, | |
}) => any; | |
// Create images from a text-only prompt. This tool is used to generate visual content based on detailed descriptions provided in text form. | |
type dalle = (_: { | |
size?: "1792x1024" | "1024x1024" | "1024x1792", |
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
from more_itertools import windowed, repeat_last | |
import numpy as np | |
from more_itertools import grouper | |
input_ids = np.arange(65) | |
# input_ids = np.arange(4097) | |
width = 16 | |
stride = 4 |
NewerOlder