Skip to content

Instantly share code, notes, and snippets.

@sgtoj
sgtoj / docker_setup_wsl.sh
Last active January 22, 2021 15:44
Ubuntu for Windows: Setup Docker for WSL
# install docker client
curl https://download.docker.com/linux/static/stable/x86_64/docker-19.03.8.tgz > ~/docker.tar.gz
tar xzvf ~/docker.tar.gz --directory ~/
sudo mv ~/docker/docker /usr/local/bin/docker
rm -rf ~/docker
rm -f ~/docker.tar.gz
# install docker-compose client
curl -L https://github.com/docker/compose/releases/download/1.28.0/docker-compose-Linux-x86_64 > ~/docker-compose
chmod +x ~/docker-compose
@sgtoj
sgtoj / persistent_c_mount_wsl.sh
Last active January 29, 2024 06:11
Ubuntu for Windows: Mounting C: Drive to WSL's Root
# allow `mount` cmd without password
echo "$USER ALL=NOPASSWD: /bin/mount" | (sudo su -c 'EDITOR="tee -a" visudo')
# add the mount directive to `fstab`
sudo mkdir -p /c
sudo sh -c "echo '/mnt/c /c none bind' >> /etc/fstab"
# update to `.bashrc` to auto mount at login
echo "sudo mount -a" >> ~/.bashrc
# now reload it
source ~/.bashrc

Change Product Name in Registry

  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    • Set EditionID Key to Professional
    • Set ProductName Key to Windows 10 Professional
  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion
    • Set EditionID Key to Professional
    • Set ProductName Key to Windows 10 Professional

Update Windows

@sgtoj
sgtoj / wsl_py3.md
Created March 6, 2018 12:17
Install Python 3.6 from Source for Windows for Ubuntu

Python 3.6 is not avaliable via apt-get using a trusted source for the WSL's current version of Ubuntu (v16.04). Therefore, it is recommended to install Python 3.6 from source using the steps below. Be warned, installing Python from source takes several minutes to complete.

sudo apt-get install -y build-essential checkinstall
sudo apt-get install -y libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
cd /usr/src
@sgtoj
sgtoj / config_aws_raid.sh
Last active February 23, 2024 18:38
Configure Raid for AWS Instance (NVME Supported)
#!/usr/bin/env bash
# ========================================================== configurations ===
RAID_NAME=ephemeral_raid
RAID_DEVICE=/dev/md0
RAID_MOUNT_PATH=/mnt/ephemeral
# =============================================================== functions ===
@sgtoj
sgtoj / transfer_ddb.py
Created August 6, 2019 12:13
Copy DynamoDB Table to Another Table
#!/usr/bin/env python3
import boto3
# parameters for source account
SRC_ACCOUNT_PROFILE = 'aws_profile_name'
SRC_ACCOUNT_REGION = 'us-east-1'
SRC_TABLE = 'your-source-table-name'
# parameters for destination account
DST_ACCOUNT_PROFILE = 'aws_profile_name'
@sgtoj
sgtoj / aws_mfa_login.py
Last active January 27, 2020 12:52
Simple Script to Create MFA Login Sessions for AWS CLI and SDK
#!/usr/bin/env python3
import sys
from configparser import SafeConfigParser
from pathlib import Path
import boto3
import botocore
AWS_PROFILE_PATH = f"{Path.home()}/.aws/credentials"
@sgtoj
sgtoj / review_sns_topics.py
Last active December 17, 2019 15:03
Python script to query and save all SNS topics and their attributes in a given region.
#!/usr/bin/env python3
import json
import re
import sys
import os
import boto3
# -------------------------------------------------------------------- main ---
@sgtoj
sgtoj / copy_sm_secrets.py
Last active May 17, 2024 12:03
Python script to copy AWS SecretsManager Secrets
#!/usr/bin/env python3
import os
import sys
import boto3
from botocore.exceptions import ClientError
# -------------------------------------------------------------------- main ---
@sgtoj
sgtoj / aws_sso.py
Last active February 13, 2024 18:58
AWS SSO Credentials File Updater for AWS SDKs
#!/usr/bin/env python3
import json
import os
import sys
from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
import boto3