This file contains hidden or 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 difflib | |
def extract_line_differences(source: str, modified: str) -> dict: | |
""" | |
Extracts line-level differences between two multi-line strings and returns a dictionary where: | |
- For replacements: key is the differing block of lines in the source and | |
value is the corresponding block of lines in the modified string. | |
- For deletions: key is the block of lines deleted from the source, value is an empty string. | |
- For insertions: key is a string indicating the insertion location (e.g., "INSERT_AT_LINE_#") | |
and value is the inserted block of lines from the modified string. |
This file contains hidden or 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
# Author: Naufal Suryanto | |
import requests | |
import re | |
from markdownify import markdownify as md | |
from urllib.parse import urlparse | |
def fetch_url_readme_from_git(url): | |
""" | |
Fetch the README file content from a Git repository given a URL. |
This file contains hidden or 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 weave | |
import pandas as pd | |
from tqdm import tqdm | |
def get_calls(project_id, op_name, parent_id = None): | |
client = weave.init(project_id) | |
query_data = { | |
"project_id": project_id, | |
"filter": {"op_names": [op_name]}, | |
"sort_by": [{"field": "started_at", "direction": "desc"}], |
This file contains hidden or 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
#!/usr/bin/env python3 | |
""" | |
Markdown Image Descriptor Script | |
This script processes a markdown file, extracts images, encodes them in base64, | |
and sends them with contextual text to a Visual Language Model (VLM) for description extraction. | |
The image markdown references are then replaced with the structured descriptions provided by the model. | |
If an image is deemed non-important (e.g., logos) it is replaced with a markdown comment. | |
Additionally, if an image contains text information (e.g., terminal screenshots, tables, code snippets), | |
the VLM is instructed to extract and return only the text content using markdown formatting. |
This file contains hidden or 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 typing import Dict, Union | |
from huggingface_hub import get_safetensors_metadata | |
import argparse | |
import sys | |
# Example: | |
# python get_gpu_memory.py Qwen/Qwen2.5-7B-Instruct | |
# Dictionary mapping dtype strings to their byte sizes | |
bytes_per_dtype: Dict[str, float] = { |
This file contains hidden or 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 cv2 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import argparse | |
# -------------------------- | |
# Utility Functions | |
# -------------------------- |
This file contains hidden or 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 os | |
import re | |
import base64 | |
import argparse | |
from typing import List, Dict, Any | |
from datasets import Dataset | |
def embed_images_in_markdown(markdown_text: str, base_path: str = ".") -> str: | |
""" | |
Embed images in markdown text as base64 encoded strings. |
This file contains hidden or 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 sqlite3 | |
import pandas as pd | |
from datetime import datetime, timedelta | |
# Path to your Chrome history database [Select one based on your os and chrome history path] | |
history_path = "C:\\Users\\[USER_NAME]\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History" # Windows | |
history_path = "~/Library/Application Support/Google/Chrome/Default/History" # MAC | |
history_path = "~/.config/google-chrome/Default/History" # Linux | |
# Connect to the database |
This file contains hidden or 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
#!/bin/bash | |
# initialize a semaphore with a given number of tokens | |
open_sem(){ | |
mkfifo pipe-$$ | |
exec 3<>pipe-$$ | |
rm pipe-$$ | |
local i=$1 | |
for((;i>0;i--)); do | |
printf %s 000 >&3 |
This file contains hidden or 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
#!/bin/bash | |
# Check if the correct number of arguments is provided | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <input_directory> <output_file>" | |
exit 1 | |
fi | |
# Assign input arguments to variables | |
input_dir="$1" |
NewerOlder