Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
OhadRubin / howto_save_running_process.md
Created January 4, 2026 11:08
HOWTO: Save a Running Process You Forgot to Start in tmux

HOWTO: Save a Running Process You Forgot to Start in tmux

You started a long-running job and forgot to use tmux. Now you're stuck. Here's how to save it.

Option 1: Detach with disown (simplest, lose output)

# In the terminal where the process is running:
Ctrl+Z              # Suspend the process
bg # Resume in background
@OhadRubin
OhadRubin / json_scripts.sh
Created January 4, 2026 08:18
Bash function for JSON templating with environment variable substitution
#!/usr/bin/env bash
json_template_to_canon() {
# stdin: template with ${VARS}; output: canonical (minified) json
# Substitutes environment variables in a JSON template.
#
# NOTE: Variables MUST be exported (not just set) for this to work.
# NOTE: Unset variables are left as-is (safe_substitute behavior).
#
# Example 1 - single line:
@OhadRubin
OhadRubin / ast-grep-delete.py
Created December 17, 2025 05:41
ast-grep-delete.py
# /// script
# dependencies = [
# "ast-grep-py",
# ]
# ///
import sys
from pathlib import Path
from ast_grep_py import SgRoot
@OhadRubin
OhadRubin / md2drive
Created October 17, 2025 04:25
md2drive - convert markdown file to docx and upload it to google drive
#!/usr/bin/env bash
set -euo pipefail
# gcloud auth login --enable-gdrive-access
# Usage: ./md2drive <markdown_file>
# Example: ./md2drive example.md
# Requires: export FOLDER_ID=<your_google_drive_folder_id>
MD_FILE="${1:?usage: $0 path/to/file.md}"
# Check if markdown file exists
@OhadRubin
OhadRubin / explain_code.md
Created July 3, 2025 08:09
explain_code.md

Create a documentation file that explains code in natural language:

Part 1: Read the input file {filename} and create a new markdown file at docs/{filename}.md

Part 2: Create an initial todo list (let's call it list A) of functions/sections to document, give an complexity rating to each task.

Part 3: Group simple items together into single tasks.

  • This will ensure tasks have similar complexity levels.
  • Each item should require a similar amount of time to "think about"
  • This will result in list B that has a uniform level of complexity for each item.
#!/usr/bin/env python
"""
Parse a listing like the one in stdin and write each file to disk.
"""
import re
import sys
from pathlib import Path
_PATH_LINE = re.compile(r"^/.*:$")
#!/usr/bin/env python3.10
"""
Enhanced file expansion using Jinja2 templates with flexible functionality.
Example usage:
wget this file, apply chmod +x jinja_expand, and run it like this:
jinja_expand template.md > expanded.md
@OhadRubin
OhadRubin / expand.py
Last active May 26, 2025 12:25
Python script to expand file contents with placeholders
"""
Example usage:
python3.10 expand.py template.md > expanded.md
This will expand all {file_path} placeholders in template.md with the actual file contents
and write the result to expanded.md
```template.md
@OhadRubin
OhadRubin / eLOCm.md
Created May 26, 2025 08:55
eLOCm.md

please port this implementation of epinets into jax keep it as similar as possible to the original code. you are provided with a jax implementation of mnist to help you.

  1. come up with a plan that includes a estimated #LOC modified or e#LOCm.
  2. if a line requires more than 30 e#LOCm then you should divide it into two parts or more. This is so I could see what you are doing. The division allows me to see your output, you should say what you did after each modification and think ahead to the next modification.

Strict Script Generation Task: File Partitioning with Shell Script

Primary Objective: Your sole task is to generate a shell script containing a function definition and a sequence of function calls designed to partition the provided original_file_content based on the rules specified in the explanation. This partitioning must be complete - all original content (except imports) must appear in exactly one output file, with no content omitted or duplicated.

Inputs Provided:

  1. - Text describing how the original file should be partitioned.
  2. <original_file_content>: The content of the file to be partitioned.

Instructions - Follow Sequentially and Precisely: