Skip to content

Instantly share code, notes, and snippets.

View tamsanh's full-sized avatar

Tam Nguyen tamsanh

View GitHub Profile
@tamsanh
tamsanh / setup-python-dependencies-on-ubuntu-ec2.sh
Last active April 1, 2024 22:07
Setup Python on Ubuntu EC2
sudo apt install build-essential zlib1g-dev libffi-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev
@tamsanh
tamsanh / install-ec2-postgres.sh
Last active November 14, 2023 06:25
Install Postgres Dependencies on EC2 Amazon Linux 2023
sudo yum groupinstall -y "Development Tools"
sudo yum install -y readline-devel zlib-devel openssl-devel libuuid-devel
# To install postgres, use asdf
## Setup ASDF
sudo yum install -y git
if [ ! -e ~/.asdf ]; then
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1
fi
@tamsanh
tamsanh / config.sqlc.yaml
Created July 5, 2023 01:50
Generate python sql functions with sqlc
---
version: "2"
plugins:
- name: py
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm
sha256: aca83e1f59f8ffdc604774c2f6f9eb321a2b23e07dc83fc12289d25305fa065b
sql:
- schema: schema.sql # This is the basis for all generated queries
queries: ../queries.sql # Queries to generate
@tamsanh
tamsanh / generate-python-openapi-client.sh
Created July 4, 2023 23:23
Generate an openapi client for python
#!/bin/bash
if [ -z $2 ]; then
echo "Usage: $0 [api_url] [package_name]"
echo "Creates a client in the local directory under a 'clients' module"
exit 1
fi
api_url=${1}
package_name=${2}
@tamsanh
tamsanh / emoji_id.py
Created June 10, 2023 08:09
Generates a random combination of emojis. Not for use for real identification purposes, but can be a fun toy to spice up boring logging.
import random
emojis = "❤️ 🩷 🧡 💛 💚 💙 🩵 💜 🖤 🩶 🤍 🤎 ❤️‍🔥 ❤️‍🩹 💔 ❣️ 💕 💞 💓 💗 💖 💘 💝 💟 ☮️ ✝️ ☪️ 🪯 🕉 ☸️ ✡️ 🔯 🕎 ☯️ " \
"☦️ 🛐 ⛎ ♈️ ♉️ ♊️ ♋️ ♌️ ♍️ ♎️ ♏️ ♐️ ♑️ ♒️ ♓️ 🆔 ⚛️ 🉑 ☢️ ☣️ 📴 📳 🈶 🈚️ 🈸 🈺 🈷️ ✴️ 🆚 💮 🉐 ㊙️ ㊗️ 🈴 🈵 " \
"🈹 🈲 🅰️ 🅱️ 🆎 🆑 🅾️ 🆘 ❌ ⭕️ 🛑 ⛔️ 📛 🚫 💯 💢 ♨️ 🚷 🚯 🚳 🚱 🔞 📵 🚭 ❗️ ❕ ❓ ❔ ‼️ ⁉️ 🔅 🔆 〽️ ⚠️ 🚸 🔱 " \
"⚜️ 🔰 ♻️ ✅ 🈯️ 💹 ❇️ ✳️ ❎ 🌐 💠 Ⓜ️ 🌀 💤 🏧 🚾 ♿️ 🅿️ 🛗 🈳 🈂️ 🛂 🛃 🛄 🛅 🚹 🚺 🚼 ⚧ 🚻 🚮 🎦 🛜 📶 🈁 🔣 " \
"ℹ️ 🔤 🔡 🔠 🆖 🆗 🆙 🆒 🆕 🆓 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟 🔢 #️⃣ *️⃣ ⏏️ ▶️ ⏸ ⏯ ⏹ ⏺ ⏭ ⏮ ⏩ ⏪ ⏫ " \
"⏬ ◀️ 🔼 🔽 ➡️ ⬅️ ⬆️ ⬇️ ↗️ ↘️ ↙️ ↖️ ↕️ ↔️ ↪️ ↩️ ⤴️ ⤵️ 🔀 🔁 🔂 🔄 🔃 🎵 🎶 ➕ ➖ ➗ ✖️ 🟰 ♾ 💲 💱 ™️ ©️ ®️ 〰️ ➰ " \
"➿ 🔚 🔙 🔛 🔝 🔜 ✔️ ☑️ 🔘 🔴 🟠 🟡 🟢 🔵 🟣 ⚫️ ⚪️ 🟤 🔺 🔻 🔸 🔹 🔶 🔷 🔳 🔲 ▪️ ▫️ ◾️ ◽️ ◼️ ◻️ 🟥 🟧 🟨 🟩 " \
"🟦 🟪 ⬛️ ⬜️ 🟫 🔈 🔇 🔉 🔊 🔔 🔕 📣 📢 👁‍🗨 💬 💭 🗯 ♠️ ♣️ ♥️ ♦️ 🃏 🎴 🀄️😀 😃 😄 😁 😆 😅 😂 🤣 🥲 🥹 ☺️ " \
.DEFAULT_GOAL := help
SHELL := /bin/bash
.PHONY: help
help: # See: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
#!/bin/bash
# Setup based on .tool-version in the current directory
while read package; do
plugin=${package%% *}
version=${package#* }
printf "Checking ${package}... "
asdf list $plugin | grep $version >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
@tamsanh
tamsanh / setup-brew-and-asdf.sh
Last active February 23, 2023 20:58
asdf setup script
#!/bin/bash
# Install brew and asdf
# Setup Brew
brew --help > /dev/null 2>/dev/null
if [ $? -ne 0 ]; then
## Install if does not exist
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "brew setup complete"
@tamsanh
tamsanh / mfa_on_aws_cli.sh
Last active March 16, 2021 10:28
Multi-Factor Authentication on AWS Cli
#########################################################################################################
# Call this script locally using:
# eval "$(curl --silent https://gist.githubusercontent.com/tamsanh/92f0546322583dfd46f7d85d3510bdb7/raw)"
# This will override current AWS environment variables
#########################################################################################################
# First type in a token code that will expire after at least 20 seconds
# Ex: TOKEN_CODE=192392
read -p TOKEN_CODE= TOKEN_CODE
@tamsanh
tamsanh / github_catalog_hook.py
Created September 19, 2020 06:46
GithubCatalogHook
from io import StringIO
from typing import Optional, Dict, Any
import yaml
from kedro.framework.hooks import hook_impl
from kedro.io import DataCatalog
from kedro.versioning import Journal
def _read_github_repo_file(access_token, repo_name, filepath, branch='master'):