Skip to content

Instantly share code, notes, and snippets.

View nhthai2005's full-sized avatar

Thai H. NGUYEN (Bob) nhthai2005

View GitHub Profile
@nhthai2005
nhthai2005 / Autocomplete_ssh_scp.md
Last active January 7, 2025 10:17
Autocomplete server names for SSH and SCP for Git Bash

Autocomplete server names for SSH and SCP for Git Bash

For ssh

1. Make a file with name ssh as following content:

_ssh() 
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
@nhthai2005
nhthai2005 / git_reset
Created June 15, 2021 08:38
Git Reset Hard
#!/bin/bash
git restore *
git clean -fd
git reset --hard
@nhthai2005
nhthai2005 / unbuffer.md
Last active June 28, 2021 04:57
Shell unbuffering for CygWin: is it possible?
  • Installing the Expect package and naming "unbuffer" this script:
#!/usr/bin/expect --
# Description: unbuffer stdout of a program
# Author: Don Libes, NIST
eval spawn -noecho $argv
set timeout -1
expect
  • Installing the Expect package and naming "unbuffer" this other script:
@nhthai2005
nhthai2005 / context_menu_sublime_text.bat
Last active June 28, 2021 05:37
Add Sublime Text to your context menu on right click
@echo off
SET sublimeTextPath=D:\opt\sublime_text_build_4107_x64\sublime_text.exe
REM ADD REGISTRY KEYS
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%sublimeTextPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%sublimeTextPath% \"%%1\"" /f
pause
@nhthai2005
nhthai2005 / Resized_disk_in_Virtualbox.md
Created July 5, 2021 13:03
Resized disk in VirtualBox

Replace "vboxmanage modifyhd" with "vboxmanage clonehd"

  1. Create a new virtual disk VDI (With the size you want to expand). Example: Old.vdi had 50gb. New.vdi create it with 100GB
VBoxManage createhd --filename /path/New.vdi --size 100000
  1. Clone it with the following command:
vboxmanage clonehd /path/Old.vdi /path/New.vdi --existing
@nhthai2005
nhthai2005 / sublimetext_useful_shortcuts_pc.md
Created July 10, 2021 11:34 — forked from twalker/sublimetext_useful_shortcuts_pc.md
A fork of useful sublime text keyboard shortcuts. Using markdown and making more readable from github.

Sublime Text - Useful Shortcuts (linux)

Sublime Text 3 documentation
= Right Mouse Button
= Left Mouse Button
= Shift
= Delete
= Enter
←↑→↓ = Arrow keys

Editing

@nhthai2005
nhthai2005 / vault_install.md
Created July 11, 2021 12:05
Howto install vault in Alpine linux
apk add --no-cache vault libcap
setcap cap_ipc_lock= /usr/sbin/vault
@nhthai2005
nhthai2005 / docker_dind.sh
Last active July 16, 2021 15:28
How to run docker in docker
#!/bin/bash
docker network create some-network
docker volume create some-docker-certs-ca
docker volume create some-docker-certs-client
docker run --privileged --name some-docker -d \
--network some-network --network-alias docker \
-e DOCKER_TLS_CERTDIR=/certs \
-v some-docker-certs-ca:/certs/ca \
-v some-docker-certs-clients:/certs/client \
docker:dind
@nhthai2005
nhthai2005 / Dockerfile
Last active July 17, 2021 16:16
Exposing a port on a live Docker container
FROM debian:7
RUN apt-get update && \
apt-get -y install socat && \
apt-get clean
USER nobody
CMD socat -dddd TCP-LISTEN:1521,reuseaddr,fork TCP:db:1521
@nhthai2005
nhthai2005 / README.md
Created August 10, 2021 05:01 — forked from ptflp/README.md
docker tun device into container

Docker tun device into container install openvpn or other soft, which uses tun devices