Skip to content

Instantly share code, notes, and snippets.

View ngoan98tv's full-sized avatar

Ngoan Tran ngoan98tv

View GitHub Profile
@ngoan98tv
ngoan98tv / directories_summary.sh
Created April 18, 2024 09:53
Big directory helpers
#!/bin/bash
# Count number of files in each directories, even subdirectories
find /data \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.pdf" -o -iname "*.tif" -o -iname "*.tiff" \) | rev | cut -d/ -f2- | rev | sort | uniq -c | sort -nr
@ngoan98tv
ngoan98tv / Dockerfile
Created January 25, 2024 04:24
Ubuntu SSH Server on Docker
FROM ubuntu:latest
RUN apt update && apt install openssh-server sudo -y
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu
RUN echo 'ubuntu:password' | chpasswd
RUN service ssh start
@ngoan98tv
ngoan98tv / ssh_command.sh
Created November 28, 2023 13:52
Run ssh command in background
# start new program
nohup myprogram > foo.log 2> foo.err < /dev/null &
# running program
# 1. Ctrl-Z to pause the program
[1]+ Stopped processName
# 2. move program to background by run:
bg %1
# 3. Disown processName with
disown %1
sudo apt-get update
sudo apt-get install -y cockpit
sudo systemctl enable cockpit.socket
sudo systemctl start cockpit.socket
@ngoan98tv
ngoan98tv / install_docker.sh
Created April 7, 2022 07:24
Install docker and docker-compose
echo "Install docker"
curl https://get.docker.com | sh && sudo systemctl --now enable docker
echo "Install docker compose"
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo "DONE"
@ngoan98tv
ngoan98tv / install_nvidia_driver.md
Last active March 8, 2024 18:23 — forked from espoirMur/install_nvidia_driver.md
How I fix this issue NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running

I had many driver installed I my virtual machine , so It was actually the reason why I was having the error.

To fix it I had first to remove all driver I have installed before using :

  • sudo apt-get purge nvidia-*
  • sudo apt-get update -sudo apt-get autoremove

After that I when a head and installed the latest version of it nvidia driver:

I did :

@ngoan98tv
ngoan98tv / backup_mongodb_rclone.sh
Created October 14, 2021 06:23
Backup mongodb (in docker) to Google Drive using rclone
#!/bin/bash
DRIVE_DIR="gdrive:BACKUP"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
MONGO_DB="dbname"
MONGO_USER="dbuser"
MONGO_PASS="dbpassword"
ARCHIVE_FILE="$MONGO_DB-$TIMESTAMP.archive"
BACKUP_FILE="$MONGO_DB-$TIMESTAMP.zip"
@ngoan98tv
ngoan98tv / clear_git_tags.sh
Created October 9, 2021 08:27
Clear all tags contains "v" in both local and remote
git tag | grep v | xargs -n1 git push --delete origin
git tag | grep v | xargs -n1 git tag -d
#!/bin/sh
# https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html
# The NVIDIA driver requires that the kernel headers and development packages for the running version of the kernel be installed at the time of the driver installation, as well whenever the driver is rebuilt. For example, if your system is running kernel version 4.4.0, the 4.4.0 kernel headers and development packages must also be installed.
# The kernel headers and development packages for the currently running kernel can be installed with:
sudo apt-get install linux-headers-$(uname -r)
# Ensure packages on the CUDA network repository have priority over the Canonical repository.
distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-$distribution.pin
<?php
define('CLI_SCRIPT', 1);
require_once('../config.php');
require_once($CFG->libdir . '/clilib.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
list($options, $unrecognized) = cli_get_params(array(
'shortnames' => '',