Skip to content

Instantly share code, notes, and snippets.

@baydakovss
baydakovss / docker_compose_assume_iam_role.sh
Created January 25, 2024 15:52 — forked from jzwiep/docker_compose_assume_iam_role.sh
Assume a specific IAM role with a container via docker-compose
#!/bin/bash
# Assume the role using locally configured AWS credentials, then pass the assumed role to the container via environment
# variables!
ASSUMED_ROLE=$(aws sts assume-role \
--role-arn "arn:aws:iam::000000000000:role/our-role-to-assume" \
--role-session-name "session_name" \
--output text)
@baydakovss
baydakovss / list.txt
Created October 10, 2023 17:04 — forked from shortjared/list.txt
List of AWS Service Principals
a4b.amazonaws.com
access-analyzer.amazonaws.com
account.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
airflow-env.amazonaws.com
airflow.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com

Frontend Masters: AWS for Frontend Engineers

You should have the following completed on your computer before the workshop:

  • Install the AWS CLI.
  • Have Node.js installed on your system. (Recommended: Use nvm.)
    • Install yarn with brew install yarn.
  • Create an AWS account. (This will require a valid credit card.)
  • Create a Travis CI account. (This should be as simple as logging in via GitHub).
@baydakovss
baydakovss / gist:0944441b547233f9b641cc604c3a28d7
Last active June 17, 2023 14:31
How to list docker swarm nodes with labels
docker node ls -q | xargs docker node inspect -f '{{ .ID }} [{{ .Description.Hostname }}]: {{ .Spec.Labels }}'
docker node inspect --pretty swarm
ID: xa56lddvm1la1i8f444zw4mop
Labels:
- env=prod
@baydakovss
baydakovss / gist:bf9374d4983e17fa79469d8c5b958771
Last active June 17, 2023 17:31
Invalid mount path: mount path must be absolute error (gitbash and docker-machine)
docker run --name registry -p 5000:5000 --mount "type=bind,source=$PWD,target=/var/lib/registry" registry
docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: 'C:/Users/user/sources' mount path must be absolute
# right way
export MSYS_NO_PATHCONV=1
# workaround - double //
source=//c//Users//user//sources//project
@baydakovss
baydakovss / gist:a95dd608f5ab6d5659b3cfb870032652
Created June 15, 2023 10:18
Docker on WSL2 does not bind mount local folder to container on docker machine (virtualbox)
# Problem
# Mounting folders outside the users folder on windows is not working
cd ~/sources/../
docker run --rm -it -v .:/mnt alpine ls -1 /mnt
empty
# Workaround:
Since Docker Machine mounts Windows user folder we will deceive it.
# Windows
Move source folder to c:/Users/username/
@baydakovss
baydakovss / gist:645e72bb4389f05d056c71013f656772
Created June 15, 2023 08:39
How mount a volume of files to a remote docker daemon?
# If docker client is running on different host than docker daemon the bind mount is likely looking for folder mount on the host where daemon instead of local
export DOCKER_HOST=tcp://REMOTE:2375
docker volume create data-volume
docker create -v data-volume:/data --name helper alpine true
docker cp . helper:/data
docker rm helper
docker run --rm -it -v data-volume:/data alpine sh
@baydakovss
baydakovss / openai_translate.py
Last active May 26, 2023 12:02
Translate big text to target language in chat mode OpenAI with keeping context to better translation
import openai
import nltk
nltk.download('punkt')
openai.api_key = "XXXXXXXX"
def split_sentences(text, max_length):
"""
splitting text into chunks by sentences, not exceeding a specified maximum .
@baydakovss
baydakovss / Vagrant_setup,md
Created May 25, 2023 06:37
Vagrant +Windows + WSL2 + Hyper-v
# Vagrant With Windows, WSL2 and Hyper-V
To say getting this configuration working is a pain in the ass is an understatement. However, once it is working correctly you gain access to tools like Ansible and full performance VMs inside Windows. This guide covers the steps I followed to get things working correctly with this configuration. It is possible that something may not work for you however I have been able to reproduce this success on two Windows 11 Pro machines and expect this to work for others.
This guide assumes basic knowledge of Windows and Linux systems and how Vagrant operates. Due to the difficulty of setting this up you may need to do some additional troubleshooting
## Requirements
* Windows Professional - Hyper-V can only be installed on Windows Professional systems or higher
* WSL2 - Due to the massive differences between WSL1 and WSL2 this guide will only cover support for WSL2
* CPU Virtualization - While the vast majority of modern CPUs support virtualization you may need to enable it in
Tereminal 1:
socat TCP-L:12345,fork,reuseaddr EXEC:'sqlite3 /home/user/sources/test.db',pty
Terminal 2:
telnet localhost 12345
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.