Skip to content

Instantly share code, notes, and snippets.

Avatar

Viet Vu vietvudanh

  • Ha Noi, Vietnam
View GitHub Profile
View cred_install.sh
# 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 / worker-pool.go
Last active December 22, 2020 03:25 — forked from harlow/worker-pool.go
Worker pool to control concurrency and collect results
View worker-pool.go
package main
import (
"fmt"
"sync"
"time"
)
const concurrency = 3
const numTasks = 100
@vietvudanh
vietvudanh / sqla_nodes.py
Last active November 30, 2020 04:19
sqla nodes
View sqla_nodes.py
"""
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'
@vietvudanh
vietvudanh / conda.md
Last active October 26, 2022 03:35
My common snippets
View conda.md
conda env list
conda create --name dagster-3.9.11 python=3.9.11
@vietvudanh
vietvudanh / zip.sh
Last active August 14, 2020 02:09
Zip & Unzip
View zip.sh
# .zip
zip -r -o out.zip folder
unzip out.zip
# xz
gzip -r folder
gzip -f file
gunzip out.gz
# tar.gz
@vietvudanh
vietvudanh / vbox.sh
Last active July 28, 2020 05:35
Virtualbox manage
View vbox.sh
# list
vboxmanage list vms
vboxmanage list runningvms
# start
VM=cent7_1
vboxmanage startvm $VM --type headless
# stop
vboxmanage controlvm Ubuntu poweroff soft
@vietvudanh
vietvudanh / convert_csv_hdf5.py
Created July 22, 2020 03:26
Convert csv to hdf5
View convert_csv_hdf5.py
# -*- 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 / rsync
Created March 25, 2020 16:31
rsync
View rsync
#!/usr/bin/env bash
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rsync -arv \
--exclude-from=$CWD/exclude.txt \
$CWD \
vpn:~/
View spark_job.py
from pyspark.sql import SparkSession
# config
INPUT = ""
OUTPUT = ""
def main():
spark = ( SparkSession.builder
.appName("Viet PySpark")
.config("spark.dynamicAllocation.enabled","true")
@vietvudanh
vietvudanh / an-inquiry-into-matplotlib-figures.ipynb
Created January 14, 2020 02:08 — forked from akashpalrecha/an-inquiry-into-matplotlib-figures.ipynb
An Inquiry into Matplotlib's Figures, Axes, subplots and the very amazing GridSpec!
View an-inquiry-into-matplotlib-figures.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.