Skip to content

Instantly share code, notes, and snippets.

@tgran2028
tgran2028 / MyST-NB.sphinx.config.py
Last active September 24, 2023 09:58
Sphinx cnofig used by NyST-NB.
# Configuration file for the Sphinx documentation builder.
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
# -- Project information -----------------------------------------------------
project = "MyST-NB"
copyright = "2022, Executable Book Project"
author = "Executable Book Project"
@tgran2028
tgran2028 / .pre-commit-config.yaml
Created September 24, 2023 09:14
pre-commit config template
# Install pre-commit hooks via
# pre-commit install
exclude: >
(?x)^(
\.vscode/settings\.json|
tests/commonmark/commonmark\.json|
.*\.xml|
tests/.*\.txt
)$
@tgran2028
tgran2028 / activate_gnome_window.sh
Last active October 26, 2023 15:09
Script that activates a window by name so it can be configured to a global hotkey. If the window is not open, then it will launch the app/program. Requires linux and genome.
#!/bin/bash
WINDOW_NAME='Hyper'
# Use "wmctrl -l" to get list of all window names if needed
# when setting the target window name. May need to install wmctrl.
#
# Example output:
# 0x00e00003 0 dell-XPS Hyper
# 0x03600003 0 dell-XPS Script that activates a window by name so it can be configured to a global hotkey. If the window is not open, then it will launch the app/program. Requires linux and genome. and 9 more pages - Personal - Microsoft​ Edge Dev
@tgran2028
tgran2028 / pyrightconfig.default.yml
Created November 8, 2023 13:04
Default values for pyright config. YAML format of default pyrightconfig.json
# Main Configuration Options
# Paths of directories or files that should be included. If no paths are specified, pyright defaults
# to the directory that contains the config file.
include: []
# [array of paths, optional]: Paths of directories or files that should be included. If no paths are
# specified, pyright defaults to the directory that contains the config file. Paths may contain
# wildcard characters ** (a directory or multiple levels of directories), * (a sequence of zero or more
# characters), or ? (a single character). If no include paths are specified, the root path for the
# workspace is assumed.
@tgran2028
tgran2028 / run-redis-stack-docker.sh
Last active December 10, 2023 14:38
Run redis-stack docker container
#!/usr/bin/bash
################### set env vars ###################
# changedir to script parent
cd "$(dirname "$0")" || exit
# container name
REDIS_STACK_CONTAINER_NAME="redis-stack"
@tgran2028
tgran2028 / update-cargo-binaries.sh
Last active December 29, 2023 01:17
Update all installed crates at $CARGO_HOME to latest version
#!/usr/bin/env bash
# ---
# @name update-cargo-binaries.sh
# ---
# @description This script updates installed Cargo crates to their latest versions.
# It checks for the presence of required commands, verifies the CARGO_HOME environment variable,
# and updates each crate in parallel up to a specified limit.
#
# +----------------+----------------+----------------+----------------+----------------+----------------+
set -euo pipefail
@tgran2028
tgran2028 / cp-from-user.sh
Last active December 30, 2023 19:38
Util to copy file/dir from one user to another. This includes parsing relative paths to a user's home, updating ownership, and modifying file contents to home path changes (e.g. /home/foo -> /home/bar).
#!/bin/env bash
set -e
set -o pipefail
display_help() {
echo "Usage: cp-from-user [option...] --path <PATH> --source-user <SRC-USER> [--destination-user <DST-USER>]"
echo
echo "Util to copy file or directory from one user to another"
echo
echo " -p, --path <PATH> Path to the file or directory from home directory."
@tgran2028
tgran2028 / conda-environment.LLM.yaml
Last active January 9, 2024 18:18
CUDA-enabled miniconda3 environment. Includes langchain, openai, and other LLM development libs
# python=3.11
# cuda-toolkit=12.1.0
# Linux
name: LLM-env
channels:
- pytorch
- nvidia
- conda-forge
- defaults
@tgran2028
tgran2028 / gpt4all.sh
Created January 10, 2024 00:27
Install gpt4all on Linux
#!/bin/bash
sudo apt update
sudo apt install -y glslc vulkan-tools vkroots-headers vulkan-validationlayers-dev spirv-cross cmake git
if [ -d ~/.local/gpt4all ] ; then
echo "gpt4all already installed"
exit 1
fi
@tgran2028
tgran2028 / math_tutor_assistant.py
Last active January 10, 2024 15:26
Program using OpenAI's assistant API to solve math problems.
"""
math_tutor_assistant.py
Program using OpenAI's assistant API to solve math problems.
@sorce: openai/openai-python (examples/assistant.py)
"""
import time