Skip to content

Instantly share code, notes, and snippets.

@vietvudanh
vietvudanh / send_string_file.py
Last active October 1, 2025 03:17
send_string_file.py
"""Script to send string to keyboard
# INSTALL
python -m venv .venv
source .venv/bin/activate
pip install pyautogui
# USAGE
1. Change `data_to_send`
2. Hover mouse to place where you want to send keystrokes in (Browser/RDP)
@vietvudanh
vietvudanh / lm-symlink.sh
Last active February 19, 2026 02:08
lm-symlink.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 / 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'
@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 / 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 / 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!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vietvudanh
vietvudanh / common_import.py
Created October 24, 2019 03:06
notebook_common_import
import os
import sys
import pandas as pd
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import seaborn as sns
from IPython.core.display import display, HTML
@vietvudanh
vietvudanh / data.py
Last active December 3, 2019 03:48
data snippets
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
def chunks_iter(l, n):
it = iter(iterable)
while True:
chunk = tuple(itertools.islice(it, n))
if not chunk:
@vietvudanh
vietvudanh / manage.sh
Last active August 24, 2019 01:57
manage script in bash
#!/usr/bin/env bash
# template for maange script in bash
# provide listing functions / usage.. etc
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# START vars
LOG_FILE="$CWD/log.log"
# END vars