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
#!/usr/bin/env python3 | |
import argparse | |
import json | |
import os | |
import subprocess | |
import sys | |
import time | |
from typing import List, Tuple, Dict |
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
#!/bin/bash | |
# The default ollama server address | |
OLLAMA_URL="http://localhost:11434" | |
# Help function | |
show_help() { | |
echo "Usage: $0 [OPTIONS] [URL]" | |
echo "Unload all loaded models in ollama." | |
echo "" |
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
#!/bin/bash | |
# Function to display help message | |
function show_help() { | |
echo "Usage: $0 <language_code> [-p] <text_file_or_text>" | |
echo | |
echo "Arguments:" | |
echo " <language_code> The target language code (e.g., 'en' for English, 'ja' for Japanese)." | |
echo " <text_file_or_text> The path to the text file to be translated, or the text itself if -p is used. Use '-' to read from stdin." | |
echo |
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
#!/usr/bin/env python3 | |
from typing import List, Iterable, Iterator, Tuple | |
import subprocess | |
import sys | |
def colorize(text: str, color: str) -> str: | |
""" | |
Colorize the text for terminal output. |
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 argparse | |
import ast | |
import sys | |
from typing import List, TextIO, Optional | |
def get_variables(expr: str) -> List[str]: | |
""" | |
Given an expression, return a sorted list of variable names used in the expression. |
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
#!/usr/bin/env python3 | |
import argparse | |
import sys | |
import os | |
import pandas as pd | |
def csv_to_latex(input_file, output_file = None): | |
# Read csv file |
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
#!/usr/bin/env python3 | |
# ref: https://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line#2813530 | |
import io | |
import os | |
import subprocess | |
import sys | |
from pygments import highlight |
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
# The languages.json is obtained from the tokei project | |
# Source: https://github.com/XAMPPRocky/tokei/blob/c8e4d0703252c87b1df45382b365c6bb00769dbe/languages.json | |
from typing import Dict, Counter as CounterType | |
from collections import Counter | |
import json | |
import os | |
import sys |
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
#!/usr/bin/env python3 | |
# https://chat.openai.com/share/448d1592-749e-49f4-8e44-948b0207d075 | |
def to_markdown(jypyter_notebook_json): | |
cells = jypyter_notebook_json["cells"] | |
for cell in cells: | |
ct = cell["cell_type"] | |
if ct == "markdown": |
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
# ref https://zenn.dev/syoyo/articles/9a159ee747835a | |
import sys | |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
max_length = 512 | |
# ref https://huggingface.co/facebook/nllb-200-distilled-1.3B | |
# The model was trained with input lengths not exceeding 512 tokens, therefore translating longer sequences might result in quality degradation. |
NewerOlder