Skip to content

Instantly share code, notes, and snippets.

@odinokov
odinokov / ssn.sh
Last active September 12, 2024 07:37
ssn (show slurm nodes) lists SLURM nodes
#!/bin/bash
# ssn (show slurm nodes) lists SLURM nodes
# bash ssn.sh | less -SR
# to fix colors run echo -e '\033[0m'
# Define ANSI color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
@odinokov
odinokov / setup_precommit_hooks.sh
Last active August 26, 2024 03:52
The series of commands and the YAML configuration sets up a pre-commit hook environment in a Python project
pip install --user ruff black isort pre-commit codespell
echo 'repos:
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
@odinokov
odinokov / install_rust.sh
Created August 15, 2024 09:21
This script automates the setup of a Rust development environment
#!/bin/bash
#################################################################################
# Description: This script automates the setup of a Rust development environment
#################################################################################
# Define color codes for output formatting
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
@odinokov
odinokov / fetch_gnomad.py
Last active August 21, 2024 11:05
The script fetches and prints genetic variants from the gnomAD database for a specified genomic region
# The script fetches and prints genetic variants from the gnomAD database for a specified genomic region.
# Adapted from https://gist.github.com/ressy/6fd7f6ee6401ac8e703dc2709399869e
import re
import sys
from pprint import PrettyPrinter
from typing import Any, Dict, Tuple
import fire
import requests
import tenacity
@odinokov
odinokov / bb.sh
Last active July 3, 2024 14:05
Script to archive a specified directory as a tar.gz
#!/bin/bash
# Script to archive a specified directory
# Install dependencies:
# mamba install -y -c conda-forge pv crabz
# Ensure the script exits immediately if any command fails
set -e
# Cleanup function
@odinokov
odinokov / ledoit_wolf_portfolio_rebalancing.py
Last active July 21, 2023 06:38
A script to compute optimal portfolio weights using both sklearn's Ledoit-Wolf and custom shrinkage estimators
import yfinance as yf
import numpy as np
from sklearn.covariance import LedoitWolf
from scipy.optimize import minimize
import pandas as pd
from typing import Tuple
from typing import Optional
def shrinkage(returns: np.array) -> Tuple[np.array, float, float]:
# from https://github.com/WLM1ke/LedoitWolf/
#!/bin/bash
#############################################################################
# Script: restore_from_glacier.sh
# Description:
# This script restores files and folders recursively from
# Amazon S3 Glacier for a given S3 path. It checks if the restore
# is already in progress and initiates the restore for objects
# that are not currently being restored. The default values for
@odinokov
odinokov / install_ichorCNA.sh
Created April 17, 2023 07:00
How to install ichorCNA
mamba create --name ichorCNA && \
mamba activate ichorCNA && \
mamba install -y -c conda-forge -c bioconda r-essentials r-base r-devtools hmmcopy bioconductor-genomeinfodb bioconductor-genomicranges r-ichorcna && \
cd $CONDA_PREFIX/lib/R/library/ichorCNA/ && \
mkdir -p tmp && \
git clone https://github.com/broadinstitute/ichorCNA.git tmp && \
cp -r ./tmp/scripts/ .
# dry-run
Rscript $CONDA_PREFIX/lib/R/library/ichorCNA/scripts/runIchorCNA.R
@odinokov
odinokov / download_file.py
Last active March 15, 2023 04:38
Downloads a file from the given URL and saves it to the specified file path.
import os
import requests
import shutil
from tqdm import tqdm
def download_file(url: str, file_path: str) -> None:
"""
Downloads a file from the given URL and saves it to the specified file path.
Shows a progress bar using the tqdm library.
@odinokov
odinokov / print_columns.py
Created March 14, 2023 10:16
Prints the elements of a list in columns.
def print_columns(data: list, num_cols : int):
"""
Prints the elements of a list in columns.
Args:
data: A list of data to be printed.
num_cols: The number of columns to print.
Returns:
None