Skip to content

Instantly share code, notes, and snippets.

View vietvudanh's full-sized avatar

Viet Vu vietvudanh

  • Ha Noi, Vietnam
View GitHub Profile
@vietvudanh
vietvudanh / rsync
Created March 25, 2020 16:31
rsync
#!/usr/bin/env bash
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rsync -arv \
--exclude-from=$CWD/exclude.txt \
$CWD \
vpn:~/
@vietvudanh
vietvudanh / convert_csv_hdf5.py
Created July 22, 2020 03:26
Convert csv to hdf5
# -*- coding: utf-8 -*-
import h5py
import sys
import pandas as pd
import datetime
if len(sys.argv) == 1:
print("No provided file")
sys.exit(1)
@vietvudanh
vietvudanh / vbox.sh
Last active July 28, 2020 05:35
Virtualbox manage
# list
vboxmanage list vms
vboxmanage list runningvms
# start
VM=cent7_1
vboxmanage startvm $VM --type headless
# stop
vboxmanage controlvm Ubuntu poweroff soft
@vietvudanh
vietvudanh / zip.sh
Last active August 14, 2020 02:09
Zip & Unzip
# .zip
zip -r -o out.zip folder
unzip out.zip
# xz
gzip -r folder
gzip -f file
gunzip out.gz
# tar.gz
@vietvudanh
vietvudanh / snippets.md
Last active April 21, 2024 01:51
My common snippets

Bash

shebang

#!/usr/bin/env bash
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

date loop

@vietvudanh
vietvudanh / sqla_nodes.py
Last active November 30, 2020 04:19
sqla nodes
"""
simple example showing sqlalchemy Adjacency List Relationships
https://docs.sqlalchemy.org/en/13/orm/self_referential.html
"""
from sqlalchemy import create_engine, Column, ForeignKey, Integer, String
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.declarative import declarative_base
DB_PATH = 'sqlite:///nodes.sql'
# 1. python file
sudo mkdir -p /opt/cred
cat <<ETO > /opt/cred/creds.py
import argparse
import sys
import yaml
parser = argparse.ArgumentParser(description='find creds or execute credential')
parser.add_argument('--mode', help='mode to run')
parser.add_argument('--name', help='name to find')
@vietvudanh
vietvudanh / lm-symlink.sh
Last active May 31, 2025 08:54
lm-symlink.sh