Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
OhadRubin / create_toc_prompt.md
Created April 22, 2025 08:06
create_toc_prompt.md

Suppose we were to write a 1000 pages book called {name} what would the table of content be like? It should have 3 parts, each part will have 6 sections, each section will have 4 chapters, each chapter will have 3 headings. give me the full table of content with all 216 headings, 72 chapters, 18 sections and 3 parts.

your output should be in the following format

Table of Contents: {name}
PART 1: <part_title>
Section 1.1: <section_title>
Chapter 1.1.1: 
@OhadRubin
OhadRubin / peer.html
Created April 21, 2025 14:00
peer.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PeerJS Messaging Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/peerjs/1.5.4/peerjs.min.js"></script>
<style>
body {
@OhadRubin
OhadRubin / reasoning_prompt.md
Created April 21, 2025 09:08
reasoning_prompt.md

"Just do it" - Prompt

Please implement <blank>

"Into natural language" Prompt

Please describe it in natural language in such a way to it will be able to be reconstruct exactly
@OhadRubin
OhadRubin / find_largest.sh
Created March 24, 2025 12:22
find_largest.sh
#!/bin/bash
dirs=($(sudo du -h --max-depth=1 ~/ | sort -h | awk '{print $2}' | tail -n 10 | head -n 9))
for dir in "${dirs[@]}"; do
if [ ! -d "$dir" ]; then
echo "Warning: $dir is not a directory or doesnt exist"
continue
fi
echo "Largest file in $dir:"
@OhadRubin
OhadRubin / animate_svg.py
Created December 31, 2024 08:32
animate_svg.py
# pip install svgelements
import io
from svgelements import SVG, Path
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np
def read_svg(svg_file_path):
try:
with io.open(svg_file_path, "r", encoding="utf-8") as f:
@OhadRubin
OhadRubin / create_enc_script.sh
Created December 27, 2024 09:30
create_enc_script.sh
#!/bin/bash
# create_enc_script.sh - Creates an encrypted script containing API keys and uploads to GitHub Gist
# Usage: bash create_enc_script.sh --path_to_dot_env_file .my_tmp --password your_password --github_token $GITHUB_ACCESS_TOKEN
# Function to show usage
show_usage() {
echo "Usage: $0 --path_to_dot_env_file <path> --password <password> --github_token <token>"
exit 1
}
@OhadRubin
OhadRubin / tol_verbalizers.md
Created November 29, 2024 10:42
Thinking out loud Verbalizers

Hmm... Well, let me see... I'm wondering if... This makes me think of... Building on that... Wait a minute... Going back to what I said about... Something's not quite right... Hold that thought... Here's where it gets interesting...

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
@OhadRubin
OhadRubin / add_line_numbers.py
Created October 1, 2024 09:35
add_line_numbers.py
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)
@OhadRubin
OhadRubin / btree.py
Created September 25, 2024 10:20
B-tree in python
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)