Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
# Adapted from: https://github.com/longstnguyen/ViRE/blob/main/src/vi_retrieval_eval/textnorm.py
import re
import unicodedata
# Zero-width / invisible chars
_ZW_CHARS = [
"\u200b", # zero-width space
"\u200c", # ZWNJ
"\u200d", # ZWJ
@minhnguyent546
minhnguyent546 / setup_jupyter.sh
Last active November 2, 2025 03:24
Setup cloudflare tunnel for jupyter lab
# install cloudflared
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
sudo mv cloudflared-linux-amd64 /usr/local/bin/cloudflared
sudo chmod +x /usr/local/bin/cloudflared
# login
cloudflared tunnel login
# setup jupyter lab and password
pip install jupyterlab notebook ipywidgets ipykernel
@minhnguyent546
minhnguyent546 / setup_server.sh
Last active April 17, 2026 23:03
Script for setting up a fresh ubuntu server
#!/usr/bin/env bash
# Script for setting up a fresh ubuntu server
# Run this script via `source setup.sh`
# Check if a command exists in PATH
is_command_exist() {
# usage: is_command_exist <command-name>
if command -v "$1" >/dev/null 2>&1; then
return 0
@minhnguyent546
minhnguyent546 / .bashrc
Last active October 5, 2025 14:13
.bashrc with custom PS1 for Ubuntu with color enabled
export CONFIG_HOME='/home/khmt/Documents/TQKhangT/mthien/.config'
# load other bash files
other_bash_files=(
"${CONFIG_HOME}/.bash_aliases"
"${CONFIG_HOME}/.bash_profile"
"${CONFIG_HOME}/.bash_functions"
"${CONFIG_HOME}/.bash_export"
"${CONFIG_HOME}/colors.sh"
)
@minhnguyent546
minhnguyent546 / packages.sh
Last active October 11, 2025 03:49
Packages for fresh Ubuntu
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
git \
sudo \
tmux \
neofetch \
htop \
btop \
speedtest-cli \
tree \
import numpy as np
def average_precision(gt, pred):
"""
Computes the average precision.
This function computes the average prescision at k between two lists of
items.
@minhnguyent546
minhnguyent546 / .editorconfig
Created March 15, 2025 04:11
.editorconfig template
# https://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
@minhnguyent546
minhnguyent546 / configure-ssh-user.sh
Created March 15, 2025 03:36
configure-ssh-user.sh script
#!/bin/bash
# taken from https://github.com/aoudiamoncef/ubuntu-sshd
# Set default values for SSH_USERNAME and SSH_PASSWORD if not provided
: ${SSH_USERNAME:=ubuntu}
: ${SSH_PASSWORD:?"Error: SSH_PASSWORD environment variable is not set."}
: ${SSHD_CONFIG_ADDITIONAL:=""}
# Create the user with the provided username and set the password
@minhnguyent546
minhnguyent546 / install_miniconda.sh
Last active March 4, 2025 03:32
Install miniconda3 on Linux machine
# install miniconda
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
# activate
source ~/miniconda3/bin/activate
# init
@minhnguyent546
minhnguyent546 / pyrightconfig.json
Last active May 29, 2025 03:08
My pyrightconfig.json
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"pythonVersion": "3.10",
"venv": ".venv", // path to `venv` or `conda env`
"venvPath": ".",
"typeCheckingMode": "strict",
// disable some settings for incomplete stubs